The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jeff Garzik <jeff@garzik.org>
To: Andrew Morton <akpm@linux-foundation.org>, dedekind@infradead.org
Cc: LKML <linux-kernel@vger.kernel.org>, linux-mtd@lists.infradead.org
Subject: [PATCH] mtd/ubi: silence gcc warning
Date: Sun, 27 May 2007 07:32:54 -0400	[thread overview]
Message-ID: <20070527113254.GA11940@havoc.gtf.org> (raw)


Silence the gcc warning

drivers/mtd/ubi/eba.c: In function ‘ubi_eba_read_leb’:
drivers/mtd/ubi/eba.c:371: warning: ‘crc’ may be used uninitialized in this function

This is an example of the uninit'd-var warnings emitted by gcc that
can be proven to be bogus.

Normally I would commit this to my git repository containing
such verified cases, but with all the goto-driven control flow in
ubi_eba_read_leb(), I feel that initializing the 'crc' variable is
an easy way to both shut up gcc, and also make the code less fragile
for the long term.

Signed-off-by: Jeff Garzik <jeff@garzik.org>

diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 7400294..3fe1722 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -368,7 +368,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, int vol_id, int lnum, void *buf,
 	int err, pnum, scrub = 0, idx = vol_id2idx(ubi, vol_id);
 	struct ubi_vid_hdr *vid_hdr;
 	struct ubi_volume *vol = ubi->volumes[idx];
-	uint32_t crc, crc1;
+	uint32_t crc = 0, crc1;
 
 	err = leb_read_lock(ubi, vol_id, lnum);
 	if (err)

             reply	other threads:[~2007-05-27 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-27 11:32 Jeff Garzik [this message]
2007-05-27 12:48 ` [PATCH] mtd/ubi: silence gcc warning Josh Boyer
2007-05-27 12:54 ` Artem Bityutskiy

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=20070527113254.GA11940@havoc.gtf.org \
    --to=jeff@garzik.org \
    --cc=akpm@linux-foundation.org \
    --cc=dedekind@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox