Lock consistently. Other cleanups. [jmk] --rw-rw-r-- M 960117 glenda sys 11218 Dec 8 06:55 sys/src/9/ip/arp.c /n/sourcesdump/2005/1208/plan9/sys/src/9/ip/arp.c:598,620 - /n/sourcesdump/2005/1209/plan9/sys/src/9/ip/arp.c:598,612 else break; } + if(a == nil) + goto dodrops; - /* need to unlock arp, else will deadlock when icmpns - * wants to lock arp later. - */ - - qunlock(arp); - if(a == nil) - goto dodrops; // return 0; - + qunlock(arp); /* for icmpns */ if((sflag = ipv6anylocal(ifc, ipsrc)) != SRC_UNSPEC) icmpns(f, ipsrc, sflag, a->ip, TARG_MULTI, ifc->mac); runlock(ifc); - - /* grab lock on arp again */ - qlock(arp); /* put to the end of re-transmit chain */ [jmk] --rw-rw-r-- M 960117 jmk sys 29166 Dec 8 06:52 sys/src/9/pc/etherdp83820.c /n/sourcesdump/2005/1208/plan9/sys/src/9/pc/etherdp83820.c:1056,1061 - /n/sourcesdump/2005/1209/plan9/sys/src/9/pc/etherdp83820.c:1056,1063 delay(1); atc93c46r(ctlr, 0); + if(ctlr->eeprom == nil) + return -1; sum = 0; for(i = 0; i < 0x0E; i++){ r = atc93c46r(ctlr, i); [jmk] --rw-rw-r-- M 960117 glenda sys 1425 Dec 8 06:55 sys/src/9/port/alarm.c /n/sourcesdump/2005/1208/plan9/sys/src/9/port/alarm.c:4,12 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/alarm.c:4,11 #include "dat.h" #include "fns.h" - Alarms alarms; - Rendez alarmr; - Talarm talarm; + static Alarms alarms; + static Rendez alarmr; void alarmkproc(void*) [jmk] --rw-rw-r-- M 960117 glenda sys 22558 Dec 8 06:55 sys/src/9/port/portdat.h /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:40,46 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:40,45 typedef struct Sargs Sargs; typedef struct Schedq Schedq; typedef struct Segment Segment; - typedef struct Talarm Talarm; typedef struct Timer Timer; typedef struct Timers Timers; typedef struct Uart Uart; /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:89,100 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:88,93 int writer; /* number of writers */ }; - struct Talarm - { - Lock; - Proc *list; - }; - struct Alarms { QLock; /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:363,369 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:356,361 Page *pages[PTEPERTAB]; /* Page map for this chunk of pte */ Page **first; /* First used entry */ Page **last; /* Last used entry */ - Pte *next; /* Free list */ }; /* Segment types */ /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:416,422 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:408,414 Pte **map; int mapsize; Pte *ssegmap[SSEGMAPSIZE]; - ulong mark; /* portcountrefs */ + ulong mark; /* portcountrefs */ }; enum /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:599,606 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:591,596 PriRoot = 13, /* base priority for root processes */ }; - typedef uvlong Ticks; - struct Schedq { Lock; /n/sourcesdump/2005/1208/plan9/sys/src/9/port/portdat.h:768,774 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/portdat.h:758,763 extern char* statename[]; extern Image swapimage; extern char* sysname; - extern Talarm talarm; extern uint qiomaxatomic; enum [jmk] --rw-rw-r-- M 960117 glenda sys 22178 Dec 8 06:55 sys/src/9/port/sysfile.c /n/sourcesdump/2005/1208/plan9/sys/src/9/port/sysfile.c:582,588 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/sysfile.c:582,588 l = devtab[nc->type]->stat(nc, buf, nbuf); l = dirsetname(name, nname, buf, l, nbuf); if(l == BIT16SZ) - goto Norewrite; + error("dirsetname"); poperror(); /* [jmk] --rw-rw-r-- M 960117 glenda sys 15146 Dec 8 06:56 sys/src/9/port/sysproc.c /n/sourcesdump/2005/1208/plan9/sys/src/9/port/sysproc.c:568,575 - /n/sourcesdump/2005/1209/plan9/sys/src/9/port/sysproc.c:568,575 buf[ERRMAX-1] = 0; status = buf; } + poperror(); } - poperror(); } pexit(status, 1); Code cleanups. [jmk] --rw-rw-r-- M 960117 glenda sys 662 Dec 8 09:33 sys/src/ape/lib/ap/stdio/fread.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/fread.c:7,13 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/fread.c:7,13 #define BIGN (BUFSIZ/2) size_t fread(void *p, size_t recl, size_t nrec, FILE *f){ - char *s, *es; + char *s; int n, d, c; s=(char *)p; Always good to return values. [jmk] --rw-rw-r-- M 960117 glenda sys 679 Dec 8 09:33 sys/src/ape/lib/ap/stdio/setvbuf.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/setvbuf.c:34,39 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/setvbuf.c:34,39 } int _IO_setvbuf(FILE *f){ if(f==stderr || (f==stdout && isatty(1))) - setvbuf(f, (char *)0, _IOLBF, BUFSIZ); - else setvbuf(f, (char *)0, _IOFBF, BUFSIZ); + return setvbuf(f, (char *)0, _IOLBF, BUFSIZ); + return setvbuf(f, (char *)0, _IOFBF, BUFSIZ); } Unused variables. [jmk] --rw-rw-r-- M 960117 glenda sys 295 Dec 8 09:33 sys/src/ape/lib/ap/stdio/sprintf.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/sprintf.c:5,11 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/sprintf.c:5,10 int sprintf(char *buf, const char *fmt, ...){ int n; va_list args; - char *v; FILE *f=_IO_sopenw(); if(f==NULL) return 0; [jmk] --rw-rw-r-- M 960117 glenda sys 267 Dec 8 09:33 sys/src/ape/lib/ap/stdio/vsnprintf.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/vsnprintf.c:4,10 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/vsnprintf.c:4,9 #include "iolib.h" int vsnprintf(char *buf, size_t nbuf, const char *fmt, va_list args){ int n; - char *v; FILE *f=_IO_sopenw(); if(f==NULL) return 0; [jmk] --rw-rw-r-- M 960117 glenda sys 254 Dec 8 09:33 sys/src/ape/lib/ap/stdio/vsprintf.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/vsprintf.c:4,15 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/vsprintf.c:4,14 #include "iolib.h" int vsprintf(char *buf, const char *fmt, va_list args){ int n; - char *v; FILE *f=_IO_sopenw(); if(f==NULL) return 0; setvbuf(f, buf, _IOFBF, 100000); n=vfprintf(f, fmt, args); - v=_IO_sclose(f); + _IO_sclose(f); return n; } Unset variables. [jmk] --rw-rw-r-- M 960117 glenda sys 263 Dec 8 12:29 sys/src/ape/lib/ap/stdio/fgets.c /n/sourcesdump/2005/1208/plan9/sys/src/ape/lib/ap/stdio/fgets.c:3,9 - /n/sourcesdump/2005/1209/plan9/sys/src/ape/lib/ap/stdio/fgets.c:3,9 */ #include "iolib.h" char *fgets(char *as, int n, FILE *f){ - int c; + int c=0; char *s=as; while(n>1 && (c=getc(f))!=EOF){ *s++=c;