On gio, 2014-06-12 at 10:18 +0100, Ian Campbell wrote: > On Wed, 2014-06-11 at 14:01 +0200, Dario Faggioli wrote: > > for which gcc 4.9.0 complains about, like this: > > > > block-qcow.c: In function ‘get_cluster_offset’: > > block-qcow.c:431:3: error: ‘tmp_ptr’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > > memcpy(tmp_ptr, l1_ptr, 4096); > > ^ > > block-qcow.c:606:7: error: ‘tmp_ptr2’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > > if (write(s->fd, tmp_ptr2, 4096) != 4096) { > > You initialise both of these to NULL as they are defined, but the > compiler has apparently found a path where these values can be used > without subsequently being initialised, so you are passing NULL to > memcpy/write, which can't be good. > > If you've proved that the compiler is wrong/confused and this cannot > happen please explain the how/why it is wrong here. > Your are right, sorry for this. Being super-unfamiliar with that code, I was sort of relying on the fact that it is correct, especially considering the nature of the warning message. However, I understand, and actually agree, that it really is a bad practice to suppress warnings like this... Let me have a deeper look and see if I can propose a better fix. Thanks and Regards, Dario -- <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)