Re: Working towards 2.2.0: Cosmetics..

Mike (mike@oakley.keble.ox.ac.uk)
Tue, 5 Jan 1999 17:39:08 +0000 (GMT)


On Sun, 3 Jan 1999, Justin Ossevoort wrote:

> adb.c:15: asm/prom.h: No such file or directory
> adb.c:16: asm/adb.h: No such file or directory
> adb.c:17: asm/cuda.h: No such file or directory
> adb.c:18: asm/pmu.h: No such file or directory
> adb.c:20: asm/hydra.h: No such file or directory

These includes exist if you are on a power-pc which is the only time you
might want to be compiling adb.c anyway as far as I can see.
They do appear when you do a make dep though, and I don't know how you'd
go about getting rid of them.

> 8390.c: In function `ei_close':
> 8390.c:177: warning: unused variable `ei_local'
> 8390.c: In function `set_multicast_list':
> 8390.c:978: warning: unused variable `ei_local'

These are because spin_lock_irqsave and spin_lock_irqrestore often
ignore their first arguemnt. I say often, because it depends on
architecture, whether the kernel is SMP or not, and how much debuging code
is enabled. I can't see any easy way to remover these warnings (and they
are completely harmless...).

> 8390.c: In function `NS8390_trigger_send':
> 8390.c:1092: warning: unused variable `ei_local'

