2001-10-27 16:51:49

by Sven Vermeulen

[permalink] [raw]
Subject: 2.4.14-pre3: some compilerwarnings...

A little grep on the stdout/stderr of "make bzImage":

gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o fork.o fork.c
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o exec_domain.o exec_domain.c
exec_domain.c: In function `lookup_exec_domain':
exec_domain.c:80: warning: unused variable `buffer'
--
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o misc.o misc.c
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o random.o random.c
random.c: In function `xfer_secondary_pool':
random.c:1248: warning: comparison of distinct pointer types lacks a cast
--
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o procfs.o procfs.c
ld -m elf_i386 -r -o parport.o share.o ieee1284.o ieee1284_ops.o init.o procfs.o
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o parport_pc.o parport_pc.c
parport_pc.c:94: warning: `verbose_probing' defined but not used
parport_pc.c:2007: warning: `parport_ECP_supported' defined but not used
--
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o buffer.o buffer.c
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o super.o super.c
super.c: In function `mount_root':
super.c:1064: warning: label `attach_it' defined but not used
--
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o i387.o i387.c
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o bluesmoke.o bluesmoke.c
gcc -D__KERNEL__ -I/home/nitro/src/linux-2.4.13/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fomit-frame-pointer -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=k6 -c -o dmi_scan.o dmi_scan.c
dmi_scan.c:194: warning: `disable_ide_dma' defined but not used
--

I have no problems believing that some (most) of them are due to my .config,
but, as I said before, I *hate* warnings :)

--
You might as well skip the Xmas celebration completely, and instead
sit in front of your Linux computer playing with the
all-new-and-improved Linux kernel version. ~(Linus Torvalds)


2001-10-27 17:17:10

by Robert Love

[permalink] [raw]
Subject: Re: 2.4.14-pre3: some compilerwarnings...

On Sat, 2001-10-27 at 12:51, Sven Vermeulen wrote:
> A little grep on the stdout/stderr of "make bzImage":

You can't do much about unused variables because, as you suggested, they
may be present with a different config. For example, the unused
attach_it label in super.c is used if NFS is defined.

As for the typecast error, we should fix that...the attached patch uses
the typed min system macro. Linus, the attached is against
2.4.14-pre3. Please, apply.

diff -u linux-2.4.14-pre3/drivers/char/random.c linux/drivers/char/random.c
--- linux-2.4.14-pre3/drivers/char/random.c Sat Oct 27 13:13:03 2001
+++ linux/drivers/char/random.c Sat Oct 27 13:13:52 2001
@@ -1245,8 +1245,9 @@

