]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix some 64-bit fallout
authorRoy Marples <roy@marples.name>
Thu, 27 Mar 2014 23:00:32 +0000 (23:00 +0000)
committerRoy Marples <roy@marples.name>
Thu, 27 Mar 2014 23:00:32 +0000 (23:00 +0000)
control.c
dhcp-common.c
dhcp.c
dhcp6.c
if-linux.c
if-options.c
ipv6nd.c
platform-linux.c

index 76c2c6b108b1cfb0269d893a2660da1af1392ef9..4b4758a1e8bea2aa08e46b5b4795001566cd9a4c 100644 (file)
--- a/control.c
+++ b/control.c
@@ -152,7 +152,7 @@ make_sock(struct dhcpcd_ctx *ctx, struct sockaddr_un *sun, const char *ifname)
        snprintf(sun->sun_path, sizeof(sun->sun_path), CONTROLSOCKET,
            ifname ? "-" : "", ifname ? ifname : "");
        strlcpy(ctx->control_sock, sun->sun_path, sizeof(ctx->control_sock));
-       return SUN_LEN(sun);
+       return (socklen_t)SUN_LEN(sun);
 }
 
 int
index 25c984af69b8792945f34e01abfaa618478fa28e..a09984a17b903f0f1671ef39909dae3ea28b621d 100644 (file)
@@ -587,12 +587,12 @@ size_t
 dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
     const char *ifname, struct dhcp_opt *opt,
     const uint8_t *(*dgetopt)(struct dhcpcd_ctx *,
-    unsigned int *, unsigned int *, unsigned int *,
-    const uint8_t *, unsigned int, struct dhcp_opt **),
+    size_t *, unsigned int *, size_t *,
+    const uint8_t *, size_t, struct dhcp_opt **),
     const uint8_t *od, size_t ol)
 {
-       size_t e, i, n;
-       unsigned int eoc, eos, eol;
+       size_t e, i, n, eos, eol;
+       unsigned int eoc;
        const uint8_t *eod;
        int ov;
        struct dhcp_opt *eopt, *oopt;
diff --git a/dhcp.c b/dhcp.c
index a565629f424d0006f53756552cb713d78eee0a27..1beb944c3f66a6d261910d090eb987abd281a915 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -698,11 +698,11 @@ make_message(struct dhcp_message **message,
        }
 
        dhcp->op = DHCP_BOOTREQUEST;
-       dhcp->hwtype = iface->family;
+       dhcp->hwtype = (uint8_t)iface->family;
        switch (iface->family) {
        case ARPHRD_ETHER:
        case ARPHRD_IEEE802:
-               dhcp->hwlen = iface->hwlen;
+               dhcp->hwlen = (uint8_t)iface->hwlen;
                memcpy(&dhcp->chaddr, &iface->hwaddr, iface->hwlen);
                break;
        }
@@ -848,9 +848,9 @@ make_message(struct dhcp_message **message,
                        *p++ = 0; /* from server for PTR RR */
                        *p++ = 0; /* from server for A RR if S=1 */
                        if (hostname) {
-                               ul = encode_rfc1035(hostname, p);
-                               *lp += ul;
-                               p += ul;
+                               i = encode_rfc1035(hostname, p);
+                               *lp += i;
+                               p += i;
                        }
                } else if (ifo->options & DHCPCD_HOSTNAME && hostname) {
                        *p++ = DHO_HOSTNAME;
diff --git a/dhcp6.c b/dhcp6.c
index 945296297bb032a1bfc52d059f3218472d328e15..aa8391df10d32d990adc3ccb92d8f057f961b415 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -681,7 +681,7 @@ static void dhcp6_delete_delegates(struct interface *ifp)
 }
 
 
-static int
+static ssize_t
 dhcp6_update_auth(struct interface *ifp, struct dhcp6_message *m, size_t len)
 {
        struct dhcp6_state *state;
index 6e564e60b32fd3477eaa9b8084d52a20afc36d65..a6a8094863509be1184c3ed316c2dd5eed7e410f 100644 (file)
@@ -403,7 +403,8 @@ link_addr(struct dhcpcd_ctx *ctx, struct nlmsghdr *nlm)
        return 1;
 }
 
-static short l2addr_len(unsigned short if_type)
+static uint8_t
+l2addr_len(unsigned short if_type)
 {
 
        switch (if_type) {
@@ -415,9 +416,10 @@ static short l2addr_len(unsigned short if_type)
                return 8;
        case ARPHRD_INFINIBAND:
                return 20;
-       default:
-               return -1;
        }
+
+       /* Impossible */
+       return 0;
 }
 
 static int
@@ -517,7 +519,7 @@ link_netlink(struct dhcpcd_ctx *ctx, struct nlmsghdr *nlm)
 
        /* Re-read hardware address and friends */
        if (!(ifi->ifi_flags & IFF_UP) && hwaddr) {
-               short l;
+               uint8_t l;
 
                l = l2addr_len(ifi->ifi_type);
                if (hwaddr->rta_len == RTA_LENGTH(l))
index 759d1e8c4a6a4811c42766fc1a3728490293aa88..3ff8cdcb060c60bbbcfd84ccbc1b5cfa274ddcc6 100644 (file)
@@ -390,9 +390,9 @@ parse_iaid1(uint8_t *iaid, const char *arg, size_t len, int n)
        l = strtoul(arg, &np, 0);
        if (l <= (unsigned long)UINT32_MAX && errno == 0 && *np == '\0') {
                if (n)
-                       u32 = htonl(l);
+                       u32 = htonl((uint32_t)l);
                else
-                       u32 = l;
+                       u32 = (uint32_t)l;
                memcpy(iaid, &u32, sizeof(u32));
                return 0;
        }
@@ -609,7 +609,7 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo,
     int opt, const char *arg, struct dhcp_opt **ldop, struct dhcp_opt **edop)
 {
        int i, l, t;
-       unsigned int u;
+       unsigned long u;
        char *p = NULL, *fp, *np, **nconf;
        ssize_t s;
        struct in_addr addr, addr2;
@@ -1550,7 +1550,7 @@ err_sla:
                        ndop->encopts_len = 0;
                } else
                        free_dhcp_opt_embenc(ndop);
-               ndop->option = u; /* could have been 0 */
+               ndop->option = (uint32_t)u; /* could have been 0 */
                ndop->type = t;
                ndop->len = (size_t)l;
                ndop->var = np;
@@ -1598,7 +1598,7 @@ err_sla:
                        return -1;
                }
                ifo->vivco = vivco;
