]> Zhao Yanbai Git Server - minix.git/commitdiff
Fixed a number of uses of uninitialized variables by adding assertions
authorKees van Reeuwijk <reeuwijk@few.vu.nl>
Wed, 27 Jan 2010 10:23:58 +0000 (10:23 +0000)
committerKees van Reeuwijk <reeuwijk@few.vu.nl>
Wed, 27 Jan 2010 10:23:58 +0000 (10:23 +0000)
or other sanity checks, code reshuffling, or fixing broken behavior.

14 files changed:
drivers/audio/framework/audio_fw.c
drivers/floppy/floppy.c
lib/stdio/doprnt.c
lib/stdio/doscan.c
servers/ds/store.c
servers/hgfs/lookup.c
servers/inet/generic/tcp_send.c
servers/inet/sr.c
servers/ipc/sem.c
servers/is/main.c
servers/mfs/link.c
servers/pm/alarm.c
servers/rs/service.c
servers/vfs/main.c

index d70a255f3332a99b89412f2b78ac930cfed0ffcd..7d093b9f1a32fb79476c3470ec37103d02777400 100644 (file)
@@ -945,8 +945,8 @@ PRIVATE int init_buffers(sub_dev_t *sub_dev_ptr)
        if (!(sub_dev_ptr->ExtraBuf = malloc(sub_dev_ptr->NrOfExtraBuffers * 
                                        sub_dev_ptr->DmaSize / 
                                        sub_dev_ptr->NrOfDmaFragments))) {
-               error("%s failed to allocate extra buffer for channel %d\n", 
-                               drv.DriverName,i);
+               error("%s failed to allocate extra buffer for a channel\n", 
+                               drv.DriverName);
                return EIO;
        }
 
index 86cd7a8825c09f1ccbb6e3d19b9c97d784b663b7..9d313984fd317eb1384be3b0155090d62261571f 100644 (file)
@@ -642,18 +642,18 @@ unsigned nr_req;          /* length of request vector */
                                if (*up != NO_OFFSET) break;
                                fp->fl_sector++;
                        }
-               }
 
-               if (r == OK && opcode == DEV_SCATTER_S) {
-                       /* Copy the user bytes to the DMA buffer. */
-                       if(proc_nr != SELF) {
-                          s=sys_safecopyfrom(proc_nr, *ug, *up,
-                               (vir_bytes) floppy_buf,
-                                (phys_bytes) SECTOR_SIZE, D);
-                          if(s != OK)
-                               panic("FLOPPY", "sys_safecopyfrom failed", s);
-                       } else {
-                          memcpy(floppy_buf, (void *) (*ug + *up), SECTOR_SIZE);
+                       if (opcode == DEV_SCATTER_S) {
+                               /* Copy the user bytes to the DMA buffer. */
+                               if(proc_nr != SELF) {
+                                  s=sys_safecopyfrom(proc_nr, *ug, *up,
+                                       (vir_bytes) floppy_buf,
+                                        (phys_bytes) SECTOR_SIZE, D);
+                                  if(s != OK)
+                                       panic("FLOPPY", "sys_safecopyfrom failed", s);
+                               } else {
+                                  memcpy(floppy_buf, (void *) (*ug + *up), SECTOR_SIZE);
+                               }
                        }
                }
 
index 9c4aba2fedc42504155613394298fd9512eb2609..d1cf1d26c0b622811132abe539a1fc36d88ab7cf 100644 (file)
@@ -107,6 +107,7 @@ o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed)
        case 'x':
        case 'X':
        case 'p':       base = 16;      break;
+       default:        base = 10;      break;
        }
 
        s = _i_compute(unsigned_val, base, s, precision);
index 2c1034e64581d2f8839deb4c62b2667f3cf96066..a9386a61fb240123e33d0081a005dac02d88b00a 100644 (file)
@@ -46,6 +46,7 @@ o_collect(register int c, register FILE *stream, char type,
        case 'u':       base = 10;      break;
        case 'o':       base = 8;       break;
        case 'b':       base = 2;       break;
+       default:        base = 10;      break;
        }
 
        if (c == '-' || c == '+') {
index 0c478bb5b213f22f5fb6116c1d9ac0eec710ad34..b2dac7da667570e84ab1c58dd97f5ab95132a2a7 100644 (file)
@@ -444,7 +444,7 @@ PUBLIC int do_retrieve(message *m_ptr)
                if(!GRANT_VALID(gid))
                        return -1;
                m_ptr->DS_VAL = gid;
-               m_ptr->DS_VAL_LEN = length;
+               m_ptr->DS_VAL_LEN = dsp->u.map.length;
        }
 
        /* The caller requested a copy of a mapped mem range or a snapshot. */
index 8de9b73b0a75eb19eb04db29274e36d6104c0a39..bee89d8029fdb634964b84637b94ad999758bb83 100644 (file)
@@ -197,7 +197,8 @@ PUBLIC int do_lookup()
 /* Resolve a path string to an inode.
  */
   ino_t dir_ino_nr, root_ino_nr;