diff -u 8390.c.~1~ 8390.c
--- 8390.c.~1~ Mon Jan 4 12:22:21 1999
+++ 8390.c Tue Jan 5 16:18:53 1999
@@ -1089,7 +1089,6 @@
int start_page)
{
int e8390_base = dev->base_addr;
- struct ei_device *ei_local = (struct ei_device *) dev->priv;

outb_p(E8390_NODMA+E8390_PAGE0, e8390_base+E8390_CMD);

> awe_compat.h:181: warning: `my_realloc' defined but not used

As far as I can see it is safe to remove this, but I'm prepared to be told
otherwise.

diff -u awe_compat.h~ awe_compat.h
--- awe_compat.h~ Mon Jan 4 12:34:19 1999
+++ awe_compat.h Tue Jan 5 16:25:40 1999
@@ -150,7 +150,6 @@
#define my_malloc_init(memptr) _mem_start = (memptr)
#define my_malloc_memptr() _mem_start
#define my_free(ptr) /* do nothing */
-#define my_realloc(buf,oldsize,size) NULL /* no realloc */

static void *my_malloc(int size)
{
@@ -176,16 +175,6 @@
#define my_free(ptr) if (ptr) {vfree(ptr);}
#define my_kmalloc(size) kmalloc(size,GFP_KERNEL)
#define my_kfree(ptr) kfree(ptr)
-
-static void *my_realloc(void *buf, int oldsize, int size)
-{
- void *ptr;
- if ((ptr = vmalloc(size)) == NULL)
- return NULL;
- memcpy(ptr, buf, ((oldsize < size) ? oldsize : size) );
- vfree(buf);
- return ptr;
-}

/* do not allocate buffer at beginning */
#define INIT_TABLE(buffer,index,nums,type) {buffer=NULL; index=0;}

> soundcard.c:810: warning: `destroy_special_devices' defined but not used
> soundcard.c:856: warning: `sound' defined but not used

diff -u soundcard.c~ soundcard.c
--- soundcard.c~ Mon Jan 4 12:20:38 1999
+++ soundcard.c Tue Jan 5 16:36:13 1999
@@ -806,6 +806,7 @@
return -1;
}

+#ifdef MODULE
static void destroy_special_devices(void)
{
unregister_sound_special(6);
@@ -813,7 +814,6 @@
unregister_sound_special(8);
}

-#ifdef MODULE
static void
#else
void
@@ -853,11 +853,11 @@
#endif
}

+#ifdef MODULE
+
static int sound[20] = {
0
};
-
-#ifdef MODULE

int traceinit = 0;
static int dmabuf = 0;

> fbcon.c: In function `fbcon_scroll':
> fbcon.c:971: warning: unused variable `p'

This is because the fontwidth macro ignores its argument if
CONFIG_FBCON_FONTWIDTH8_ONLY is defined.

It would be possible with some #ifdefs to remove the error, but the
resulting code is, IMHO, very ugly:

if (t != 0 && logo_shown == fg_console) {
#ifndef CONFIG_FBCON_FONTWIDTH8_ONLY
struct display *p = &fb_display[unit];
int lw = (smp_num_cpus * (LOGO_W + 8) - 7) / fontwidth(p)
+ 1;
#else
int lw = (smp_num_cpus * (LOGO_W + 8) - 7) / 8 + 1;
#endif
logos_left = conp->vc_cols - lw;
while (logos_left < 0)
#ifdef CONFIG_FBCON_FONTWIDTH8_ONLY
logos_left += (LOGO_W + 8 - 7) / 8;
#else
logos_left += (LOGO_W + 8 - 7) / fontwidth(p);
#endif
logos_width = conp->vc_cols - logos_left;
}

> fbcon.c: In function `fbcon_set_font':
> fbcon.c:1423: warning: unused variable `j'

diff -u fbcon.c~ fbcon.c
--- fbcon.c~ Wed Dec 23 20:17:32 1998
+++ fbcon.c Tue Jan 5 17:12:59 1999
@@ -1420,10 +1420,12 @@
int w = op->width;
int h = op->height;
int size = h;
- int i, j, k;
+ int i, k;
u8 *new_data, *data = op->data, *p;

#ifdef CONFIG_FBCON_FONTWIDTH8_ONLY
+ int j;
+
if (w != 8)
return -EINVAL;
#endif

> inode.c: In function `fat_read_super':
> inode.c:368: warning: unsigned int format, long unsigned int arg (arg 2)
(this is fs/fat/inode.c)

diff -u inode.c~ inode.c
--- inode.c~ Mon Jan 4 12:20:38 1999
+++ inode.c Tue Jan 5 17:16:27 1999
@@ -365,7 +365,7 @@
MSDOS_SB(sb)->fsinfo_offset =
CF_LE_W(b->info_sector) * logical_sector_size + 0x1e0;
if (MSDOS_SB(sb)->fsinfo_offset + sizeof(MSDOS_SB(sb)->fsinfo_offset) > sb->s_blocksize) {
- printk("fat_read_super: Bad fsinfo_offset 0x%x\n", MSDOS_SB(sb)->fsinfo_offset);
+ printk("fat_read_super: Bad fsinfo_offset 0x%lx\n", MSDOS_SB(sb)->fsinfo_offset);
fat_brelse(sb, bh);
goto out_invalid;
}

> vfs.c: In function `nfsd_setattr':
> vfs.c:285: warning: `saved_cap' might be used uninitialized in this function
> vfs.c: In function `nfsd_write':
> vfs.c:557: warning: `saved_cap' might be used uninitialized in this function
> vfs.c: In function `nfsd_truncate':
> vfs.c:762: warning: `saved_cap' might be used uninitialized in this function
> vfs.c: In function `nfsd_permission':
> vfs.c:1285: warning: `saved_cap' might be used uninitialized in this function

These are all wrong. saved_cap can not be used uninitialized. gcc thinks
it can because the place where saved_cap is set is like
..
if(current->fsuid) {
...
saved_cap = ...
...
}

and it is later used like
if(current->fsuid) {
...
... = saved_cap;
...
}

which is obviously ok, since we set it precisely when we need to. gcc
isn't clever enough to notice this (understandably).
We could change the
kernel_cap_t saved_cap;
lines to
kernel_cap_t saved_cap=0;
purely to stop gcc winging.

> nls_base.c: In function `init_nls':
> nls_base.c:433: warning: implicit declaration of function `init_nls_iso8859_15'

diff -u include/linux/nls.h~ include/linux/nls.h
--- include/linux/nls.h~ Sun Jan 25 18:05:47 1998
+++ include/linux/nls.h Tue Jan 5 17:30:08 1999
@@ -36,6 +36,7 @@
extern int init_nls_iso8859_7(void);
extern int init_nls_iso8859_8(void);
extern int init_nls_iso8859_9(void);
+extern int init_nls_iso8859_15(void);
extern int init_nls_cp437(void);
extern int init_nls_cp737(void);
extern int init_nls_cp775(void);

> ip_input.c: In function `ip_rcv':
> ip_input.c:506: warning: unused variable `tos'

diff -u ip_input.c~ ip_input.c
--- ip_input.c~ Mon Jan 4 12:22:21 1999
+++ ip_input.c Tue Jan 5 17:32:43 1999
@@ -503,7 +503,9 @@
{
int fwres;
u16 rport;
+#ifdef CONFIG_IP_ROUTE_TOS
u8 tos = iph->tos;
+#endif

if ((fwres=call_in_firewall(PF_INET, skb->dev, iph, &rport, &skb))<FW_ACCEPT) {
if (fwres==FW_REJECT)

> mtrr.c:222: warning: `main_lock' defined but not used

diff -u mtrr.c~ mtrr.c
--- mtrr.c~ Mon Jan 4 12:19:25 1999
+++ mtrr.c Tue Jan 5 17:37:10 1999
@@ -219,7 +219,9 @@
static unsigned int ascii_buf_bytes = 0;
#endif
static unsigned int *usage_table = NULL;
+#ifdef __SMP__
static spinlock_t main_lock = SPIN_LOCK_UNLOCKED;
+#endif

/* Private functions */
#ifdef CONFIG_PROC_FS

> ip_masq_user.c:36: warning: `debug' defined but not used

It is used AFAICS. I don't see why gcc is spewing this warning at all

WARNING: None of the above patches have been tested. They may not even
compile.

-- 
Mike <rickettm@ox.compsoc.net>

If you wish to succeed, consult three old people.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/