if (r->entropy_count < nbytes * 8 &&
r->entropy_count < r->poolinfo.POOLBITS) {
- int nwords = min(r->poolinfo.poolwords - r->entropy_count/32,
- sizeof(tmp) / 4);
+ int nwords = min_t(int,
+ r->poolinfo.poolwords - r->entropy_count/32,
+ sizeof(tmp) / 4);

DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
nwords * 32,


Robert Love

2001-10-27 17:30:51

by Robert Love

[permalink] [raw]
Subject: [PATCH] Re: 2.4.14-pre3: some compilerwarnings...

On Sat, 2001-10-27 at 13:16, Robert Love wrote:
> <snip>

Hm, while we are at it, let's cleanup the MIN macros, too...might as
well just use the built-in system min. This patch includes that cleanup
as well as the typecast fix. Ignore the old, apply this, enjoy.

diff -urN linux-2.4.14-pre3/drivers/char/random.c linux/drivers/char/random.c
--- linux-2.4.14-pre3/drivers/char/random.c Sat Oct 27 13:13:03 2001
+++ linux/drivers/char/random.c Sat Oct 27 13:26:34 2001
@@ -406,10 +406,6 @@
*
*****************************************************************/

-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
/*
* Unfortunately, while the GCC optimizer for the i386 understands how
* to optimize a static rotate left of x bits, it doesn't know how to
@@ -1245,8 +1241,9 @@

if (r->entropy_count < nbytes * 8 &&
r->entropy_count < r->poolinfo.POOLBITS) {
- int nwords = min(r->poolinfo.poolwords - r->entropy_count/32,
- sizeof(tmp) / 4);
+ int nwords = min_t(int,
+ r->poolinfo.poolwords - r->entropy_count/32,
+ sizeof(tmp) / 4);

DEBUG_ENT("xfer %d from primary to %s (have %d, need %d)\n",
nwords * 32,
@@ -1359,7 +1356,7 @@
#endif

/* Copy data to destination buffer */
- i = MIN(nbytes, HASH_BUFFER_SIZE*sizeof(__u32)/2);
+ i = min(nbytes, HASH_BUFFER_SIZE*sizeof(__u32)/2);
if (flags & EXTRACT_ENTROPY_USER) {
i -= copy_to_user(buf, (__u8 const *)tmp, i);
if (!i) {
@@ -1586,7 +1583,7 @@
size_t c = count;

while (c > 0) {
- bytes = MIN(c, sizeof(buf));
+ bytes = min(c, sizeof(buf));

bytes -= copy_from_user(&buf, p, bytes);
if (!bytes) {


Robert Love

2001-10-31 17:09:12

by Ragnar Hojland Espinosa

[permalink] [raw]
Subject: Re: 2.4.14-pre3: some compilerwarnings...

On Sat, Oct 27, 2001 at 01:16:23PM -0400, Robert Love wrote:
> On Sat, 2001-10-27 at 12:51, Sven Vermeulen wrote:
> > A little grep on the stdout/stderr of "make bzImage":
>
> You can't do much about unused variables because, as you suggested, they

May I suggest the following?

--
____/| Ragnar H?jland Freedom - Linux - OpenGL | Brainbench MVP
\ o.O| PGP94C4B2F0D27DE025BE2302C104B78C56 B72F0822 | for Unix Programming
=(_)= "Thou shalt not follow the NULL pointer for | (http://www.brainbench.com)
U chaos and madness await thee at its end."


--- linux-2.4.13/arch/i386/kernel/dmi_scan.c.O Wed Oct 31 18:03:20 2001
+++ linux-2.4.13/arch/i386/kernel/dmi_scan.c Wed Oct 31 18:06:21 2001
@@ -190,6 +190,7 @@ struct dmi_blacklist
* corruption problems
*/

+static __init int disable_ide_dma(struct dmi_blacklist *d) __attribute__ ((unused));
static __init int disable_ide_dma(struct dmi_blacklist *d)
{
#ifdef CONFIG_BLK_DEV_IDE
--- linux-2.4.13/drivers/parport/parport_pc.c.O Wed Oct 31 17:59:16 2001
+++ linux-2.4.13/drivers/parport/parport_pc.c Wed Oct 31 18:09:14 2001
@@ -91,7 +91,7 @@ static struct superio_struct { /* For Su
} superios[NR_SUPERIOS] __devinitdata = { {0,},};

static int user_specified __devinitdata = 0;
-static int verbose_probing;
+static int verbose_probing __attribute__ ((unused));
static int registered_parport;

/* frob_control, but for ECR */
@@ -1756,6 +1756,7 @@ static int __devinit parport_PS2_support
return ok;
}

+static int __devinit parport_ECP_supported(struct parport *pb) __attribute__ ((unused));
static int __devinit parport_ECP_supported(struct parport *pb)
{
int i;
--- linux-2.4.13/fs/super.c.O Wed Oct 31 18:00:57 2001
+++ linux-2.4.13/fs/super.c Wed Oct 31 18:01:18 2001
@@ -1060,7 +1060,7 @@ mount_it:
vfsmnt->mnt_root = dget(sb->s_root);
bdput(bdev); /* sb holds a reference */

-attach_it:
+attach_it: __attribute__ ((unused))
root_nd.mnt = root_vfsmnt;
root_nd.dentry = root_vfsmnt->mnt_sb->s_root;
graft_tree(vfsmnt, &root_nd);
--- linux-2.4.13/kernel/exec_domain.c.O Wed Oct 31 17:58:03 2001
+++ linux-2.4.13/kernel/exec_domain.c Wed Oct 31 17:58:48 2001
@@ -77,7 +77,7 @@ static struct exec_domain *
lookup_exec_domain(u_long personality)
{
struct exec_domain * ep;
- char buffer[30];
+ char buffer[30] __attribute__ ((unused));
u_long pers = personality(personality);

read_lock(&exec_domains_lock);