Fix printfs with too few or too many parms, remove unused vars, fix incorrect flag tests, other code cleanup.

This commit is contained in:
Kees van Reeuwijk 2010-04-01 13:25:05 +00:00
parent c3f649557e
commit fc7dced1fa
59 changed files with 127 additions and 222 deletions

View file

@ -424,7 +424,7 @@ static void restore_screen(void)
sizeof(boot_tty_info));
if(boot_tty_info.magic == TTYMAGIC) {
if(boot_tty_info.flags & (BTIF_CONSORIGIN|BTIF_CONSCURSOR) ==
if((boot_tty_info.flags & (BTIF_CONSORIGIN|BTIF_CONSCURSOR)) ==
(BTIF_CONSORIGIN|BTIF_CONSCURSOR)) {
int line;
raw_copy(mon2abs(consolescreen),

View file

@ -1307,7 +1307,6 @@ int main(int argc, char **argv)
/* Driver task.
*/
message m;
sigset_t set;
int r;
/* Initialize SEF. */

View file

@ -260,15 +260,15 @@ PRIVATE void do_conf(const message * mp)
}
} else { /* Port number is out of range */
port = ENXIO;
dep = NULL;
}
reply_mess.m_type = DL_CONF_REPLY;
reply_mess.m3_i1 = port;
reply_mess.m3_i2 = DE_PORT_NR;
/* FIXME: if port number is out of range, this uses
* uninitialized variable 'dep'.
*/
*(ether_addr_t *) reply_mess.m3_ca1 = dep->de_address;
if(dep != NULL){
*(ether_addr_t *) reply_mess.m3_ca1 = dep->de_address;
}
if (send(mp->m_source, &reply_mess) != OK)
panic(str_SendErrMsg, mp->m_source);
@ -291,7 +291,7 @@ PRIVATE void do_get_name(message *mp)
PRIVATE void do_reply(dpeth_t * dep, int err, int may_block)
{
message reply;
int status = FALSE;
int status = 0;
if (dep->de_flags & DEF_ACK_SEND) status |= DL_PACK_SEND;
if (dep->de_flags & DEF_ACK_RECV) status |= DL_PACK_RECV;
@ -620,7 +620,6 @@ PRIVATE void de_first_init(dpeth_t *dep)
int i,j,r;
vir_bytes descr_vir = dep->sendrecv_descr_buf;
vir_bytes buffer_vir = dep->sendrecv_buf;
de_descr_t *phys_descr;
de_loc_descr_t *loc_descr;
u32_t temp;

View file

@ -624,8 +624,8 @@ int hermes_read_ltv (hermes_t * hw, int bap, u16_t rid, unsigned bufsize,
if (rtype != rid) {
printf("hermes @ %lx: hermes_read_ltv(): rid (0x%04x)",
hw->iobase);
printf("does not match type (0x%04x)\n", rid, rtype);
hw->iobase, rid);
printf("does not match type (0x%04x)\n", rtype);
}
if (HERMES_RECLEN_TO_BYTES (rlength) > bufsize) {

View file

@ -1168,7 +1168,7 @@ int devind;
/*===========================================================================*
* record_bars *
*===========================================================================*/
PRIVATE void record_bars(devind, last_reg)
PRIVATE void record_bars(int devind, int last_reg)
{
int i, reg, width;
@ -2397,7 +2397,7 @@ int port;
port);
#if USER_SPACE
if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL)))
printf("PCI: warning, sys_outl failed: %d\n");
printf("PCI: warning, sys_outl failed: %d\n", s);
#else
outl(PCII_CONFADD, PCII_UNSEL);
#endif
@ -2514,7 +2514,7 @@ u32_t value;
port, value);
#if USER_SPACE
if (OK != (s=sys_outl(PCII_CONFADD, PCII_UNSEL)))
printf("PCI: warning, sys_outl failed: %d\n");
printf("PCI: warning, sys_outl failed: %d\n",s);
#else
outl(PCII_CONFADD, PCII_UNSEL);
#endif
@ -2523,8 +2523,7 @@ u32_t value;
/*===========================================================================*
* pcii_rsts *
*===========================================================================*/
PRIVATE u16_t pcii_rsts(busind)
int busind;
PRIVATE u16_t pcii_rsts(int busind)
{
u16_t v;
int s;

View file

@ -263,7 +263,7 @@ _PROTOTYPE( static void check_int_events, (void) );
_PROTOTYPE( static void do_hard_int, (void) );
_PROTOTYPE( static void rtl8169_dump, (void) );
_PROTOTYPE( static void dump_phy, (re_t *rep) );
_PROTOTYPE( static int rl_handler, (re_t *rep) );
_PROTOTYPE( static void rl_handler, (re_t *rep) );
_PROTOTYPE( static void rl_watchdog_f, (timer_t *tp) );
/*
@ -1989,8 +1989,7 @@ static void do_hard_int(void)
/*===========================================================================*
* rl_handler *
*===========================================================================*/
static int rl_handler(rep)
re_t *rep;
static void rl_handler(re_t *rep)
{
int i, port, tx_head, tx_tail, link_up;
u16_t isr;
@ -2093,8 +2092,6 @@ re_t *rep;
if (isr)
printf("rl_handler: unhandled interrupt isr = 0x%04x\n", isr);
return 1;
}
/*===========================================================================*

View file

@ -328,10 +328,10 @@ PRIVATE int get_set_input(const message *m_ptr, int flag, int channel)
mixer_set(input_cmd, mask);
} else { /* Get input */
if (shift > 0) {
input.left = (((mask >> (shift+1)) & 1) == 1 ? ON : OFF);
input.right = (((mask >> shift) & 1) == 1 ? ON : OFF);
input.left = ((((mask >> (shift+1)) & 1) == 1) ? ON : OFF);
input.right = ((((mask >> shift) & 1) == 1) ? ON : OFF);
} else {
input.left = ((mask & 1) == 1 ? ON : OFF);
input.left = (((mask & 1) == 1) ? ON : OFF);
}
/* Copy back to user */
@ -384,10 +384,10 @@ PRIVATE int get_set_output(const message *m_ptr, int flag)
mixer_set(MIXER_OUTPUT_CTRL, mask);
} else { /* Get input */
if (shift > 0) {
output.left = (((mask >> (shift+1)) & 1) == 1 ? ON : OFF);
output.right = (((mask >> shift) & 1) == 1 ? ON : OFF);
output.left = ((((mask >> (shift+1)) & 1) == 1) ? ON : OFF);
output.right = ((((mask >> shift) & 1) == 1) ? ON : OFF);
} else {
output.left = ((mask & 1) == 1 ? ON : OFF);
output.left = (((mask & 1) == 1) ? ON : OFF);
}
/* Copy back to user */

View file

@ -440,7 +440,7 @@ struct port *pp;
v8= pci_attr_r8(devind, TI_CARD_CTRL);
if (v8 & TI_CCR_IFG)
{
printf("ti1225: got functional interrupt\n", v8);
printf("ti1225: got functional interrupt\n");
pci_attr_w8(devind, TI_CARD_CTRL, v8);
}

View file

@ -49,7 +49,7 @@ printf("ld_dr7(0x%x)\n",dr7);
case 3: ld_dr3(linaddr); break;
default: panic(__FILE__, "invalid breakpoint index", __LINE__);
}
printf("ld_dr%d(0x%x, 0x%x)\n",bp,linaddr);
printf("ld_dr%d(0x%x)\n",bp,linaddr);
/* set new flags */
dr7 |= dr7flags;

