From: Roy Marples Date: Thu, 27 Mar 2014 23:00:32 +0000 (+0000) Subject: Fix some 64-bit fallout X-Git-Tag: v6.4.0~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76bb4d039dd70286dbf7327ab1af2650c49ed772;p=thirdparty%2Fdhcpcd.git Fix some 64-bit fallout --- diff --git a/control.c b/control.c index 76c2c6b1..4b4758a1 100644 --- 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 diff --git a/dhcp-common.c b/dhcp-common.c index 25c984af..a09984a1 100644 --- a/dhcp-common.c +++ b/dhcp-common.c @@ -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 a565629f..1beb944c 100644 --- 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 94529629..aa8391df 100644 --- 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; diff --git a/if-linux.c b/if-linux.c index 6e564e60..a6a80948 100644 --- a/if-linux.c +++ b/if-linux.c @@ -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)) diff --git a/if-options.c b/if-options.c index 759d1e8c..3ff8cdcb 100644 --- a/if-options.c +++ b/if-options.c @@ -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; diff --git a/ipv6nd.c b/ipv6nd.c index 74b0b71e..5fbc0a55 100644 --- 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); } } diff --git a/platform-linux.c b/platform-linux.c index 0be32065..2181cbd0 100644 --- a/platform-linux.c +++ b/platform-linux.c @@ -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;