Amazingly picky bug fixes from Valgrind.

This commit is contained in:
rsc 2004-03-05 05:53:11 +00:00
parent 230d62c475
commit 15680d56a6
9 changed files with 20 additions and 9 deletions

View file

@ -298,7 +298,7 @@ tgetc(void *a, uint n)
Rune*
skipbl(Rune *r, int n, int *np)
{
while(n>0 && *r==' ' || *r=='\t' || *r=='\n'){
while(n>0 && (*r==' ' || *r=='\t' || *r=='\n')){
--n;
r++;
}
@ -309,7 +309,7 @@ skipbl(Rune *r, int n, int *np)
Rune*
findbl(Rune *r, int n, int *np)
{
while(n>0 && *r!=' ' && *r!='\t' && *r!='\n'){
while(n>0 && (*r!=' ' && *r!='\t' && *r!='\n')){
--n;
r++;
}

View file

@ -29,14 +29,18 @@ void
threadmain(int argc, char *argv[])
{
char buf[512];
int fd;
int fd, dofork;
progname = "plumber";
dofork = 1;
ARGBEGIN{
case 'd':
debug = 1;
break;
case 'f':
dofork = 0;
break;
case 'p':
plumbfile = ARGF();
break;
@ -66,6 +70,7 @@ threadmain(int argc, char *argv[])
* Start all processes and threads from other proc
* so we (main pid) can return to user.
*/
if(dofork)
switch(fork()){
case -1:
sysfatal("fork: %r");

View file

@ -741,6 +741,7 @@ morerules(uchar *text, int done)
;
while((rs=readruleset()) != nil){
rules = erealloc(rules, (n+2)*sizeof(Ruleset*));
fprint(2, "initialize rules %d %d\n", n, n+1);
rules[n++] = rs;
rules[n] = nil;
}

View file

@ -28,7 +28,7 @@ cachechars(Font *f, char **ss, Rune **rr, ushort *cp, int max, int *wp, char **s
}
wid = 0;
*subfontname = 0;
for(i=0; (*sp || *rp) && i<max; sp+=w, rp+=rw){
for(i=0; i<max && (*sp || *rp); sp+=w, rp+=rw){
if(ss){
r = *(uchar*)sp;
if(r < Runeself)

View file

@ -25,7 +25,7 @@ _stringnwidth(Font *f, char *s, Rune *r, int len)
}else
rptr = &r;
twid = 0;
while((*s || *r) && len){
while(len && (*s || *r)){
max = Max;
if(len < max)
max = len;

View file

@ -115,9 +115,12 @@ static
void
chopbox(Frame *f, Frbox *b, int n) /* drop first n chars; no allocation done */
{
char *p;
if(b->nrune<0 || b->nrune<n)
drawerror(f->display, "chopbox");
strcpy((char*)b->ptr, (char*)runeindex(b->ptr, n));
p = (char*)runeindex(b->ptr, n);
memmove((char*)b->ptr, p, strlen(p)+1);
b->nrune -= n;
b->wid = stringwidth(f->font, (char *)b->ptr);
}

View file

@ -28,7 +28,8 @@ fprint(2, "n %d msize %d\n", n, msize);
tx.offset = offset;
tx.count = n;
fsrpc(fid->fs, &tx, &rx, &freep);
if(fsrpc(fid->fs, &tx, &rx, &freep) < 0)
return -1;
if(rx.type == Rerror){
werrstr("%s", rx.ename);
free(freep);

View file

@ -24,7 +24,8 @@ _fspwrite(Fid *fid, void *buf, long n, vlong offset)
tx.count = n;
tx.data = buf;
fsrpc(fid->fs, &tx, &rx, &freep);
if(fsrpc(fid->fs, &tx, &rx, &freep) < 0)
return -1;
if(rx.type == Rerror){
werrstr("%s", rx.ename);
free(freep);

View file

@ -45,7 +45,7 @@ main(int argc, char **argv)
signal(SIGTERM, _threaddie);
signal(SIGCHLD, _nop);
signal(SIGINFO, _threadstatus);
// signal(SIGINFO, _threadstatus);
// rfork(RFREND);
//_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;