From: Dario Faggioli <dario.faggioli@citrix.com>
To: Ian Campbell <Ian.Campbell@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org, Keir Fraser <keir@xen.org>,
Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: Re: [blktap2] fix two 'maybe uninitialized' variables
Date: Thu, 12 Jun 2014 11:30:42 +0200 [thread overview]
Message-ID: <1402565442.28649.44.camel@Solace> (raw)
In-Reply-To: <1402564712.8162.5.camel@kazak.uk.xensource.com>
[-- Attachment #1.1: Type: text/plain, Size: 1619 bytes --]
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
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-06-12 9:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 12:01 [blktap2] fix two 'maybe uninitialized' variables Dario Faggioli
2014-06-11 12:09 ` Dario Faggioli
2014-06-12 9:18 ` Ian Campbell
2014-06-12 9:30 ` Dario Faggioli [this message]
2014-06-12 11:40 ` Dario Faggioli
2014-06-17 10:07 ` Dario Faggioli
2014-06-18 14:02 ` Ian Campbell
2014-06-20 14:11 ` Dario Faggioli
2014-06-23 17:08 ` Ian Jackson
2014-06-23 17:13 ` Ian Jackson
2014-07-02 15:07 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402565442.28649.44.camel@Solace \
--to=dario.faggioli@citrix.com \
--cc=Ian.Campbell@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.