Re: Result of compiling with `-W'

From: Andrew Morton (andrewm@uow.edu.au)
Date: Thu Jul 13 2000 - 09:40:21 EST


Jakub Jelinek wrote:
>
> Also, if you cast an unsigned long to signed (which means int), you break all the 64bit
> ports (by killing top 32bits).

There were several of these. Second attempt attached. Please treat
this as 'suggested changes'.

I have taken out the setrlimit() patch.

--- linux-2.4.0-test4-pre6/drivers/net/3c515.c Thu Jul 13 20:42:32 2000
+++ linux-akpm/drivers/net/3c515.c Thu Jul 13 21:22:27 2000
@@ -1049,6 +1049,7 @@
                 cli();
                 outw(DownStall, ioaddr + EL3_CMD);
                 /* Wait for the stall to complete. */
+ /* BUG! `i' is unsigned */
                 for (i = 20; i >= 0; i--)
                         if ((inw(ioaddr + EL3_STATUS) & CmdInProgress) ==
                             0) break;
--- linux-2.4.0-test4-pre6/net/ax25/af_ax25.c Tue Jul 11 22:21:17 2000
+++ linux-akpm/net/ax25/af_ax25.c Thu Jul 13 21:21:39 2000
@@ -519,13 +519,13 @@
                           break;
 
                   case AX25_T3:
- if (ax25_ctl.arg < 0)
+ if ((signed long)ax25_ctl.arg < 0)
                                   return -EINVAL;
                           ax25->t3 = ax25_ctl.arg * HZ;
                           break;
 
                   case AX25_IDLE:
- if (ax25_ctl.arg < 0)
+ if ((signed long)ax25_ctl.arg < 0)
                                   return -EINVAL;
                           ax25->idle = ax25_ctl.arg * 60 * HZ;
                           break;
--- linux-2.4.0-test4-pre6/net/decnet/af_decnet.c Sat Jun 24 15:39:47 2000
+++ linux-akpm/net/decnet/af_decnet.c Thu Jul 13 21:24:05 2000
@@ -1199,7 +1199,7 @@
 
         case TIOCOUTQ:
                 amount = sk->sndbuf - atomic_read(&sk->wmem_alloc);
- if (amount < 0)
+ if ((signed long)amount < 0)
                         amount = 0;
                 err = put_user(amount, (int *)arg);
                 break;
--- linux-2.4.0-test4-pre6/drivers/isdn/avmb1/b1.c Tue Jul 11 22:21:14 2000
+++ linux-akpm/drivers/isdn/avmb1/b1.c Thu Jul 13 21:28:41 2000
@@ -601,7 +601,7 @@
                 ApplId = (unsigned) b1_get_word(card->port);
                 MsgLen = b1_get_slice(card->port, card->msgbuf);
                 card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                        && ( card->msgbuf[MsgLen] == '\n'
                            || card->msgbuf[MsgLen] == '\r'))
                         card->msgbuf[MsgLen--] = 0;
@@ -612,7 +612,7 @@
         case RECEIVE_DEBUGMSG:
                 MsgLen = b1_get_slice(card->port, card->msgbuf);
                 card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                        && ( card->msgbuf[MsgLen] == '\n'
                            || card->msgbuf[MsgLen] == '\r'))
                         card->msgbuf[MsgLen--] = 0;
--- linux-2.4.0-test4-pre6/fs/binfmt_aout.c Tue Jul 11 22:21:16 2000
+++ linux-akpm/fs/binfmt_aout.c Thu Jul 13 21:38:07 2000
@@ -342,7 +342,7 @@
 
                 error = bprm->file->f_op->read(bprm->file, (char *)text_addr,
                           ex.a_text+ex.a_data, &pos);
