. 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)
This commit is contained in:
Ben Gras 2006-06-27 16:47:35 +00:00
parent a0f8161fe7
commit bd535a120b
9 changed files with 19 additions and 26 deletions

View file

@ -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. */

View file

@ -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);
}

View file

@ -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];

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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) {

View file

@ -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;

View file

@ -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;