From: Ben Gras Date: Tue, 27 Jun 2006 16:47:35 +0000 (+0000) Subject: . satisfy some gcc warnings (uninitialized/unused variables) X-Git-Tag: v3.1.3~280 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/mult.png?a=commitdiff_plain;h=bd535a120b35fc975ba22f5e07e59ca522fe81ac;p=minix.git . satisfy some gcc warnings (uninitialized/unused variables) . change cloexec mask from long to fd_set to remove 32 fd's per process restriction (from cloexec at least) --- diff --git a/servers/fs/device.c b/servers/fs/device.c index 275ea11a2..32f1029a1 100644 --- a/servers/fs/device.c +++ b/servers/fs/device.c @@ -175,7 +175,7 @@ vir_bytes bytes; off_t *pos; { int access = 0, size; - int m, j; + int j; iovec_t *v; /* Number of grants allocated in vector I/O. */ diff --git a/servers/fs/exec.c b/servers/fs/exec.c index 7fb3695b1..2c6234c75 100644 --- a/servers/fs/exec.c +++ b/servers/fs/exec.c @@ -606,17 +606,12 @@ struct fproc *rfp; { /* Files can be marked with the FD_CLOEXEC bit (in fp->fp_cloexec). */ - int i, proc; - long bitmap; + int i; - /* The array of FD_CLOEXEC bits is in the fp_cloexec bit map. */ - bitmap = rfp->fp_cloexec; - if (bitmap) { /* Check the file desriptors one by one for presence of FD_CLOEXEC. */ - for (i = 0; i < OPEN_MAX; i++) { - if ( (bitmap >> i) & 01) (void) close_fd(rfp, i); - } - } + for (i = 0; i < OPEN_MAX; i++) + if ( FD_ISSET(i, &rfp->fp_cloexec_set)) + (void) close_fd(rfp, i); } diff --git a/servers/fs/fproc.h b/servers/fs/fproc.h index 98c0d90c9..3d886f9ae 100644 --- a/servers/fs/fproc.h +++ b/servers/fs/fproc.h @@ -28,7 +28,7 @@ EXTERN struct fproc { char fp_sesldr; /* true if proc is a session leader */ char fp_execced; /* true if proc has exec()ced after fork */ pid_t fp_pid; /* process id */ - long fp_cloexec; /* bit map for POSIX Table 6-2 FD_CLOEXEC */ + fd_set fp_cloexec_set; /* bit map for POSIX Table 6-2 FD_CLOEXEC */ endpoint_t fp_endpoint; /* kernel endpoint number of this process */ } fproc[NR_PROCS]; diff --git a/servers/fs/main.c b/servers/fs/main.c index 7aa62badf..64c5a03ce 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -273,8 +273,6 @@ PRIVATE void fs_init() if (NR_BUFS < 6) panic(__FILE__,"NR_BUFS < 6", NO_NUM); if (V1_INODE_SIZE != 32) panic(__FILE__,"V1 inode size != 32", NO_NUM); if (V2_INODE_SIZE != 64) panic(__FILE__,"V2 inode size != 64", NO_NUM); - if (OPEN_MAX > 8 * sizeof(long)) - panic(__FILE__,"Too few bits in fp_cloexec", NO_NUM); /* The following initializations are needed to let dev_opcl succeed .*/ fp = (struct fproc *) NULL; diff --git a/servers/fs/misc.c b/servers/fs/misc.c index 93f59288e..40f77fcb5 100644 --- a/servers/fs/misc.c +++ b/servers/fs/misc.c @@ -139,8 +139,6 @@ PUBLIC int do_fcntl() register struct filp *f; int new_fd, r, fl; - long cloexec_mask; /* bit map for the FD_CLOEXEC flag */ - long clo_value; /* FD_CLOEXEC flag in proper position */ struct filp *dummy; /* Is the file descriptor valid? */ @@ -157,13 +155,14 @@ PUBLIC int do_fcntl() case F_GETFD: /* Get close-on-exec flag (FD_CLOEXEC in POSIX Table 6-2). */ - return( ((fp->fp_cloexec >> m_in.fd) & 01) ? FD_CLOEXEC : 0); + return( FD_ISSET(m_in.fd, &fp->fp_cloexec_set) ? FD_CLOEXEC : 0); case F_SETFD: /* Set close-on-exec flag (FD_CLOEXEC in POSIX Table 6-2). */ - cloexec_mask = 1L << m_in.fd; /* singleton set position ok */ - clo_value = (m_in.addr & FD_CLOEXEC ? cloexec_mask : 0L); - fp->fp_cloexec = (fp->fp_cloexec & ~cloexec_mask) | clo_value; + if(m_in.addr & FD_CLOEXEC) + FD_SET(m_in.fd, &fp->fp_cloexec_set); + else + FD_CLR(m_in.fd, &fp->fp_cloexec_set); return(OK); case F_GETFL: @@ -670,7 +669,7 @@ struct mem_map *seg_ptr; if (r != OK) { printf("dumpcore pid %d: sys_trace failed " - "at offset %d: %d\n", + "at offset %ld: %d\n", rfp->fp_pid, trace_off, r); break; } @@ -714,7 +713,7 @@ off_t off; /* offset in file */ char *buf; size_t bytes; /* how much is to be transferred? */ { - int r, block_size; + int block_size; off_t n, o, b_off; block_t b; struct buf *bp; diff --git a/servers/fs/open.c b/servers/fs/open.c index 85f24a385..6657fd42f 100644 --- a/servers/fs/open.c +++ b/servers/fs/open.c @@ -450,7 +450,7 @@ int fd_nr; put_inode(rip); } - rfp->fp_cloexec &= ~(1L << fd_nr); /* turn off close-on-exec bit */ + FD_CLR(fd_nr, &rfp->fp_cloexec_set); rfp->fp_filp[fd_nr] = NIL_FILP; FD_CLR(fd_nr, &rfp->fp_filp_inuse); diff --git a/servers/fs/protect.c b/servers/fs/protect.c index 221d91ff0..295b2dfb2 100644 --- a/servers/fs/protect.c +++ b/servers/fs/protect.c @@ -26,7 +26,7 @@ PUBLIC int do_chmod() { /* Perform the chmod(name, mode) system call. */ - register struct inode *rip; + register struct inode *rip = NULL; register int r; if(call_nr == CHMOD) { @@ -70,7 +70,7 @@ PUBLIC int do_chown() { /* Perform the chown(name, owner, group) system call. */ - register struct inode *rip; + register struct inode *rip = NULL; register int r; if(call_nr == CHOWN) { diff --git a/servers/fs/read.c b/servers/fs/read.c index 1f73c8449..b049aef89 100644 --- a/servers/fs/read.c +++ b/servers/fs/read.c @@ -50,7 +50,7 @@ int rw_flag; /* READING or WRITING */ int regular, partial_pipe = 0, partial_cnt = 0; mode_t mode_word; struct filp *wf; - int block_size; + int block_size = 0; int completed, r2 = OK; phys_bytes p; diff --git a/servers/fs/write.c b/servers/fs/write.c index 7652ea9d1..d4075905c 100644 --- a/servers/fs/write.c +++ b/servers/fs/write.c @@ -45,7 +45,8 @@ int op; /* special actions */ * Also free the double indirect block if that was the last entry in the * double indirect block. */ - int scale, ind_ex, new_ind, new_dbl, zones, nr_indirects, single, zindex, ex; + int scale, ind_ex = 0, new_ind, new_dbl, + zones, nr_indirects, single, zindex, ex; zone_t z, z1, z2 = NO_ZONE, old_zone; register block_t b; long excess, zone;