View file

@ -32,7 +32,7 @@ PUBLIC int do_clear(struct proc * caller, message * m_ptr)
rc = proc_addr(exit_p); /* clean up */
/* Don't clear if already cleared. */
if(isemptyp(rc)) return;
if(isemptyp(rc)) return OK;
/* Check the table with IRQ hooks to see if hooks should be released. */
for (i=0; i < NR_IRQ_HOOKS; i++) {

View file

@ -35,14 +35,12 @@ PUBLIC int do_update(struct proc * caller, message * m_ptr)
*/
endpoint_t src_e, dst_e;
int src_p, dst_p;
struct proc *src_rp, *dst_rp, *rp;
struct proc *src_rp, *dst_rp;
struct priv *src_privp, *dst_privp;
struct proc orig_src_proc;
struct proc orig_dst_proc;
struct priv orig_src_priv;
struct priv orig_dst_priv;
int r;
reg_t src_vbp, dst_vbp;
/* Lookup slots for source and destination process. */
src_e = m_ptr->SYS_UPD_SRC_ENDPT;

View file

@ -21,7 +21,6 @@ PUBLIC int do_vmctl(struct proc * caller, message * m_ptr)
int proc_nr;
endpoint_t ep = m_ptr->SVMCTL_WHO;
struct proc *p, *rp, *target;
int err;
if(ep == SELF) { ep = m_ptr->m_source; }

View file

@ -206,7 +206,7 @@ date_of(const register struct dsttype *dst, const struct tm *timep)
if (dst->ds_type != 'M') {
return dst->ds_date[0] -
(dst->ds_type == 'J'
((dst->ds_type == 'J')
&& leap
&& dst->ds_date[0] < 58);
}

View file

@ -385,7 +385,7 @@ message *mp;
/*===========================================================================*
* nop_prepare *
*===========================================================================*/
PUBLIC struct device *nop_prepare(device)
PUBLIC struct device *nop_prepare(int device)
{
/* Nothing to prepare for. */
return(NIL_DEV);

View file

@ -92,9 +92,6 @@ sef_init_info_t *info;
*===========================================================================*/
PRIVATE void sef_cb_signal_handler(int signo)
{
sigset_t set;
int r;
/* Only check for termination signal, ignore anything else. */
if (signo != SIGTERM) return;

View file

@ -61,8 +61,7 @@ PUBLIC struct boot_image image[NR_BOOT_PROCS];
PUBLIC void timing_dmp()
{
static struct util_timingdata timingdata[TIMING_CATEGORIES];
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
static int offsetlines = 0;
int r, c, x = 0;
if ((r = sys_getlocktimings(&timingdata[0])) != OK) {
printf("IS: warning: couldn't get copy of lock timings: %d\n", r);
@ -213,7 +212,7 @@ PRIVATE char *boot_flags_str(int flags)
*===========================================================================*/
PUBLIC void image_dmp()
{
int m, i,j,r;
int m, r;
struct boot_image *ip;
if ((r = sys_getimage(image)) != OK) {
@ -315,7 +314,7 @@ PUBLIC void privileges_dmp()
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
register struct priv *sp;
int r, i, n = 0;
int r, i;
/* First obtain a fresh copy of the current process and system table. */
if ((r = sys_getprivtab(priv)) != OK) {
@ -381,7 +380,7 @@ PUBLIC void proctab_dmp()
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, n = 0;
int r;
phys_clicks text, data, size;
/* First obtain a fresh copy of the current process table. */
@ -418,7 +417,7 @@ PUBLIC void procstack_dmp()
register struct proc *rp;
static struct proc *oldrp = BEG_PROC_ADDR;
int r, n = 0;
int r;
/* First obtain a fresh copy of the current process table. */
if ((r = sys_getproctab(proc)) != OK) {
@ -441,7 +440,7 @@ PUBLIC void memmap_dmp()
{
register struct proc *rp;
static struct proc *oldrp = proc;
int r, n = 0;
int r;
phys_clicks size;
/* First obtain a fresh copy of the current process table. */

View file

@ -37,7 +37,6 @@ PUBLIC int main(int argc, char **argv)
* sending the reply. The loop never terminates, unless a panic occurs.
*/
int result;
sigset_t sigset;
/* SEF local startup. */
env_setargs(argc, argv);
@ -97,7 +96,7 @@ PRIVATE void sef_local_startup()
/*===========================================================================*
* sef_cb_init_fresh *
*===========================================================================*/
PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
PRIVATE int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
{
/* Initialize the information server. */

View file

@ -28,7 +28,6 @@ PUBLIC struct buf *bp_to_pickup = buf; /* This is a pointer to the next node in
PUBLIC struct buf *get_block(block)
register block_t block; /* which block is wanted? */
{
int b;
register struct buf *bp, *free_bp;
free_bp = NIL_BUF;

View file

@ -41,7 +41,6 @@ void **buf;
int *vec_grants;
vir_bytes bytes;
{
int size;
int j;
iovec_t *v;
static iovec_t new_iovec[NR_IOREQS];
@ -170,10 +169,8 @@ int bytes; /* how many bytes to transfer */
int flags; /* special flags, like O_NONBLOCK */
{
/* Read or write from a device. The parameter 'dev' tells which one. */
struct dmap *dp;
int r, safe;
message m;
iovec_t *v;
cp_grant_id_t gid = GRANT_INVALID;
int vec_grants;
int op_used;

View file

@ -20,7 +20,6 @@ FORWARD _PROTOTYPE( int sef_cb_init_fresh, (int type, sef_init_info_t *info) );
*===========================================================================*/
PUBLIC int main(void) {
endpoint_t who_e, ind, error;
message m;
/* SEF local startup. */
sef_local_startup();

View file

@ -16,7 +16,7 @@ FORWARD _PROTOTYPE( int parse_path, (ino_t dir_ino, ino_t root_ino, int flags,
*===========================================================================*/
PUBLIC int fs_lookup() {
cp_grant_id_t grant;
int r, r1, len, flags;
int r, len, flags;
size_t offset;
ino_t dir_ino, root_ino;
struct dir_record *dir;
@ -87,8 +87,8 @@ PUBLIC int search_dir(ldir_ptr,string,numb)
ino_t *numb; /* pointer to new dir record */
{
struct dir_record *dir_tmp;
register struct buf *bp,*bp2;
int pos,len;
register struct buf *bp;
int pos;
char* comma_pos = NULL;
char tmp_string[NAME_MAX];
@ -293,8 +293,7 @@ struct dir_record **resp; /* resulting inode */
*/
register struct dir_record *rip = NULL;
int r, inumb;
dev_t mnt_dev;
int r;
ino_t numb;
/* If 'string' is empty, yield same inode straight away. */

View file

@ -80,8 +80,7 @@ PUBLIC int fs_bread(void)
int nrbytes;
u64_t position;
unsigned int off, cum_io;
mode_t mode_word;
int completed, r2 = OK;
int completed;
struct dir_record *dir;
r = OK;
@ -292,9 +291,7 @@ int *completed; /* number of bytes copied */
register struct buf *bp;
register int r = OK;
int n;
block_t b;
dev_t dev;
int file_unit, rel_block, offset;
*completed = 0;

View file

@ -25,8 +25,7 @@ PRIVATE int stat_dir_record(
/* Common code for stat and fstat system calls. */
struct stat statbuf;
mode_t mo;
int r, s;
int r;
struct tm ltime;
time_t time1;

View file

@ -54,7 +54,6 @@ void **buf;
int *vec_grants;
vir_bytes bytes;
{
int access = 0, size;
int j;
iovec_t *v;
static iovec_t *new_iovec;
@ -158,10 +157,8 @@ int bytes; /* how many bytes to transfer */
int flags; /* special flags, like O_NONBLOCK */
{
/* Read or write from a device. The parameter 'dev' tells which one. */
struct dmap *dp;
int r, safe;
message m;
iovec_t *v;
cp_grant_id_t gid = GRANT_INVALID;
int vec_grants;
int op_used;

View file

@ -128,7 +128,7 @@ int numb; /* inode number (ANSI: may not be unshort) */
/* Find the inode in the hash table. If it is not there, get a free inode
* load it from the disk if it's necessary and put on the hash list
*/
register struct inode *rip, *xp;
register struct inode *rip;
int hashi;
hashi = numb & INODE_HASH_MASK;

View file

@ -28,7 +28,6 @@ PUBLIC int main(int argc, char *argv[])
* sending the reply. The loop never terminates, unless a panic occurs.
*/
int error, ind;
message m;
/* SEF local startup. */
env_setargs(argc, argv);

View file

@ -23,7 +23,6 @@ PUBLIC int fs_readsuper()
* so that the VFS knows that it has to find the vnode on which this FS
* process' partition is mounted on.
*/
struct super_block *xp;
struct inode *root_ip;
cp_grant_id_t label_gid;
size_t label_len;
@ -152,7 +151,6 @@ PUBLIC int fs_mountpoint()
PUBLIC int fs_unmount()
{
/* Unmount a file system by device number. */
struct super_block *sp1;
int count;
struct inode *rip, *root_ip;

View file

@ -21,7 +21,7 @@ FORWARD _PROTOTYPE( struct inode *new_node, (struct inode *ldirp,
PUBLIC int fs_create()
{
phys_bytes len;
int r, b;
int r;
struct inode *ldirp;
struct inode *rip;
mode_t omode;

View file

@ -67,7 +67,6 @@ PUBLIC int fs_lookup()
if(user_path[len - 1] != '\0') return(EINVAL);
if(flags & PATH_GET_UCRED) { /* Do we have to copy uid/gid credentials? */
int i;
grant2 = fs_m_in.REQ_GRANT2;
cred_size = fs_m_in.REQ_UCRED_SIZE;

View file

@ -17,7 +17,6 @@ PUBLIC int fs_chmod()
/* Perform the chmod(name, mode) system call. */
register struct inode *rip;
register int r;
/* Temporarily open the file. */
if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE)
@ -78,7 +77,6 @@ PUBLIC int forbidden(register struct inode *rip, mode_t access_desired)
*/
register struct inode *old_rip = rip;
register struct super_block *sp;
register mode_t bits, perm_bits;
int r, shift;

View file

@ -22,7 +22,7 @@ PRIVATE char getdents_buf[GETDENTS_BUFSIZ];
PUBLIC int fs_readwrite(void)
{
int r, rw_flag, chunk, block_size, block_spec;
int partial_cnt, regular, nrbytes;
int regular, nrbytes;
cp_grant_id_t gid;
off_t position, f_size, bytes_left;
unsigned int off, cum_io;
@ -140,8 +140,7 @@ PUBLIC int fs_breadwrite(void)
int nrbytes;
u64_t position;
unsigned int off, cum_io;
mode_t mode_word;
int completed, r2 = OK;
int completed;
/* Pseudo inode for rw_chunk */
struct inode rip;

View file

@ -291,7 +291,6 @@ off_t position; /* file pointer */
zone_t z;
zone_t zone_size;
int scale, r;
struct super_block *sp;
/* Is another block available in the current zone? */
if ( (b = read_map(rip, position)) == NO_BLOCK) {

View file

@ -127,7 +127,7 @@ int numb; /* inode number (ANSI: may not be unshort) */
/* Find the inode in the hash table. If it is not there, get a free inode
* load it from the disk if it's necessary and put on the hash list
*/
register struct inode *rip, *xp;
register struct inode *rip;
int hashi;
hashi = numb & INODE_HASH_MASK;
@ -245,7 +245,6 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
/* Allocate a free inode on 'dev', and return a pointer to it. */
register struct inode *rip;
int major, minor;
bit_t b;
ino_t i_num;
@ -293,8 +292,6 @@ register struct inode *rip; /* the inode to be erased */
* inode is to be truncated.
*/
register int i;
rip->i_size = 0;
rip->i_update = ATIME | CTIME | MTIME; /* update all times later */
}

View file

@ -1,8 +1,5 @@
#include "fs.h"
#include <sys/stat.h>
#include <string.h>
#include <minix/com.h>
#include <minix/callnr.h>
#include "buf.h"
#include "inode.h"
#include <minix/vfsif.h>
@ -14,7 +11,6 @@ PUBLIC int fs_ftrunc(void)
{
struct inode *rip;
off_t start, end;
int r;
ino_t inumb;
inumb = fs_m_in.REQ_INODE_NR;
@ -43,7 +39,6 @@ off_t newsize; /* inode must become this size */
* O_APPEND mode, as this is different per fd and is checked when
* writing is done.
*/
int scale;
/* Pipes can shrink, so adjust size to make sure all zones are removed. */
if(newsize != 0) return(EINVAL); /* Only truncate pipes to 0. */

View file

@ -25,7 +25,6 @@ PUBLIC int main(int argc, char *argv[])
* sending the reply. The loop never terminates, unless a panic occurs.
*/
int error, ind;
message m;
/* SEF local startup. */
env_setargs(argc, argv);

View file

@ -12,7 +12,6 @@
PUBLIC int fs_readwrite(void)
{
int r, rw_flag;
block_t b;
struct buf *bp;
cp_grant_id_t gid;
off_t position, f_size;

View file

@ -40,7 +40,6 @@
PUBLIC int do_exec()
{
message m;
int r;
/* Forward call to FS */
m.m_type = PM_EXEC;

View file

@ -47,7 +47,7 @@ PUBLIC int do_fork()
register struct mproc *rmc; /* pointer to child */
pid_t new_pid;
static int next_child;
int i, n = 0, r, s;
int i, n = 0, s;
endpoint_t child_ep;
message m;
@ -133,7 +133,7 @@ PUBLIC int do_srv_fork()
int s;
pid_t new_pid;
static int next_child;
int i, n = 0, r;
int i, n = 0;
endpoint_t child_ep;
message m;
@ -243,7 +243,7 @@ int dump_core; /* flag indicating whether to dump core */
* become a zombie.
*/
register int proc_nr, proc_nr_e;
int parent_waiting, r;
int r;
pid_t procgrp;
struct mproc *p_mp;
clock_t user_time, sys_time;

View file

@ -22,7 +22,7 @@ PUBLIC int do_get()
*/
register struct mproc *rmp = mp;
int r, proc;
int r;
int ngroups;
switch(call_nr) {

View file

@ -366,7 +366,6 @@ PUBLIC int do_getepinfo()
PUBLIC int do_reboot()
{
message m;
int r;
/* Check permission to abort the system. */
if (mp->mp_effuid != SUPER_USER) return(EPERM);

View file

@ -213,9 +213,7 @@ PUBLIC int do_srv_kill()
/*===========================================================================*
* process_ksig *
*===========================================================================*/
PUBLIC int process_ksig(proc_nr_e, signo)
int proc_nr_e;
int signo;
PUBLIC int process_ksig(int proc_nr_e, int signo)
{
register struct mproc *rmp;
int proc_nr;
@ -223,14 +221,14 @@ int signo;
if(pm_isokendpt(proc_nr_e, &proc_nr) != OK || proc_nr < 0) {
printf("PM: process_ksig: %d?? not ok\n", proc_nr_e);
return;
return EDEADSRCDST; /* process is gone. */
}
rmp = &mproc[proc_nr];
if ((rmp->mp_flags & (IN_USE | EXITING)) != IN_USE) {
#if 0
printf("PM: process_ksig: %d?? exiting / not in use\n", proc_nr_e);
#endif
return;
return EDEADSRCDST; /* process is gone. */
}
proc_id = rmp->mp_pid;
mp = &mproc[0]; /* pretend signals are from PM */
@ -615,7 +613,7 @@ struct mproc *rmp; /* which process */
* so it can check for READs and WRITEs from pipes, ttys and the like.
*/
message m;
int r, slot;
int r;
/* If we're already waiting for a delayed call, don't do anything now. */
if (rmp->mp_flags & DELAY_CALL)

View file

@ -34,7 +34,6 @@ int srv_execve(int proc_e, char *exec, size_t exec_len, char **argv,
size_t string_off;
size_t n;
int ov;
message m;
int r;
/* Assumptions: size_t and char *, it's all the same thing. */
@ -161,7 +160,7 @@ static int do_exec(int proc_e, char *exec, size_t exec_len, char *progname,
proc_e, (vir_bytes) vsp, (phys_bytes)frame_len);
if (r != OK) {
printf("RS: stack_top is 0x%lx; tried to copy to 0x%lx in %d\n",
stack_top, vsp);
stack_top, vsp, proc_e);
printf("do_exec: copying out new stack failed: %d\n", r);
error= r;
goto fail;
@ -298,7 +297,6 @@ vir_bytes *pc; /* program entry point (initial PC) */
int *hdrlenp;
{
/* Read the header and extract the text, data, bss and total sizes from it. */
block_t b;
struct exec hdr; /* a.out header is read in here */
/* Read the header and check the magic number. The standard MINIX header
@ -327,8 +325,6 @@ int *hdrlenp;
* used here only. The symbol table is for the benefit of a debugger and
* is ignored here.
*/
int r;
if (exec_len < sizeof(hdr)) return(ENOEXEC);
memcpy(&hdr, exec, sizeof(hdr));
@ -413,7 +409,6 @@ phys_bytes seg_bytes; /* how much is to be transferred? */
*/
int r;
off_t n, o, b_off, seg_off;
if (off+seg_bytes > exec_len) return ENOEXEC;
r= sys_vircopy(SELF, D, (vir_bytes)exec+off, proc_e, seg, 0, seg_bytes);

View file

@ -479,8 +479,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
*===========================================================================*/
PRIVATE void sef_cb_signal_handler(int signo)
{
int exit_status;
/* Check for known signals, ignore anything else. */
switch(signo) {
case SIGCHLD:
@ -508,13 +506,15 @@ PRIVATE int sef_cb_signal_manager(endpoint_t target, int signo)
if(rs_verbose)
printf("RS: ignoring spurious signal %d for process %d\n",
signo, target);
return;
return OK; /* Since we're ignoring it, we have handled
* the signal without problem. All is OK.
*/
}
rp = rproc_ptr[target_p];
rpub = rp->r_pub;
/* Don't bother if a termination signal has already been processed. */
if( rp->r_flags & (RS_TERMINATED|RS_EXITING) == RS_TERMINATED ) {
if(rp->r_flags & RS_TERMINATED) {
return EDEADSRCDST; /* process is gone */
}

View file

@ -268,7 +268,6 @@ PUBLIC void end_update(int result)
* service has a period, a status request will be forced in the next period.
*/
struct rproc *old_rp, *new_rp, *exiting_rp, *surviving_rp;
message m;
old_rp = rupdate.rp;
new_rp = old_rp->r_new_rp;
@ -316,8 +315,6 @@ char *errstr;
int err;
{
/* Crash a system service and don't let it restart. */
struct rprocpub *rpub;
if(errstr && !shutting_down) {
printf("RS: %s (error %d)\n", errstr, err);
}
@ -383,12 +380,8 @@ struct rproc *rp;
/* Create the given system service. */
int child_proc_nr_e, child_proc_nr_n; /* child process slot */
pid_t child_pid; /* child's process id */
char *file_only;
int s, use_copy, slot_nr;
bitchunk_t *vm_mask;
message m;
int s, use_copy;
extern char **environ;
char * null_env = NULL;
struct rprocpub *rpub;
rpub = rp->r_pub;
@ -879,11 +872,63 @@ PUBLIC void terminate_service(struct rproc *rp)
}
}
/*===========================================================================*
* run_script *
*===========================================================================*/
PRIVATE int run_script(struct rproc *rp)
{
int r, endpoint;
pid_t pid;
char *reason;
char incarnation_str[20]; /* Enough for a counter? */
char *envp[1] = { NULL };
struct rprocpub *rpub;
rpub = rp->r_pub;
if (rp->r_flags & RS_REFRESHING)
reason= "restart";
else if (rp->r_flags & RS_NOPINGREPLY)
reason= "no-heartbeat";
else reason= "crashed";
sprintf(incarnation_str, "%d", rp->r_restarts);
if(rs_verbose) {
printf("RS: %s:\n", srv_to_string(rp));
printf("RS: calling script '%s'\n", rp->r_script);
printf("RS: reason: '%s'\n", reason);
printf("RS: incarnation: '%s'\n", incarnation_str);
}
pid= fork();
switch(pid)
{
case -1:
return kill_service(rp, "unable to fork script", errno);
case 0:
execle(rp->r_script, rp->r_script, rpub->label, reason,
incarnation_str, NULL, envp);
printf("RS: run_script: execl '%s' failed: %s\n",
rp->r_script, strerror(errno));
exit(1);
default:
/* Set the privilege structure for the child process. */
endpoint = getnprocnr(pid);
if ((r = sys_privctl(endpoint, SYS_PRIV_SET_USER, NULL))
!= OK) {
return kill_service(rp,"can't set script privileges",r);
}
/* Allow the script to run. */
if ((r = sys_privctl(endpoint, SYS_PRIV_ALLOW, NULL)) != OK) {
return kill_service(rp,"can't let the script run",r);
}
}
return OK;
}
/*===========================================================================*
* restart_service *
*===========================================================================*/
PUBLIC void restart_service(rp)
struct rproc *rp;
PUBLIC void restart_service(struct rproc *rp)
{
/* Restart service via a recovery script or directly. */
struct rproc *replica_rp;
@ -1092,13 +1137,7 @@ endpoint_t source;
{
/* Initialize a slot as requested by the client. */
struct rprocpub *rpub;
int slot_nr; /* local table entry */
int arg_count; /* number of arguments */
char *cmd_ptr; /* parse command string */
char *label; /* unique name of command */
enum dev_style dev_style; /* device style */
struct rproc *tmp_rp;
struct rprocpub *tmp_rpub;
int len; /* length of string */
int i;
int s;
@ -1534,59 +1573,6 @@ struct rproc *rp;
rproc_ptr[_ENDPOINT_P(rpub->endpoint)] = NULL;
}
/*===========================================================================*
* run_script *
*===========================================================================*/
PUBLIC int run_script(rp)
struct rproc *rp;
{
int r, endpoint;
pid_t pid;
char *reason;
char incarnation_str[20]; /* Enough for a counter? */
char *envp[1] = { NULL };
struct rprocpub *rpub;
rpub = rp->r_pub;
if (rp->r_flags & RS_REFRESHING)
reason= "restart";
else if (rp->r_flags & RS_NOPINGREPLY)
reason= "no-heartbeat";
else reason= "crashed";
sprintf(incarnation_str, "%d", rp->r_restarts);
if(rs_verbose) {
printf("RS: %s:\n", srv_to_string(rp));
printf("RS: calling script '%s'\n", rp->r_script);
printf("RS: reason: '%s'\n", reason);
printf("RS: incarnation: '%s'\n", incarnation_str);
}
pid= fork();
switch(pid)
{
case -1:
return kill_service(rp, "unable to fork script", errno);
case 0:
execle(rp->r_script, rp->r_script, rpub->label, reason,
incarnation_str, NULL, envp);
printf("RS: run_script: execl '%s' failed: %s\n",
rp->r_script, strerror(errno));
exit(1);
default:
/* Set the privilege structure for the child process. */
endpoint = getnprocnr(pid);
if ((r = sys_privctl(endpoint, SYS_PRIV_SET_USER, NULL))
!= OK) {
return kill_service(rp,"can't set script privileges",r);
}
/* Allow the script to run. */
if ((r = sys_privctl(endpoint, SYS_PRIV_ALLOW, NULL)) != OK) {
return kill_service(rp,"can't let the script run",r);
}
}
}
/*===========================================================================*
* get_next_label *
@ -1617,7 +1603,7 @@ char *caller_label;
if (len > RS_MAX_LABEL_LEN)
{
printf(
"rs:get_next_label: bad ipc list entry '.*s' for %s: too long\n",
"rs:get_next_label: bad ipc list entry '%.*s' for %s: too long\n",
len, p, caller_label);
continue;
}

View file

@ -75,7 +75,6 @@ _PROTOTYPE( struct rproc* lookup_slot_by_label, (char *label) );
_PROTOTYPE( struct rproc* lookup_slot_by_pid, (pid_t pid) );
_PROTOTYPE( int alloc_slot, (struct rproc **rpp) );
_PROTOTYPE( void free_slot, (struct rproc *rp) );
_PROTOTYPE( int run_script, (struct rproc *rp) );
_PROTOTYPE( char *get_next_label, (char *ptr, char *label, char *caller_label));
_PROTOTYPE( void add_forward_ipc, (struct rproc *rp, struct priv *privp) );
_PROTOTYPE( void add_backward_ipc, (struct rproc *rp, struct priv *privp) );

View file

@ -827,7 +827,6 @@ PUBLIC void dev_up(int maj)
struct vmnt *vmp;
struct fproc *rfp;
struct vnode *vp;
message m;
/* Open a device once for every filp that's opened on it,
* and once for every filesystem mounted from it.

View file

@ -30,7 +30,6 @@ PUBLIC int do_link()
{
/* Perform the link(name1, name2) system call. */
int r = OK;
endpoint_t linked_fs_e, link_lastdir_fs_e;
struct vnode *vp, *vp_d;
/* See if 'name1' (file to be linked to) exists. */
@ -72,7 +71,6 @@ PUBLIC int do_unlink()
* is almost the same. They differ only in some condition testing. Unlink()
* may be used by the superuser to do dangerous things; rmdir() may not.
*/
register struct fproc *rfp;
struct vnode *vldirp, *vp;
int r;
@ -126,7 +124,6 @@ PUBLIC int do_rename()
{
/* Perform the rename(name1, name2) system call. */
int r = OK, r1;
size_t len;
struct vnode *old_dirp, *new_dirp, *vp;
char old_name[PATH_MAX+1];
@ -218,7 +215,6 @@ PUBLIC int do_truncate()
PUBLIC int do_ftruncate()
{
/* As with do_truncate(), truncate_vnode() does the actual work. */
int r;
struct filp *rfilp;
if ((off_t) m_in.flength < 0) return(EINVAL);
@ -255,9 +251,8 @@ off_t newsize;
PUBLIC int do_slink()
{
/* Perform the symlink(name1, name2) system call. */
int r, linklen;
int r;
struct vnode *vp;
char string[NAME_MAX]; /* last component of the new dir's path name */
if(m_in.name1_length <= 1) return(ENOENT);
if(m_in.name1_length >= SYMLINK_MAX) return(ENAMETOOLONG);

View file

@ -151,8 +151,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? */
@ -533,7 +531,7 @@ int ngroups;
gid_t *groups;
{
struct fproc *rfp;
int slot, i;
int slot;
okendpt(proc_e, &slot);
rfp = &fproc[slot];
@ -623,7 +621,7 @@ PUBLIC int pm_dumpcore(proc_e, seg_ptr)
int proc_e;
struct mem_map *seg_ptr;
{
int r, proc_s;
int proc_s;
/* Terminate the process */
okendpt(proc_e, &proc_s);

View file

@ -128,7 +128,6 @@ PRIVATE int mount_fs(endpoint_t fs_e)
struct fproc *tfp;
struct dmap *dp;
dev_t dev;
message m;
struct vnode *root_node, *vp = NULL, *bspec;
struct vmnt *vmp;
char *label;
@ -405,11 +404,10 @@ PUBLIC int unmount(dev, label)
Dev_t dev; /* block-special device */
char *label; /* buffer to retrieve label, or NULL */
{
struct vnode *vp, *vi;
struct vnode *vp;
struct vmnt *vmp_i = NULL, *vmp = NULL;
struct dmap *dp;
int count, r;
int fs_e;
/* Find vmnt that is to be unmounted */
for(vmp_i = &vmnt[0]; vmp_i < &vmnt[NR_MNTS]; ++vmp_i) {
@ -496,7 +494,6 @@ int allow_mountpt;
* and the path is the root node of a mounted file system, return that device
* number. In all other cases, return NO_DEV and an error code in 'err_code'.
*/
int r;
dev_t dev;
struct vnode *vp;
@ -522,7 +519,7 @@ int allow_mountpt;
/*===========================================================================*
* is_nonedev *
*===========================================================================*/
PRIVATE int is_nonedev(dev)
PRIVATE int is_nonedev(int dev)
{
/* Return whether the given device is a "none" pseudo device.
*/

View file

@ -247,7 +247,6 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits)
struct vnode *dirp, *vp;
int r, flags;
struct node_details res;
struct vnode *rest;
/* When O_CREAT and O_EXCL flags are set, the path may not be named by a
* symbolic link. */

View file

@ -111,7 +111,6 @@ PUBLIC struct vnode *last_dir(void)
* and parse the path up to the penultimate component.
*/
int r;
size_t len;
char *cp;
char dir_entry[PATH_MAX+1];

View file

@ -46,7 +46,6 @@ PUBLIC int do_pipe()
struct filp *fil_ptr0, *fil_ptr1;
int fil_des[2]; /* reply goes here */
struct vnode *vp;
struct vmnt *vmp;
struct node_details res;
/* See if a free vnode is available */
@ -581,7 +580,7 @@ int proc_nr_e;
*===========================================================================*/
PUBLIC int select_request_pipe(struct filp *f, int *ops, int block)
{
int orig_ops, r = 0, err, canwrite;
int orig_ops, r = 0, err;
orig_ops = *ops;
if ((*ops & (SEL_RD|SEL_ERR))) {
if ((err = pipe_check(f->filp_vno, READING, 0,

View file

@ -75,8 +75,6 @@ PUBLIC int do_chmod()
PUBLIC int do_chown()
{
/* Perform the chmod(name, mode) and fchmod(fd, mode) system calls. */
int inode_nr;
int fs_e;
struct filp *flp;
struct vnode *vp;
int r;
@ -173,11 +171,10 @@ PUBLIC int forbidden(struct vnode *vp, mode_t access_desired)
* if it is forbidden, EACCES is returned.
*/
register struct super_block *sp;
register mode_t bits, perm_bits;
uid_t uid;
gid_t gid;
int r, shift, type;
int r, shift;
if (vp->v_uid == (uid_t) -1 || vp->v_gid == (gid_t) -1) return(EACCES);

View file

@ -43,14 +43,11 @@ int rw_flag; /* READING or WRITING */
/* Perform read(fd, buffer, nbytes) or write(fd, buffer, nbytes) call. */
register struct filp *f;
register struct vnode *vp;
off_t bytes_left;
u64_t position, res_pos, new_pos;
unsigned int off, cum_io, cum_io_incr, res_cum_io;
int op, oflags, r, chunk, block_spec, char_spec;
unsigned int cum_io, cum_io_incr, res_cum_io;
int op, oflags, r, block_spec, char_spec;
int regular;
mode_t mode_word;
phys_bytes p;
struct dmap *dp;
/* If the file descriptor is valid, get the vnode, size and mode. */
if (m_in.nbytes < 0) return(EINVAL);
@ -154,7 +151,6 @@ PUBLIC int do_getdents()
/* Perform the getdents(fd, buf, size) system call. */
int r;
u64_t new_pos;
cp_grant_id_t gid;
register struct filp *rfilp;
/* Is the file descriptor valid? */
@ -191,10 +187,10 @@ struct filp *f;
char *buf;
size_t req_size;
{
int r, oflags, partial_pipe = 0, r2;
size_t size, cum_io, cum_io_incr, cum_io_incr2;
int r, oflags, partial_pipe = 0;
size_t size, cum_io, cum_io_incr;
struct vnode *vp;
u64_t position, new_pos, new_pos2;
u64_t position, new_pos;
oflags = f->filp_flags;
vp = f->filp_vno;

View file

@ -12,9 +12,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#include <minix/vfsif.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/keymap.h>
#include <minix/const.h>
#include <minix/endpoint.h>
#include <minix/u64.h>
@ -1027,7 +1025,6 @@ PRIVATE int fs_sendrec_f(char *file, int line, endpoint_t fs_e, message *reqm)
*/
int r, old_driver_e, new_driver_e;
message origm, m;
struct vmnt *vmp;
if(fs_e <= 0 || fs_e == NONE)
panic("talking to bogus endpoint: %d", fs_e);

View file

@ -714,7 +714,7 @@ PUBLIC void select_unsuspend_by_endpt(endpoint_t proc_e)
*===========================================================================*/
PUBLIC void select_reply1()
{
int i, s, minor, status;
int i, minor, status;
endpoint_t driver_e;
dev_t dev;
struct filp *fp;

View file

@ -75,7 +75,6 @@ int len; /* length of the directory name string */
{
/* Do the actual work for chdir() and chroot(). */
struct vnode *vp;
int r;
/* Try to open the directory */
if (fetch_name(name_ptr, len, M3) != OK) return(err_code);

View file

@ -22,7 +22,6 @@ PUBLIC int do_utime()
/* Perform the utime(name, timep) system call. */
register int len;
int r;
uid_t uid;
time_t actime, modtime;
struct vnode *vp;

View file

@ -92,7 +92,7 @@ PUBLIC int isokendpt_f(char *file, int line, int endpoint, int *proc, int fatal)
endpoint_t ke;
*proc = _ENDPOINT_P(endpoint);
if(endpoint == NONE) {
printf("vfs:%s: endpoint is NONE\n", file, line, endpoint);
printf("vfs:%s:%d: endpoint is NONE\n", file, line);
failed = 1;
} else if(*proc < 0 || *proc >= NR_PROCS) {
printf("vfs:%s:%d: proc (%d) from endpoint (%d) out of range\n",