From: Roy Marples Date: Thu, 7 Aug 2014 09:54:19 +0000 (+0000) Subject: Optimize auth_len a little. X-Git-Tag: v6.4.4~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=01eee106e4961c6ec532de934615d8bed383df5d;p=thirdparty%2Fdhcpcd.git Optimize auth_len a little. --- diff --git a/dhcp.c b/dhcp.c index 6f6d1226..1225dc35 100644 --- a/dhcp.c +++ b/dhcp.c @@ -989,10 +989,11 @@ make_message(struct dhcp_message **message, auth_len = (size_t)dhcp_auth_encode(&ifo->auth, state->auth.token, NULL, 0, 4, type, NULL, 0); - if ((ssize_t)auth_len == -1) + if ((ssize_t)auth_len == -1) { syslog(LOG_ERR, "%s: dhcp_auth_encode: %m", iface->name); - else if (auth_len > 0) { + auth_len = 0; + } else if (auth_len != 0) { len = (size_t)((p + auth_len) - m); if (auth_len > 255 || len > sizeof(*dhcp)) goto toobig; @@ -1014,7 +1015,7 @@ make_message(struct dhcp_message **message, #endif len = (size_t)(p - m); - if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len > 0) + if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0) dhcp_auth_encode(&ifo->auth, state->auth.token, m, len, 4, type, auth, auth_len); diff --git a/dhcp6.c b/dhcp6.c index 9dcdce34..6199dc73 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -649,7 +649,7 @@ dhcp6_makemessage(struct interface *ifp) syslog(LOG_ERR, "%s: dhcp_auth_encode: %m", ifp->name); auth_len = 0; - } else if (auth_len> 0) + } else if (auth_len != 0) len += sizeof(*o) + auth_len; } else auth_len = 0; /* appease GCC */ @@ -853,7 +853,7 @@ dhcp6_makemessage(struct interface *ifp) } /* This has to be the last option */ - if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len > 0) { + if (ifo->auth.options & DHCPCD_AUTH_SEND && auth_len != 0) { o = D6_NEXT_OPTION(o); o->code = htons(D6_OPTION_AUTH); o->len = htons(auth_len);