-  struct inode *cur_ino, *next_ino, *root_ino;
+  struct inode *cur_ino, *root_ino;
+  struct inode *next_ino = NIL_INODE;
   struct hgfs_attr attr;
   char buf[PATH_MAX], path[PATH_MAX];
   char name[NAME_MAX+1];
index 3d0be8b310799ed3f8ca4209b3cec33f936113e4..793cbcd0b02867478557852855cd0fcaec3c073c 100644 (file)
@@ -162,8 +162,8 @@ PRIVATE acc_t *make_pack(tcp_conn)
 tcp_conn_t *tcp_conn;
 {
        acc_t *pack2write, *tmp_pack, *tcp_pack;
-       tcp_hdr_t *tcp_hdr;
-       ip_hdr_t *ip_hdr;
+       tcp_hdr_t *tcp_hdr = NULL;
+       ip_hdr_t *ip_hdr = NULL;
        int tot_hdr_size, ip_hdr_len, no_push, head, more2write;
        u32_t seg_seq, seg_lo_data, queue_lo_data, seg_hi, seg_hi_data;
        u16_t seg_up, mss;
@@ -495,6 +495,8 @@ after_data:
                        return NULL;
                }
 
+               assert( tcp_hdr != NULL );
+               assert( ip_hdr != NULL );
                tcp_hdr->th_seq_nr= htonl(seg_seq);
                tcp_hdr->th_ack_nr= htonl(tcp_conn->tc_RCV_NXT);
                tcp_hdr->th_flags= seg_flags;
index b659f130ff3ffe2c2a5be80571d316a005953a8b..1fc8e56a38b28c843adc7487bbba8405da762a93 100644 (file)
@@ -176,6 +176,7 @@ mq_t *m;
                break;
        case DEV_STATUS:
                sr_status(&m->mq_mess);
+               result= OK;   /* Satisfy lint. */
                send_reply= 0;
                free_mess= 1;
                break;
index 5eaf59e7bfe61dd339c23afd1db9850c3e9a2da0..f4f3cbc633a2d7384bb7fef383573c8f3dd701b7 100644 (file)
@@ -446,7 +446,7 @@ PUBLIC int do_semop(message *m)
        struct sembuf *sops;
        unsigned int nsops;
        struct sem_struct *sem;
-       int no_reply;
+       int no_reply = 0;
 
        id = m->SEMOP_ID;
        nsops = (unsigned int) m->SEMOP_SIZE;
@@ -515,7 +515,6 @@ PUBLIC int do_semop(message *m)
 
        }
        /* there will be no errors left, so we can go ahead */
-       no_reply = 0;
        for (i = 0; i < nsops; i++) {
                struct semaphore *s;
                int op_n;
index b1117381cfc093add64a8efaefd6243df2686151..8e0d71b07b79c35d66944e5e61eb01d5308d508f 100644 (file)
@@ -64,6 +64,10 @@ PUBLIC int main(int argc, char **argv)
                      case TTY_PROC_NR:
                              result = do_fkey_pressed(&m_in);
                              break;
+                     default:
+                             /* FIXME: error message. */
+                             result = EDONTREPLY;
+                             break;
              }
       }
       else {
index 5645d94261f65ae9060de65b78e966e25efecbd3..5ac8558d23b2bda9161723e2c46b10e57dc9d5db 100644 (file)
@@ -327,6 +327,8 @@ PUBLIC int fs_rename()
   
   if(old_ip != NIL_INODE)
          odir = ((old_ip->i_mode & I_TYPE) == I_DIRECTORY); /* TRUE iff dir */
+  else
+         odir = FALSE; /* FIXME: is this a safe default? */
 
   /* If it is ok, check for a variety of possible errors. */
   if(r == OK) {
index 33a44176f43e9c5095d421a5000999fc83670697..82f4172cb0f38bea66a3df438c16c51006e1ae73 100644 (file)
@@ -143,6 +143,9 @@ PUBLIC int do_itimer()
 
                r = OK;
                break;
+
+       default:
+               panic(__FILE__, "invalid timer type", m_in.which_timer);
   }
 
   /* If requested, copy the old interval timer to user space. */
index f84e62afea12ce1585af8a3972a0a0aa24135469..599d2719eaec26ac8fa59bdcef1de2241a91fa7b 100644 (file)
@@ -1068,7 +1068,7 @@ PRIVATE void do_config(char *label, char *filename)
 PUBLIC int main(int argc, char **argv)
 {
   message m;
-  int result;
+  int result = EXIT_SUCCESS;
   int request;
   int i;
   char *label, *progname = NULL;
index 4508025d6eb3780d29d9554ece2377d8ab9152f9..8379173deeac2d9ba08d278789eec942ad9cc54e 100644 (file)
@@ -168,6 +168,7 @@ PUBLIC int main(void)
                        break;
                default:
                        caught = 0;
+                       error = 0; /* To satisfy lints. */
                        break;
           }
           if(caught) {