- if (error < 0) {
+ if ((signed long)error < 0) {
                         send_sig(SIGKILL, current, 0);
                         return error;
                 }
--- linux-2.4.0-test4-pre6/drivers/isdn/avmb1/c4.c Tue Jul 11 22:21:14 2000
+++ linux-akpm/drivers/isdn/avmb1/c4.c Thu Jul 13 21:42:18 2000
@@ -679,7 +679,7 @@
                 ApplId = (unsigned) _get_word(&p);
                 MsgLen = _get_slice(&p, card->msgbuf);
                 card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                        && ( card->msgbuf[MsgLen] == '\n'
                            || card->msgbuf[MsgLen] == '\r'))
                         card->msgbuf[MsgLen--] = 0;
@@ -690,7 +690,7 @@
         case RECEIVE_DEBUGMSG:
                 MsgLen = _get_slice(&p, card->msgbuf);
                 card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                        && ( card->msgbuf[MsgLen] == '\n'
                            || card->msgbuf[MsgLen] == '\r'))
                         card->msgbuf[MsgLen--] = 0;
--- linux-2.4.0-test4-pre6/drivers/video/clgenfb.c Tue Jul 11 22:21:16 2000
+++ linux-akpm/drivers/video/clgenfb.c Thu Jul 13 21:44:02 2000
@@ -875,9 +875,9 @@
         } else if (_par->var.yres_virtual == -1) {
                 /* FIXME: maximize Y virtual resolution only */
         }
- if (_par->var.xoffset < 0)
+ if ((signed)_par->var.xoffset < 0)
                 _par->var.xoffset = 0;
- if (_par->var.yoffset < 0)
+ if ((signed)_par->var.yoffset < 0)
                 _par->var.yoffset = 0;
 
         /* truncate xoffset and yoffset to maximum if too high */
--- linux-2.4.0-test4-pre6/drivers/char/epca.c Tue Jul 11 22:21:14 2000
+++ linux-akpm/drivers/char/epca.c Thu Jul 13 21:52:48 2000
@@ -3771,7 +3771,7 @@
 
                         case 5:
                                 board.port = (unsigned char *)ints[index];
