From: David van Moolenbroek Date: Fri, 5 Aug 2016 10:17:31 +0000 (+0000) Subject: commands: fix various small issues X-Git-Url: http://zhaoyanbai.com/repos/CHANGES?a=commitdiff_plain;h=ab712d19236a3841c2f32c52798f854f9f9cd880;p=minix.git commands: fix various small issues Reported by dcb314. Recommendations adopted as is. This closes #137, closes #138, closes #139, and hopefully I got that right this time. Change-Id: I79774f4c398495dba19dec43fbc3f79afd186843 --- diff --git a/minix/commands/cawf/regexp.c b/minix/commands/cawf/regexp.c index 72abc839c..eaeccee27 100644 --- a/minix/commands/cawf/regexp.c +++ b/minix/commands/cawf/regexp.c @@ -231,8 +231,10 @@ regexp *regcomp(char *exp) { regnpar = 1; regcode = r->program; regc(MAGIC); - if (reg(0, &flags) == NULL) + if (reg(0, &flags) == NULL) { + free(r); return(NULL); + } /* Dig out information for optimizations. */ r->regstart = '\0'; /* Worst-case defaults. */ diff --git a/minix/commands/slip/slip.c b/minix/commands/slip/slip.c index efc44bc91..7ed31f943 100644 --- a/minix/commands/slip/slip.c +++ b/minix/commands/slip/slip.c @@ -278,7 +278,7 @@ static int fprintf(int fd, const char *format, ...) while (*fp != 0) { if (*fp == '%' && memchr("sdu", fp[1], 3) != nil) { if (fp > fp0) { - if ((r= write(fd, fp0, (fp - fp0))) < 0) return -1; + if ((r= write(fd, fp0, (fp - fp0))) < 0) goto error; len+= r; } fp++; @@ -287,7 +287,7 @@ static int fprintf(int fd, const char *format, ...) if (*fp == 's') { char *s= va_arg(ap, char *); - if ((r= write(fd, s, strlen(s))) < 0) return -1; + if ((r= write(fd, s, strlen(s))) < 0) goto error; len+= r; } else { int d; @@ -308,16 +308,19 @@ static int fprintf(int fd, const char *format, ...) do *--p= '0' + (u % 10); while ((u /= 10) > 0); if (d < 0) *--p= '-'; - if ((r= write(fd, p, (a + sizeof(a)) - p)) < 0) return -1; + if ((r= write(fd, p, (a + sizeof(a)) - p)) < 0) goto error; len+= r; } } fp++; } if (fp > fp0) { - if ((r= write(fd, fp0, (fp - fp0))) < 0) return -1; + if ((r= write(fd, fp0, (fp - fp0))) < 0) goto error; len+= r; } va_end(ap); return len; +error: + va_end(ap); + return -1; } diff --git a/minix/commands/zmodem/sz.c b/minix/commands/zmodem/sz.c index 3691e59af..cc256d6f1 100644 --- a/minix/commands/zmodem/sz.c +++ b/minix/commands/zmodem/sz.c @@ -726,7 +726,8 @@ int wctx(long flen) fflush(stdout); ++attempts; } - while ((firstch=(readline(Rxtimeout)) != ACK) && attempts < RETRYMAX); + while ((firstch = readline(Rxtimeout)) != ACK && + attempts < RETRYMAX); if (attempts == RETRYMAX) { zperr("No ACK on EOT"); return ERROR;