diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-12-12 01:40:36 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-12-12 01:40:36 +0000 |
commit | 50190b1e429b32cb3e90478a5dee680d5519402f (patch) | |
tree | 56657cf92282e7ddc7537d975acf8a1333ddee4c | |
parent | c278a7ac174695e307f0e3ec4e19219165348ed7 (diff) |
Eliminate (most) double decrements of remaining space in the pretty
print buffer. Use consistant idiom to increment pointer to data
being consumed, instead of hiding some increments.
-rw-r--r-- | sbin/dhclient/options.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/sbin/dhclient/options.c b/sbin/dhclient/options.c index eb5777eea73..b9c7b021024 100644 --- a/sbin/dhclient/options.c +++ b/sbin/dhclient/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.57 2013/12/06 23:40:48 krw Exp $ */ +/* $OpenBSD: options.c,v 1.58 2013/12/12 01:40:35 krw Exp $ */ /* DHCP options parsing and reassembly. */ @@ -361,7 +361,6 @@ pretty_print_option(unsigned int code, struct option_data *option, opcount = strlcpy(op, inet_ntoa(foo), opleft); if (opcount >= opleft) goto toobig; - opleft -= opcount; dp += 4; break; case 'l': @@ -369,7 +368,6 @@ pretty_print_option(unsigned int code, struct option_data *option, (long)getLong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; dp += 4; break; case 'L': @@ -377,7 +375,6 @@ pretty_print_option(unsigned int code, struct option_data *option, (unsigned long)getULong(dp)); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; dp += 4; break; case 's': @@ -385,7 +382,6 @@ pretty_print_option(unsigned int code, struct option_data *option, getShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; dp += 2; break; case 'S': @@ -393,34 +389,33 @@ pretty_print_option(unsigned int code, struct option_data *option, getUShort(dp)); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; dp += 2; break; case 'b': opcount = snprintf(op, opleft, "%d", - *(char *)dp++); + *(char *)dp); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; + dp++; break; case 'B': - opcount = snprintf(op, opleft, "%d", *dp++); + opcount = snprintf(op, opleft, "%d", *dp); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; + dp++; break; case 'x': - opcount = snprintf(op, opleft, "%x", *dp++); + opcount = snprintf(op, opleft, "%x", *dp); if (opcount >= opleft || opcount == -1) goto toobig; - opleft -= opcount; + dp++; break; case 'f': opcount = strlcpy(op, - *dp++ ? "true" : "false", opleft); + *dp ? "true" : "false", opleft); if (opcount >= opleft) goto toobig; - opleft -= opcount; + dp++; break; default: warning("Unexpected format code %c", fmtbuf[j]); |