On 03/16/2011 03:05 PM, Benjamin Herrenschmidt wrote:
On Wed, 2011-03-16 at 17:03 +0100, Alexander Graf wrote:
+int spapr_tce_dma_zero(VIOsPAPRDevice *dev, uint64_t taddr,
uint32_t size)
+{
+    uint8_t *zeroes;
+
+#ifdef DEBUG_TCE
+    fprintf(stderr, "spapr_tce_dma_zero taddr=0x%llx size=0x%x\n",
+            (unsigned long long)taddr, size);
+#endif
+
+    /* FIXME: do this better... */
+    zeroes = alloca(size);
+    memset(zeroes, 0, size);
You sure that zeroes is still alive during the call? If I were a
compiler, I'd probably optimize the return away so that it'd end up
being a simple branch to spapr_tce_dma_write - coincidentally
invalidating the stack that zeroes is on.
Ugh ? How would this ever be legal for a compiler to do that ?

But BTW, if you're already being evil and using alloca, it's a whole lot nicer to just do:

uint8_t zeros[size];

Regards,

Anthony Liguori

Ben.





Reply via email to