From: Ben Gras Date: Sat, 25 Aug 2012 17:42:05 +0000 (+0200) Subject: various warning/errorwarning fixes for gcc47 X-Git-Tag: v3.2.1~357 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/CHANGES?a=commitdiff_plain;h=e4ac80eb60221384ea13b279eea71460312f85a2;p=minix.git various warning/errorwarning fixes for gcc47 . warnings (sometimes promoted to errors) in servers/ and kernel/ . -Os for ext2 boot module to make it small enough --- diff --git a/kernel/arch/i386/direct_tty_utils.c b/kernel/arch/i386/direct_tty_utils.c index 873cfa7a4..72a31174c 100644 --- a/kernel/arch/i386/direct_tty_utils.c +++ b/kernel/arch/i386/direct_tty_utils.c @@ -122,7 +122,7 @@ void direct_print(const char *str) int direct_read_char(unsigned char *ch) { - unsigned long b, sb; + unsigned long sb; sb = inb(KB_STATUS); @@ -130,7 +130,7 @@ int direct_read_char(unsigned char *ch) return 0; } - b = inb(KEYBD); + inb(KEYBD); if (!(sb & KB_AUX_BYTE)) return 1; diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 27bbf43ca..542084f5f 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -560,7 +560,6 @@ static void vm_print(u32_t *root) int vm_memset(endpoint_t who, phys_bytes ph, const u8_t c, phys_bytes bytes) { u32_t p; - int r = OK; struct proc *whoptr = NULL; /* NONE for physical, otherwise virtual */ @@ -592,7 +591,6 @@ int vm_memset(endpoint_t who, phys_bytes ph, const u8_t c, phys_bytes bytes) */ if((pfa=phys_memset(ptr, p, chunk))) { printf("kernel memset pagefault\n"); - r = EFAULT; break; } bytes -= chunk; diff --git a/kernel/proc.c b/kernel/proc.c index c83954ab4..1fff91c30 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -1168,7 +1168,6 @@ int try_deliver_senda(struct proc *caller_ptr, for (i = 0; i < size; i++) { /* Process each entry in the table and store the result in the table. * If we're done handling a message, copy the result to the sender. */ - int pending_recv = FALSE; dst = NONE; /* Copy message to kernel */ @@ -1220,7 +1219,6 @@ int try_deliver_senda(struct proc *caller_ptr, /* Inform receiver that something is pending */ set_sys_bit(priv(dst_ptr)->s_asyn_pending, priv(caller_ptr)->s_id); - pending_recv = TRUE; done = FALSE; continue; } diff --git a/servers/ext2/open.c b/servers/ext2/open.c index fc65e7595..151b84808 100644 --- a/servers/ext2/open.c +++ b/servers/ext2/open.c @@ -5,6 +5,7 @@ #include "fs.h" #include #include +#include #include #include "buf.h" #include "inode.h" @@ -191,7 +192,7 @@ int fs_slink() struct inode *ldirp; /* directory containing link */ register int r; /* error code */ char string[NAME_MAX]; /* last component of the new dir's path name */ - char* link_target_buf; /* either sip->i_block or bp->b_data */ + char* link_target_buf = NULL; /* either sip->i_block or bp->b_data */ struct buf *bp = NULL; /* disk buffer for link */ caller_uid = (uid_t) fs_m_in.REQ_UID; @@ -241,6 +242,7 @@ int fs_slink() } } if (r == OK) { + assert(link_target_buf); link_target_buf[fs_m_in.REQ_MEM_SIZE] = '\0'; sip->i_size = (off_t) strlen(link_target_buf); if (sip->i_size != fs_m_in.REQ_MEM_SIZE) { diff --git a/servers/inet/generic/ip_read.c b/servers/inet/generic/ip_read.c index 24bd92481..5c8926d08 100644 --- a/servers/inet/generic/ip_read.c +++ b/servers/inet/generic/ip_read.c @@ -71,7 +71,7 @@ acc_t *pack; ip_hdr_t *pack_hdr; { ip_ass_t *ass_ent; - size_t pack_hdr_len, pack_offset, tmp_offset; + size_t pack_offset, tmp_offset; u16_t pack_flags_fragoff; acc_t *prev_acc, *curr_acc, *next_acc, *head_acc, *tmp_acc; ip_hdr_t *tmp_hdr; @@ -81,7 +81,6 @@ ip_hdr_t *pack_hdr; pack_hdr->ih_proto, pack_hdr->ih_src, pack_hdr->ih_dst); pack_flags_fragoff= ntohs(pack_hdr->ih_flags_fragoff); - pack_hdr_len= (pack_hdr->ih_vers_ihl & IH_IHL_MASK) * 4; pack_offset= (pack_flags_fragoff & IH_FRAGOFF_MASK)*8; pack->acc_ext_link= NULL; diff --git a/servers/inet/generic/tcp_recv.c b/servers/inet/generic/tcp_recv.c index 41390c2de..8178899b8 100644 --- a/servers/inet/generic/tcp_recv.c +++ b/servers/inet/generic/tcp_recv.c @@ -34,15 +34,11 @@ size_t data_len; { tcp_fd_t *connuser; int tcp_hdr_flags; - int ip_hdr_len, tcp_hdr_len; u32_t seg_ack, seg_seq, rcv_hi, snd_una, snd_nxt; u16_t seg_wnd, mtu; size_t mss; int acceptable_ACK, segm_acceptable, send_rst, close_connection; - ip_hdr_len= (ip_hdr->ih_vers_ihl & IH_IHL_MASK) << 2; - tcp_hdr_len= (tcp_hdr->th_data_off & TH_DO_MASK) >> 2; - tcp_hdr_flags= tcp_hdr->th_flags & TH_FLAGS_MASK; seg_ack= ntohl(tcp_hdr->th_ack_nr); seg_seq= ntohl(tcp_hdr->th_seq_nr); @@ -1394,12 +1390,9 @@ unsigned tcp_sel_read(tcp_conn) tcp_conn_t *tcp_conn; { - tcp_fd_t *tcp_fd; size_t data_size; int fin_recv, urg, push; - tcp_fd= tcp_conn->tc_fd; - if (tcp_conn->tc_state == TCS_CLOSED) return 1; @@ -1449,7 +1442,7 @@ int *bytesp; { tcp_conn_t *tcp_conn; size_t data_size; - int fin_recv, urg, push; + int fin_recv, urg; *bytesp= 0; /* The default is that nothing is available */ @@ -1461,7 +1454,6 @@ int *bytesp; return; urg= tcp_Gmod4G(tcp_conn->tc_RCV_UP, tcp_conn->tc_RCV_LO); - push= (tcp_conn->tc_flags & TCF_RCV_PUSH); fin_recv= (tcp_conn->tc_flags & TCF_FIN_RECV); data_size= tcp_conn->tc_RCV_NXT-tcp_conn->tc_RCV_LO; diff --git a/servers/inet/sr.c b/servers/inet/sr.c index e6c6178d8..a84792c45 100644 --- a/servers/inet/sr.c +++ b/servers/inet/sr.c @@ -282,9 +282,9 @@ static int sr_rwio(m) mq_t *m; { sr_fd_t *sr_fd; - mq_t **q_head_ptr, **q_tail_ptr; - int ip_flag, susp_flag, first_flag; - int r; + mq_t **q_head_ptr = NULL, **q_tail_ptr = NULL; + int ip_flag = 0, susp_flag = 0, first_flag = 0; + int r = OK; ioreq_t request; size_t size; diff --git a/servers/ipc/shm.c b/servers/ipc/shm.c index e3aab7d82..a949f4d25 100644 --- a/servers/ipc/shm.c +++ b/servers/ipc/shm.c @@ -222,7 +222,7 @@ int do_shmctl(message *m) int cmd = m->SHMCTL_CMD; struct shmid_ds *ds = (struct shmid_ds *)m->SHMCTL_BUF; struct shmid_ds tmp_ds; - struct shm_struct *shm; + struct shm_struct *shm = NULL; struct shminfo sinfo; struct shm_info s_info; uid_t uid; diff --git a/servers/pfs/link.c b/servers/pfs/link.c index 67dc2d8f5..9fc2bfb47 100644 --- a/servers/pfs/link.c +++ b/servers/pfs/link.c @@ -9,7 +9,7 @@ int fs_ftrunc(message *fs_m_in, message *fs_m_out) { struct inode *rip; - off_t start, end; + off_t start; ino_t inumb; inumb = (ino_t) fs_m_in->REQ_INODE_NR; @@ -17,7 +17,6 @@ int fs_ftrunc(message *fs_m_in, message *fs_m_out) if( (rip = find_inode(inumb)) == NULL) return(EINVAL); start = fs_m_in->REQ_TRC_START_LO; - end = fs_m_in->REQ_TRC_END_LO; return truncate_inode(rip, start); } diff --git a/servers/pfs/uds.c b/servers/pfs/uds.c index a8a4fc46d..922d2f668 100644 --- a/servers/pfs/uds.c +++ b/servers/pfs/uds.c @@ -1092,7 +1092,6 @@ int do_getsockopt_peercred_old(message *dev_m_in, message *dev_m_out) int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out) { - int minor; int rc; size_t sndbuf = PIPE_BUF; @@ -1102,8 +1101,6 @@ int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out) uds_minor(dev_m_in), ++call_count); #endif - minor = uds_minor(dev_m_in); - rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT, (vir_bytes) 0, (vir_bytes) &(sndbuf), sizeof(size_t)); @@ -1112,7 +1109,6 @@ int do_getsockopt_sndbuf(message *dev_m_in, message *dev_m_out) int do_setsockopt_sndbuf(message *dev_m_in, message *dev_m_out) { - int minor; int rc; size_t sndbuf; @@ -1122,9 +1118,6 @@ int do_setsockopt_sndbuf(message *dev_m_in, message *dev_m_out) uds_minor(dev_m_in), ++call_count); #endif - minor = uds_minor(dev_m_in); - - rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT, (vir_bytes) 0, (vir_bytes) &sndbuf, sizeof(size_t)); @@ -1146,7 +1139,6 @@ int do_setsockopt_sndbuf(message *dev_m_in, message *dev_m_out) int do_getsockopt_rcvbuf(message *dev_m_in, message *dev_m_out) { - int minor; int rc; size_t rcvbuf = PIPE_BUF; @@ -1156,8 +1148,6 @@ int do_getsockopt_rcvbuf(message *dev_m_in, message *dev_m_out) uds_minor(dev_m_in), ++call_count); #endif - minor = uds_minor(dev_m_in); - rc = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT, (vir_bytes) 0, (vir_bytes) &(rcvbuf), sizeof(size_t)); @@ -1166,7 +1156,6 @@ int do_getsockopt_rcvbuf(message *dev_m_in, message *dev_m_out) int do_setsockopt_rcvbuf(message *dev_m_in, message *dev_m_out) { - int minor; int rc; size_t rcvbuf; @@ -1176,9 +1165,6 @@ int do_setsockopt_rcvbuf(message *dev_m_in, message *dev_m_out) uds_minor(dev_m_in), ++call_count); #endif - minor = uds_minor(dev_m_in); - - rc = sys_safecopyfrom(VFS_PROC_NR, (cp_grant_id_t) dev_m_in->IO_GRANT, (vir_bytes) 0, (vir_bytes) &rcvbuf, sizeof(size_t)); diff --git a/servers/pm/exec.c b/servers/pm/exec.c index d000fc708..040dcd393 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -66,7 +66,7 @@ int do_newexec() char *ptr; struct mproc *rmp; struct exec_info args; - int r, flags; + int r, flags = 0; if (who_e != VFS_PROC_NR && who_e != RS_PROC_NR) return EPERM; diff --git a/servers/rs/manager.c b/servers/rs/manager.c index c6ca0f9bd..0dc7a76d8 100644 --- a/servers/rs/manager.c +++ b/servers/rs/manager.c @@ -1247,12 +1247,6 @@ int *length; void share_exec(rp_dst, rp_src) struct rproc *rp_dst, *rp_src; { - struct rprocpub *rpub_src; - struct rprocpub *rpub_dst; - - rpub_src = rp_src->r_pub; - rpub_dst = rp_dst->r_pub; - if(rs_verbose) printf("RS: %s shares exec image with %s\n", srv_to_string(rp_dst), srv_to_string(rp_src)); diff --git a/servers/rs/request.c b/servers/rs/request.c index 3a56e2575..e659c712a 100755 --- a/servers/rs/request.c +++ b/servers/rs/request.c @@ -89,7 +89,6 @@ message *m_ptr; /* request message pointer */ int do_down(message *m_ptr) { register struct rproc *rp; - register struct rprocpub *rpub; int s; char label[RS_MAX_LABEL_LEN]; @@ -107,7 +106,6 @@ int do_down(message *m_ptr) printf("RS: do_down: service '%s' not found\n", label); return(ESRCH); } - rpub = rp->r_pub; /* Check if the call can be allowed. */ if((s = check_call_permission(m_ptr->m_source, RS_DOWN, rp)) != OK) @@ -324,7 +322,6 @@ int do_edit(message *m_ptr) int do_refresh(message *m_ptr) { register struct rproc *rp; - register struct rprocpub *rpub; int s; char label[RS_MAX_LABEL_LEN]; @@ -342,7 +339,6 @@ int do_refresh(message *m_ptr) printf("RS: do_refresh: service '%s' not found\n", label); return(ESRCH); } - rpub = rp->r_pub; /* Check if the call can be allowed. */ if((s = check_call_permission(m_ptr->m_source, RS_REFRESH, rp)) != OK) @@ -833,7 +829,6 @@ void do_sigchld() int status; struct rproc *rp; struct rproc **rps; - struct rprocpub *rpub; int i, nr_rps; if(rs_verbose) @@ -842,7 +837,6 @@ void do_sigchld() while ( (pid = waitpid(-1, &status, WNOHANG)) != 0 ) { rp = lookup_slot_by_pid(pid); if(rp != NULL) { - rpub = rp->r_pub; if(rs_verbose) printf("RS: %s exited via another signal manager\n", diff --git a/servers/rs/utility.c b/servers/rs/utility.c index 03b3d8ebc..e2e6b8e67 100644 --- a/servers/rs/utility.c +++ b/servers/rs/utility.c @@ -180,10 +180,6 @@ struct rproc *rp; /* pointer to process slot */ int code; /* status code */ { /* If a caller is waiting for a reply, unblock it. */ - struct rprocpub *rpub; - - rpub = rp->r_pub; - if(rp->r_flags & RS_LATEREPLY) { message m; m.m_type = code; diff --git a/servers/vfs/coredump.c b/servers/vfs/coredump.c index 6d484d83d..43ccfda4f 100644 --- a/servers/vfs/coredump.c +++ b/servers/vfs/coredump.c @@ -304,11 +304,17 @@ static void dump_segments(struct filp *f, Elf_Phdr phdrs[], int phnum) } for (off = 0; off < (off_t) len; off += CLICK_SIZE) { - r = sys_vircopy(fp->fp_endpoint, - (vir_bytes) (seg_off + off), + vir_bytes p = (vir_bytes) (seg_off + off); + r = sys_vircopy(fp->fp_endpoint, p, SELF, (vir_bytes) buf, (phys_bytes) CLICK_SIZE); + if(r != OK) { + printf("VFS: vircopy failed for %d @ 0x%lx during coredump\n", + fp->fp_endpoint, p); + break; + } + write_buf(f, (char *) buf, (off + CLICK_SIZE <= (off_t) len) ? CLICK_SIZE : (len - off)); } diff --git a/servers/vfs/main.c b/servers/vfs/main.c index bfbb11047..7a4beb86f 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -330,14 +330,8 @@ static void unlock_pm(void) /*===========================================================================* * do_pm * *===========================================================================*/ -static void *do_pm(void *arg) +static void *do_pm(void *arg __unused) { - struct job my_job; - struct fproc *rfp; - - my_job = *((struct job *) arg); - rfp = fp = my_job.j_fp; - lock_pm(); service_pm(); unlock_pm(); diff --git a/servers/vfs/utility.c b/servers/vfs/utility.c index b69945e85..b3f078c53 100644 --- a/servers/vfs/utility.c +++ b/servers/vfs/utility.c @@ -30,8 +30,6 @@ inline int copy_name( size_t len, char *dest) { /* Go get path and put it in 'dest'. */ - register char *rpu, *rpm; - if (len > PATH_MAX) { /* 'len' includes terminating-nul */ err_code = ENAMETOOLONG; return(EGENERIC); @@ -45,8 +43,6 @@ inline int copy_name( size_t len, char *dest) if (len <= M3_STRING) { /* Just copy the path from the message */ - rpu = &dest[0]; - rpm = job_m_in.pathname; /* contained in input message */ strncpy(dest, job_m_in.pathname, len); } else { /* String is not contained in the message. */ diff --git a/servers/vm/main.c b/servers/vm/main.c index d6692f3b1..46308f43e 100644 --- a/servers/vm/main.c +++ b/servers/vm/main.c @@ -78,7 +78,6 @@ int main(void) message msg; int result, who_e, rcv_sts; int caller_slot; - struct vmproc *vmp_caller; /* Initialize system so that all processes are runnable */ init_vm(); @@ -112,7 +111,6 @@ int main(void) who_e = msg.m_source; if(vm_isokendpt(who_e, &caller_slot) != OK) panic("invalid caller %d", who_e); - vmp_caller = &vmproc[caller_slot]; c = CALLNUMBER(msg.m_type); result = ENOSYS; /* Out of range or restricted calls return this. */ diff --git a/servers/vm/signal.c b/servers/vm/signal.c index 50063a5e0..b92267c5a 100644 --- a/servers/vm/signal.c +++ b/servers/vm/signal.c @@ -35,7 +35,6 @@ int do_push_sig(message *msg) int r, n; endpoint_t ep; vir_bytes sp; - struct vmproc *vmp; ep = msg->VMPS_ENDPOINT; @@ -43,7 +42,6 @@ int do_push_sig(message *msg) printf("VM: bogus endpoint %d from %d\n", ep, msg->m_source); return r; } - vmp = &vmproc[n]; if ((r=get_stack_ptr(ep, &sp)) != OK) panic("couldn't get new stack pointer (for sig): %d", r); diff --git a/sys/arch/i386/stand/bootxx/bootxx_ext2fs/Makefile b/sys/arch/i386/stand/bootxx/bootxx_ext2fs/Makefile index 2a6418aa3..f84710be3 100644 --- a/sys/arch/i386/stand/bootxx/bootxx_ext2fs/Makefile +++ b/sys/arch/i386/stand/bootxx/bootxx_ext2fs/Makefile @@ -3,5 +3,6 @@ FS=ext2fs CLEANFILES= lib CPPFLAGS+= -D_MINIX +CFLAGS+= -Os .include <../Makefile.bootxx>