mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Al Viro <viro@ftp.linux.org.uk>
Cc: alan@lxorguk.ukuu.org.uk, davej@redhat.com, kaos@ocs.com.au,
	linux-kernel@vger.kernel.org
Subject: Re: 2.6.14 assorted warnings
Date: Mon, 31 Oct 2005 09:29:16 +1100	[thread overview]
Message-ID: <20051031092916.249e88c9.sfr@canb.auug.org.au> (raw)
In-Reply-To: <20051030223204.GO7992@ftp.linux.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

Also, this test case:

------------------------------------------------------------
extern int f1(void);

static unsigned char f2(unsigned int *def)
{
	if (!f1())
		return 0;
	*def = 1;
	return 1;
}

unsigned char f3(unsigned char **eoc)
{
	unsigned int def;

	if (!f2(&def))
		return 0;
	if (def)
		*eoc = (unsigned char *)1;
	else
		*eoc = 0;
	return 1;
}

static int f4(unsigned int *def)
{
	if (!f1())
		return 0;
	*def = 1;
	return 1;
}

unsigned char f5(unsigned char **eoc)
{
	unsigned int def;

	if (!f4(&def))
		return 0;
	if (def)
		*eoc = (unsigned char *)1;
	else
		*eoc = 0;
	return 1;
}
------------------------------------------------------------

compiled with "gcc -Wall -O2" gives:
xx.c: In function 'f3':
xx.c:14: warning: 'def' may be used uninitialized in this function

but doesn't complain about the same code in f5.  The difference is that
f4 returns "int" while f2 returns "unsigned char".  This has apparently
been fixed in gcc mainline - the above comes from Debian unstables' gcc
(4.0.3 20051023 (prerelease) (Debian 4.0.2-3)).

Compiling with "gcc -Wall -O2 -fnoinline" suppresses the warning.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2005-10-30 22:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28  7:21 Keith Owens
2005-10-28  7:28 ` Jens Axboe
2005-10-28  7:30 ` Dave Jones
2005-10-28  8:07   ` Arnd Bergmann
2005-10-28  8:29     ` Jens Axboe
2005-10-29  5:59       ` Richard Knutsson
2005-10-29  6:03         ` Al Viro
2005-10-28  8:10   ` Richard Knutsson
2005-10-30 22:15   ` Alan Cox
2005-10-30 22:25     ` Al Viro
2005-10-30 22:32       ` Al Viro
2005-10-30 22:29         ` Stephen Rothwell [this message]
2005-10-31  0:53     ` Paul Mackerras
2005-10-31  0:57       ` Al Viro

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=20051031092916.249e88c9.sfr@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davej@redhat.com \
    --cc=kaos@ocs.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.linux.org.uk \
    /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

all inboxes | Powered by JetHome®