-               ifo->vivco_en = u;
+               ifo->vivco_en = (uint32_t)u;
                vivco = &ifo->vivco[ifo->vivco_len++];
                vivco->len = dl;
                vivco->data = (uint8_t *)np;
index 74b0b71ebb8d22cc5ca108eb46af92a2244e2405..5fbc0a556884a7b538c56343b0af0534d4d21240 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -978,7 +978,7 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
                        continue;
                if (env) {
                        snprintf(buffer, sizeof(buffer),
-                           "ra%d_from", i);
+                           "ra%zu_from", i);
                        setvar(&env, prefix, buffer, rap->sfrom);
                }
                l++;
@@ -1056,7 +1056,7 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp)
                        }
                        if (env) {
                                snprintf(buffer, sizeof(buffer),
-                                   "ra%d_%s", i, optn);
+                                   "ra%zu_%s", i, optn);
                                setvar(&env, prefix, buffer, rao->option);
                        }
                }
index 0be32065febc3e75f9ecb9903e4cdb6fc25dc864..2181cbd096aa39fef35ce967db8f880d20583e22 100644 (file)
@@ -165,8 +165,8 @@ check_ipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own)
                ifname = "all";
 
        snprintf(path, sizeof(path), "%s/%s/autoconf", prefix, ifname);
-       i = check_proc_int(path);
-       if (i != 1) {
+       ra = check_proc_int(path);
+       if (ra != 1) {
                syslog(LOG_WARNING, "%s: IPv6 kernel autoconf disabled",
                    ifname);
                return -1;