- if (board.port <= 0)
+ if ((long)board.port <= 0)
                                 {
                                         printk(KERN_ERR "<Error> - epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port);
                                         invalid_lilo_config = 1;
@@ -3783,7 +3783,7 @@
 
                         case 6:
                                 board.membase = (unsigned char *)ints[index];
- if (board.membase <= 0)
+ if ((long)board.membase <= 0)
                                 {
                                         printk(KERN_ERR "<Error> - epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase);
                                         invalid_lilo_config = 1;
--- linux-2.4.0-test4-pre6/drivers/video/riva/fbdev.c Tue Jul 11 22:21:16 2000
+++ linux-akpm/drivers/video/riva/fbdev.c Thu Jul 13 21:55:17 2000
@@ -929,9 +929,9 @@
                 /* FIXME: maximize Y virtual resolution only */
         }
 
- if (v.xoffset < 0)
+ if ((signed)v.xoffset < 0)
                 v.xoffset = 0;
- if (v.yoffset < 0)
+ if ((signed)v.yoffset < 0)
                 v.yoffset = 0;
 
         /* truncate xoffset and yoffset to maximum if too high */
--- linux-2.4.0-test4-pre6/drivers/cdrom/gscd.c Tue Jul 11 22:21:14 2000
+++ linux-akpm/drivers/cdrom/gscd.c Thu Jul 13 22:01:38 2000
@@ -996,7 +996,7 @@
 void __exit exit_gscd(void)
 {
 
- del_timer_async(&gscd_timer);
+ del_timer(&gscd_timer);
 
    devfs_unregister(devfs_find_handle(NULL, "gscd", 0, 0, DEVFS_SPECIAL_BLK,
                                       0));
--- linux-2.4.0-test4-pre6/drivers/i2c/i2c-core.c Tue Jul 11 22:21:14 2000
+++ linux-akpm/drivers/i2c/i2c-core.c Thu Jul 13 22:05:56 2000
@@ -485,7 +485,7 @@
         int i,j,k,order_nr,len=0,len_total;
         int order[I2C_CLIENT_MAX];
 
- if (count < 0)
+ if ((signed)count < 0)
                 return -EINVAL;
         len_total = file->f_pos + count;
         /* Too bad if this gets longer (unlikely) */
--- linux-2.4.0-test4-pre6/drivers/net/fc/iph5526.c Sat Jun 24 15:39:44 2000
+++ linux-akpm/drivers/net/fc/iph5526.c Thu Jul 13 22:12:19 2000
@@ -3769,7 +3769,7 @@
         for (i = 0; i <= MAX_FC_CARDS; i++)
                 fc[i] = NULL;
 
- for (i = 0; i < clone_list[i].vendor_id != 0; i++)
+ for (i = 0; i < clone_list[i].vendor_id; i++)
         while ((pdev = pci_find_device(clone_list[i].vendor_id, clone_list[i].device_id, pdev))) {
                 unsigned short pci_command;
                 if (pci_enable_device(pdev))
--- linux-2.4.0-test4-pre6/drivers/sound/emu10k1/main.c Sat Jun 24 15:39:45 2000
+++ linux-akpm/drivers/sound/emu10k1/main.c Thu Jul 13 22:21:16 2000
@@ -664,22 +664,22 @@
         init_waitqueue_head(&card->open_wait);
 
         /* Register devices */
- if ((card->audio1_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
+ if ((signed long)(card->audio1_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
                 printk(KERN_ERR "emu10k1: cannot register first audio device!\n");
                 goto err_dev0;
         }
 
- if ((card->audio2_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
+ if ((signed long)(card->audio2_num = register_sound_dsp(&emu10k1_audio_fops, -1)) < 0) {
                 printk(KERN_ERR "emu10k1: cannot register second audio device!\n");
                 goto err_dev1;
         }
 
- if ((card->mixer_num = register_sound_mixer(&emu10k1_mixer_fops, -1)) < 0) {
+ if ((signed long)(card->mixer_num = register_sound_mixer(&emu10k1_mixer_fops, -1)) < 0) {
                 printk(KERN_ERR "emu10k1: cannot register mixer device!\n");
                 goto err_dev2;
         }
 
- if ((card->midi_num = register_sound_midi(&emu10k1_midi_fops, -1)) < 0) {
+ if ((signed long)(card->midi_num = register_sound_midi(&emu10k1_midi_fops, -1)) < 0) {
                 printk(KERN_ERR "emu10k1: cannot register midi device!\n");
                 goto err_dev3;
         }
--- linux-2.4.0-test4-pre6/net/atm/mpoa_proc.c Tue Jul 11 22:21:17 2000
+++ linux-akpm/net/atm/mpoa_proc.c Thu Jul 13 22:28:53 2000
@@ -5,6 +5,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 #include <linux/proc_fs.h>
 #include <linux/time.h>
 #include <asm/uaccess.h>
@@ -108,7 +109,7 @@
         eg_cache_entry *eg_entry;
         struct timeval now;
         unsigned char ip_string[16];
- if(count < 0)
+ if((signed long)count < 0)
                 return -EINVAL;
         if(count == 0)
                 return 0;
@@ -169,7 +170,7 @@
         char *page, c;
         const char *tmp;
 
- if (nbytes < 0) return -EINVAL;
+ if ((signed long)nbytes < 0) return -EINVAL;
         if (nbytes == 0) return 0;
         if (nbytes > PAGE_SIZE) nbytes = PAGE_SIZE-1;
 
--- linux-2.4.0-test4-pre6/drivers/acpi/namespace/nsutils.c Tue Jul 11 22:21:13 2000
+++ linux-akpm/drivers/acpi/namespace/nsutils.c Thu Jul 13 22:29:37 2000
@@ -299,7 +299,7 @@
         u32 i = 0;
         u32 j = 0;
 
- if (internal_name_length < 0 ||
+ if ((signed)internal_name_length < 0 ||
                 !internal_name ||
                 !converted_name_length ||
                 !converted_name)
--- linux-2.4.0-test4-pre6/net/sunrpc/pmap_clnt.c Sat Jun 24 15:39:47 2000
+++ linux-akpm/net/sunrpc/pmap_clnt.c Thu Jul 13 22:33:29 2000
@@ -171,7 +171,7 @@
         error = rpc_call(pmap_clnt, port? PMAP_SET : PMAP_UNSET,
                                         &map, okay, 0);
 
- if (error < 0) {
+ if ((signed)error < 0) {
                 printk(KERN_WARNING
                         "RPC: failed to contact portmap (errno %d).\n",
                         error);
--- linux-2.4.0-test4-pre6/net/atm/proc.c Tue Jul 11 22:21:17 2000
+++ linux-akpm/net/atm/proc.c Thu Jul 13 22:35:40 2000
@@ -495,7 +495,7 @@
         unsigned long page;
         int length;
 
- if (count < 0) return -EINVAL;
+ if ((signed long)count < 0) return -EINVAL;
         page = get_free_page(GFP_KERNEL);
         if (!page) return -ENOMEM;
         dev = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip)
@@ -524,7 +524,7 @@
         info = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip)
             ->data;
 
- if (count < 0) return -EINVAL;
+ if ((signed long)count < 0) return -EINVAL;
         page = get_free_page(GFP_KERNEL);
         if (!page) return -ENOMEM;
         length = (*info)(*pos,(char *) page);
--- linux-2.4.0-test4-pre6/drivers/sound/pss.c Wed Mar 8 08:40:24 2000
+++ linux-akpm/drivers/sound/pss.c Thu Jul 13 22:36:36 2000
@@ -233,7 +233,7 @@
         unsigned long i, limit = jiffies + HZ/10;
 
         outw(0x2000, REG(PSS_CONTROL));
- for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+ for (i = 0; i < 32768 && ((signed long)(limit-jiffies) >= 0); i++)
                 inw(REG(PSS_CONTROL));
         outw(0x0000, REG(PSS_CONTROL));
         return 1;
@@ -332,11 +332,11 @@
                 outw(0, REG(PSS_DATA));
 
                 limit = jiffies + HZ/10;
- for (i = 0; i < 32768 && (limit - jiffies >= 0); i++)
+ for (i = 0; i < 32768 && ((signed long)(limit - jiffies) >= 0); i++)
                         val = inw(REG(PSS_STATUS));
 
                 limit = jiffies + HZ/10;
- for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
+ for (i = 0; i < 32768 && ((signed long)(limit-jiffies) >= 0); i++)
                 {
                         val = inw(REG(PSS_STATUS));
                         if (val & 0x4000)
--- linux-2.4.0-test4-pre6/drivers/net/wan/sdla_chdlc.c Thu Jul 13 20:42:32 2000
+++ linux-akpm/drivers/net/wan/sdla_chdlc.c Thu Jul 13 22:42:59 2000
@@ -544,17 +544,17 @@
         } else { /* Do not ignore keepalives */
 
                 card->u.c.kpalv_tx =
- (conf->keepalive_tx_tmr - MIN_Tx_KPALV_TIMER) >= 0 ?
+ ((signed)(conf->keepalive_tx_tmr - MIN_Tx_KPALV_TIMER)) >= 0 ?
                            min (conf->keepalive_tx_tmr, MAX_Tx_KPALV_TIMER) :
                                                    DEFAULT_Tx_KPALV_TIMER;
 
                 card->u.c.kpalv_rx =
- (conf->keepalive_rx_tmr - MIN_Rx_KPALV_TIMER) >= 0 ?
+ ((signed)(conf->keepalive_rx_tmr - MIN_Rx_KPALV_TIMER)) >= 0 ?
                            min (conf->keepalive_rx_tmr, MAX_Rx_KPALV_TIMER) :
                                                    DEFAULT_Rx_KPALV_TIMER;
 
                 card->u.c.kpalv_err =
- (conf->keepalive_err_margin - MIN_KPALV_ERR_TOL) >= 0 ?
+ ((signed)(conf->keepalive_err_margin - MIN_KPALV_ERR_TOL)) >= 0 ?
                            min (conf->keepalive_err_margin, MAX_KPALV_ERR_TOL) :
                                                    DEFAULT_KPALV_ERR_TOL;
         }
@@ -563,7 +563,7 @@
         /* Setup slarp timer to control delay between slarps
          */
         card->u.c.slarp_timer =
- (conf->slarp_timer - MIN_SLARP_REQ_TIMER) >=0 ?
+ (signed)((conf->slarp_timer - MIN_SLARP_REQ_TIMER)) >=0 ?
                 min (conf->slarp_timer, MAX_SLARP_REQ_TIMER) :
                                         DEFAULT_SLARP_REQ_TIMER;
 
--- linux-2.4.0-test4-pre6/ipc/shm.c Tue Jul 11 22:21:17 2000
+++ linux-akpm/ipc/shm.c Thu Jul 13 22:44:52 2000
@@ -796,7 +796,7 @@
         struct shmid_kernel *shp;
         int err, id = 0;
 
- if (size < SHMMIN)
+ if ((signed long)size < SHMMIN)
                 return -EINVAL;
 
         down(&shm_ids.sem);
--- linux-2.4.0-test4-pre6/fs/coda/sysctl.c Sat Jun 24 15:39:46 2000
+++ linux-akpm/fs/coda/sysctl.c Thu Jul 13 22:57:58 2000
@@ -176,7 +176,7 @@
         return ( pentry->count == 0 ) ? 0 : pentry->time_sum / pentry->count;
 }
 
-static inline unsigned long absolute( unsigned long x )
+static inline unsigned long absolute( long x )
 {
         return x >= 0 ? x : -x;
 }
@@ -188,7 +188,7 @@
   
         if ( x == 0 )
                 return 0;
- if ( x < 0)
+ if ( (signed)x < 0)
                 x = -x;
 
         while ( y ) {
--- linux-2.4.0-test4-pre6/drivers/isdn/avmb1/t1isa.c Fri Apr 14 02:03:03 2000
+++ linux-akpm/drivers/isdn/avmb1/t1isa.c Thu Jul 13 22:58:52 2000
@@ -283,7 +283,7 @@
                         ApplId = (unsigned) b1_get_word(card->port);
                         MsgLen = t1_get_slice(card->port, card->msgbuf);
                         card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                                && ( card->msgbuf[MsgLen] == '\n'
                                    || card->msgbuf[MsgLen] == '\r'))
                                 card->msgbuf[MsgLen--] = 0;
@@ -294,7 +294,7 @@
                 case RECEIVE_DEBUGMSG:
                         MsgLen = t1_get_slice(card->port, card->msgbuf);
                         card->msgbuf[MsgLen--] = 0;
- while ( MsgLen >= 0
+ while ( (signed)MsgLen >= 0
                                && ( card->msgbuf[MsgLen] == '\n'
                                    || card->msgbuf[MsgLen] == '\r'))
                                 card->msgbuf[MsgLen--] = 0;
--- linux-2.4.0-test4-pre6/fs/coda/upcall.c Tue Jul 11 22:21:16 2000
+++ linux-akpm/fs/coda/upcall.c Thu Jul 13 23:06:31 2000
@@ -738,7 +738,7 @@
             if (req->uc_flags & REQ_WRITE) {
                 out = (union outputArgs *)req->uc_data;
                 /* here we map positive Venus errors to kernel errors */
- if ( out->oh.result < 0 ) {
+ if ( (signed long)out->oh.result < 0 ) {
                         printk("Tell Peter: Venus returns negative error %ld, for oc %ld!\n",
                                out->oh.result, out->oh.opcode);
                         out->oh.result = EINTR;

-
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/



This archive was generated by hypermail 2b29 : Sat Jul 15 2000 - 21:00:16 EST