From c9df03d1a997074d237a153bb2b2637aa1232aa1 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 26 Mar 2007 17:15:23 +0000 Subject: [PATCH] Remove warnings: "comparision between signed and unsigned" and "converting from 'unsigned long' to 'u8_t': possible loss of data" --- src/core/dhcp.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/dhcp.c b/src/core/dhcp.c index 2dabd4f5..5d3b6b86 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -1035,7 +1035,7 @@ static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state) */ static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len) { - LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN); + LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U + option_len <= DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = option_type; dhcp->msg_out->options[dhcp->options_out_len++] = option_len; } @@ -1050,17 +1050,17 @@ static void dhcp_option_byte(struct dhcp *dhcp, u8_t value) } static void dhcp_option_short(struct dhcp *dhcp, u16_t value) { - LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0xff00U) >> 8; - dhcp->msg_out->options[dhcp->options_out_len++] = value & 0x00ffU; + LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2U <= DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff00U) >> 8); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t) (value & 0x00ffU); } static void dhcp_option_long(struct dhcp *dhcp, u32_t value) { - LWIP_ASSERT("dhcp_option_long: dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN); - dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0xff000000UL) >> 24; - dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x00ff0000UL) >> 16; - dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x0000ff00UL) >> 8; - dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x000000ffUL); + LWIP_ASSERT("dhcp_option_long: dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 4U <= DHCP_OPTIONS_LEN); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0xff000000UL) >> 24); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x00ff0000UL) >> 16); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x0000ff00UL) >> 8); + dhcp->msg_out->options[dhcp->options_out_len++] = (u8_t)((value & 0x000000ffUL)); } /** @@ -1296,7 +1296,8 @@ static err_t dhcp_create_request(struct netif *netif) dhcp->msg_out->cookie = htonl(0x63825363UL); dhcp->options_out_len = 0; /* fill options field with an incrementing array (for debugging purposes) */ - for (i = 0; i < DHCP_OPTIONS_LEN; i++) dhcp->msg_out->options[i] = i; + for (i = 0; i < DHCP_OPTIONS_LEN; i++) + dhcp->msg_out->options[i] = (u8_t)i; /* for debugging only, no matter if truncated */ return ERR_OK; }