use snprint, and other minor corrections Reference: /n/atom/patch/applied/nixsnprint2 Date: Thu Mar 27 06:56:02 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/port/devaudio.c Thu Mar 27 06:55:18 2014 +++ /sys/src/nix/port/devaudio.c Thu Mar 27 06:55:19 2014 @@ -193,7 +193,7 @@ adev = ac->adev; fn = nil; - switch((ulong)c->qid.path){ + switch((uint)c->qid.path){ case Qdir: audiodir[Qaudio].length = adev->buffered ? adev->buffered(adev) : 0; return devdirread(c, a, n, audiodir, nelem(audiodir), devgen); @@ -215,7 +215,7 @@ qunlock(ac); nexterror(); } - switch((ulong)c->qid.path){ + switch((uint)c->qid.path){ case Qaudiostat: case Qvolume: /* generate the text on first read */ @@ -252,7 +252,7 @@ adev = ac->adev; fn = nil; - switch((ulong)c->qid.path){ + switch((uint)c->qid.path){ case Qaudio: fn = adev->write; break; @@ -271,7 +271,7 @@ qunlock(ac); nexterror(); } - switch((ulong)c->qid.path){ + switch((uint)c->qid.path){ case Qaudioctl: case Qvolume: if(n >= sizeof(ac->buf)) @@ -341,7 +341,7 @@ ac = c->aux; adev = ac->adev; - if((ulong)c->qid.path == Qaudio) + if(c->qid.path == Qaudio) audiodir[Qaudio].length = adev->buffered ? adev->buffered(adev) : 0; return devstat(c, dp, n, audiodir, nelem(audiodir), devgen); } @@ -427,10 +427,9 @@ for(i = 0; vol[i].name != 0; i++){ if(vol[i].cap && (vol[i].cap & caps) == 0) continue; - if(cistrcmp(vol[i].name, tok[0])) + if(cistrcmp(vol[i].name, tok[0]) != 0) continue; - - if((ntok>2) && (!cistrcmp(tok[1], "out") || !cistrcmp(tok[1], "in"))) + if(ntok > 2 && (cistrcmp(tok[1], "out") == 0 || !cistrcmp(tok[1], "in") == 0)) memmove(tok+1, tok+2, --ntok); v[0] = 0; --- /sys/src/nix/port/devcap.c Thu Mar 27 06:55:21 2014 +++ /sys/src/nix/port/devcap.c Thu Mar 27 06:55:21 2014 @@ -104,20 +104,6 @@ return c; } -/* -static char* -hashstr(uchar *hash) -{ - static char buf[2*Hashlen+1]; - int i; - - for(i = 0; i < Hashlen; i++) - sprint(buf+2*i, "%2.2ux", hash[i]); - buf[2*Hashlen] = 0; - return buf; -} - */ - static Caphash* remcap(uchar *hash) { --- /sys/src/nix/port/allocb.c Thu Mar 27 06:55:23 2014 +++ /sys/src/nix/port/allocb.c Thu Mar 27 06:55:24 2014 @@ -75,10 +75,8 @@ if(ialloc.bytes > sys->ialloc){ if((m1++%10000)==0){ - if(mp++ > 1000){ - active.exiting = 1; + if(mp++ > 1000) exit(0); - } iprint("iallocb: limited %lud/%llud\n", ialloc.bytes, sys->ialloc); } @@ -87,10 +85,8 @@ if((b = _allocb(size)) == nil){ if((m2++%10000)==0){ - if(mp++ > 1000){ - active.exiting = 1; + if(mp++ > 1000) exit(0); - } iprint("iallocb: no memory %lud/%llud\n", ialloc.bytes, sys->ialloc); } --- /sys/src/nix/port/devdup.c Thu Mar 27 06:55:25 2014 +++ /sys/src/nix/port/devdup.c Thu Mar 27 06:55:26 2014 @@ -29,10 +29,10 @@ return 0; if(s & 1){ p = 0400; - sprint(up->genbuf, "%dctl", s/2); + snprint(up->genbuf, sizeof up->genbuf, "%dctl", s/2); }else{ p = perm[f->mode&3]; - sprint(up->genbuf, "%d", s/2); + snprint(up->genbuf, sizeof up->genbuf, "%d", s/2); } mkqid(&q, s+1, 0, QTFILE); devdir(c, q, up->genbuf, 0, eve, p, dp); --- /sys/src/nix/port/devenv.c Thu Mar 27 06:55:28 2014 +++ /sys/src/nix/port/devenv.c Thu Mar 27 06:55:29 2014 @@ -43,13 +43,13 @@ eg = envgrp(c); rlock(eg); - e = 0; + e = nil; if(name) e = envlookup(eg, name, -1); else if(s < eg->nent) e = eg->ent[s]; - if(e == 0) { + if(e == nil) { runlock(eg); return -1; } @@ -114,7 +114,7 @@ else rlock(eg); e = envlookup(eg, nil, c->qid.path); - if(e == 0) { + if(e == nil) { if(trunc) wunlock(eg); else @@ -124,7 +124,7 @@ if(trunc && e->value) { e->qid.vers++; free(e->value); - e->value = 0; + e->value = nil; e->len = 0; } if(trunc) @@ -200,7 +200,7 @@ eg = envgrp(c); wlock(eg); - e = 0; + e = nil; for(i=0; inent; i++){ if(eg->ent[i]->qid.path == c->qid.path){ e = eg->ent[i]; @@ -211,7 +211,7 @@ } } wunlock(eg); - if(e == 0) + if(e == nil) error(Enonexist); free(e->name); if(e->value) @@ -244,7 +244,7 @@ eg = envgrp(c); rlock(eg); e = envlookup(eg, nil, c->qid.path); - if(e == 0) { + if(e == nil) { runlock(eg); error(Enonexist); } @@ -279,7 +279,7 @@ eg = envgrp(c); wlock(eg); e = envlookup(eg, nil, c->qid.path); - if(e == 0) { + if(e == nil) { wunlock(eg); error(Enonexist); } --- /sys/src/nix/port/devproc.c Thu Mar 27 06:55:32 2014 +++ /sys/src/nix/port/devproc.c Thu Mar 27 06:55:34 2014 @@ -610,7 +610,7 @@ { char buf[32]; - return sprint(buf, "%lud", c->qid.vers); + return snprint(buf, sizeof buf, "%lud", c->qid.vers); } int