]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Optimize auth_len a little.
authorRoy Marples <roy@marples.name>
Thu, 7 Aug 2014 09:54:19 +0000 (09:54 +0000)
committerRoy Marples <roy@marples.name>
Thu, 7 Aug 2014 09:54:19 +0000 (09:54 +0000)
dhcp.c
dhcp6.c

diff --git a/dhcp.c b/dhcp.c
index 6f6d12262549a3d75e970baa4f56e9bff2376a79..1225dc358b5ba2213c2a5fb889d9c52b6de8388e 100644 (file)
--- 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 9dcdce342a979226c821742e89603abe90bbea3f..6199dc733e1b52133879e1212d8437b496a71262 100644 (file)
--- 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);