From: Olivier Matz Date: Fri, 24 Dec 2010 12:54:22 +0000 (+0100) Subject: cmdline (merge-intel): fix compilation with icc X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=36dfbc791ada2e788180a474299d25641f56903f;p=libcmdline.git cmdline (merge-intel): fix compilation with icc Signed-off-by: Olivier Matz --- diff --git a/src/lib/cmdline.c b/src/lib/cmdline.c index 6b2421c..4d2eaea 100644 --- a/src/lib/cmdline.c +++ b/src/lib/cmdline.c @@ -79,7 +79,7 @@ /**********************/ -void +static void cmdline_valid_buffer(struct rdline *rdl, const char *buf, __attribute__((unused)) unsigned int size) { @@ -94,7 +94,7 @@ cmdline_valid_buffer(struct rdline *rdl, const char *buf, cmdline_printf(cl, "Bad arguments\n"); } -int +static int cmdline_complete_buffer(struct rdline *rdl, const char *buf, char *dstbuf, unsigned int dstsize, int *state) diff --git a/src/lib/cmdline_parse.c b/src/lib/cmdline_parse.c index d5f5988..334b3e3 100644 --- a/src/lib/cmdline_parse.c +++ b/src/lib/cmdline_parse.c @@ -153,9 +153,16 @@ match_inst(cmdline_parse_inst_t *inst, const char *buf, unsigned int nb_match_to if ( isendofline(*buf) || iscomment(*buf) ) break; - n = token_hdr.ops->parse(token_p, buf, (result_buf ? result_buf+token_hdr.offset : NULL)); - if ( n < 0 ) + if (result_buf) + n = token_hdr.ops->parse(token_p, buf, + (char *)result_buf + + token_hdr.offset); + else + n = token_hdr.ops->parse(token_p, buf, NULL); + + if (n < 0) break; + debug_printf("TK parsed (len=%d)\n", n); i++; buf += n; diff --git a/src/lib/cmdline_parse_etheraddr.c b/src/lib/cmdline_parse_etheraddr.c index d718081..2cefc62 100644 --- a/src/lib/cmdline_parse_etheraddr.c +++ b/src/lib/cmdline_parse_etheraddr.c @@ -98,12 +98,12 @@ my_ether_aton(const char *a) if (i != ETHER_ADDR_LEN) return NULL; - ether_addr.ea_oct[0] = o0; - ether_addr.ea_oct[1] = o1; - ether_addr.ea_oct[2] = o2; - ether_addr.ea_oct[3] = o3; - ether_addr.ea_oct[4] = o4; - ether_addr.ea_oct[5] = o5; + ether_addr.ea_oct[0] = (uint8_t)o0; + ether_addr.ea_oct[1] = (uint8_t)o1; + ether_addr.ea_oct[2] = (uint8_t)o2; + ether_addr.ea_oct[3] = (uint8_t)o3; + ether_addr.ea_oct[4] = (uint8_t)o4; + ether_addr.ea_oct[5] = (uint8_t)o5; return (struct ether_addr *)ðer_addr; } diff --git a/src/lib/cmdline_parse_ipaddr.c b/src/lib/cmdline_parse_ipaddr.c index 2ffbf0c..276d644 100644 --- a/src/lib/cmdline_parse_ipaddr.c +++ b/src/lib/cmdline_parse_ipaddr.c @@ -108,8 +108,8 @@ struct cmdline_token_ops cmdline_token_ipaddr_ops = { * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4(const char *src, u_char *dst); -static int inet_pton6(const char *src, u_char *dst); +static int inet_pton4(const char *src, unsigned char *dst); +static int inet_pton6(const char *src, unsigned char *dst); /* int * inet_pton(af, src, dst) @@ -148,11 +148,11 @@ my_inet_pton(int af, const char *src, void *dst) * Paul Vixie, 1996. */ static int -inet_pton4(const char *src, u_char *dst) +inet_pton4(const char *src, unsigned char *dst) { static const char digits[] = "0123456789"; int saw_digit, octets, ch; - u_char tmp[INADDRSZ], *tp; + unsigned char tmp[INADDRSZ], *tp; saw_digit = 0; octets = 0; @@ -161,7 +161,7 @@ inet_pton4(const char *src, u_char *dst) const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (pch - digits); + unsigned int new = *tp * 10 + (pch - digits); if (new > 255) return (0); @@ -170,7 +170,7 @@ inet_pton4(const char *src, u_char *dst) return (0); saw_digit = 1; } - *tp = new; + *tp = (unsigned char)new; } else if (ch == '.' && saw_digit) { if (octets == 4) return (0); @@ -200,14 +200,14 @@ inet_pton4(const char *src, u_char *dst) * Paul Vixie, 1996. */ static int -inet_pton6(const char *src, u_char *dst) +inet_pton6(const char *src, unsigned char *dst) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit, count_xdigit; - u_int val; + unsigned int val; memset((tp = tmp), '\0', IN6ADDRSZ); endp = tp + IN6ADDRSZ; @@ -247,8 +247,8 @@ inet_pton6(const char *src, u_char *dst) } if (tp + sizeof(int16_t) > endp) return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; + *tp++ = (unsigned char) ((val >> 8) & 0xff); + *tp++ = (unsigned char) (val & 0xff); saw_xdigit = 0; count_xdigit = 0; val = 0; @@ -266,8 +266,8 @@ inet_pton6(const char *src, u_char *dst) if (saw_xdigit) { if (tp + sizeof(int16_t) > endp) return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; + *tp++ = (unsigned char) ((val >> 8) & 0xff); + *tp++ = (unsigned char) (val & 0xff); } if (colonp != NULL) { /* diff --git a/src/lib/cmdline_parse_num.c b/src/lib/cmdline_parse_num.c index 8a394ac..6c1ec72 100644 --- a/src/lib/cmdline_parse_num.c +++ b/src/lib/cmdline_parse_num.c @@ -97,7 +97,7 @@ enum num_parse_state_t { DEC_NEG_OK, DEC_POS_OK, FLOAT_POS_OK, - FLOAT_NEG_OK, + FLOAT_NEG_OK }; /* Keep it sync with enum in .h */ @@ -110,7 +110,7 @@ static const char * num_help[] = { }; static inline int -add_to_res(unsigned int c, unsigned int *res, unsigned int base) +add_to_res(unsigned int c, uint32_t *res, unsigned int base) { /* overflow */ if ( (UINT32_MAX - c) / base < *res ) { @@ -404,17 +404,17 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res) case DEC_NEG_OK: if ( nd.type == INT8 && res1 <= INT8_MAX + 1 ) { if (res) - *(int8_t *)res = - (int8_t) res1; + *(int8_t *)res = (int8_t) (-res1); return (buf-srcbuf); } else if ( nd.type == INT16 && res1 <= (uint16_t)INT16_MAX + 1 ) { if (res) - *(int16_t *)res = - (int16_t) res1; + *(int16_t *)res = (int16_t) (-res1); return (buf-srcbuf); } else if ( nd.type == INT32 && res1 <= (uint32_t)INT32_MAX + 1 ) { if (res) - *(int32_t *)res = - (int32_t) res1; + *(int32_t *)res = (int32_t) (-res1); return (buf-srcbuf); } #ifndef CMDLINE_NO_FLOAT @@ -460,7 +460,6 @@ cmdline_parse_num(cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res) debug_printf("error\n"); return -1; } - return -1; } diff --git a/src/lib/cmdline_parse_num.h b/src/lib/cmdline_parse_num.h index 45db43a..7e47a65 100644 --- a/src/lib/cmdline_parse_num.h +++ b/src/lib/cmdline_parse_num.h @@ -70,9 +70,9 @@ enum cmdline_numtype { UINT32, INT8, INT16, - INT32, + INT32 #ifndef NO_PARSE_FLOAT - FLOAT, + ,FLOAT #endif }; diff --git a/src/lib/cmdline_rdline.c b/src/lib/cmdline_rdline.c index 86d3a9c..6c2d9dd 100644 --- a/src/lib/cmdline_rdline.c +++ b/src/lib/cmdline_rdline.c @@ -621,9 +621,9 @@ rdline_miniprintf(struct rdline *rdl, const char * buf, unsigned int val) } /* val is never more than 255 */ while (div) { - c = val / div; + c = (char)(val / div); if (c || started) { - rdl->write_char(rdl, c+'0'); + rdl->write_char(rdl, (char)(c+'0')); started = 1; } val %= div; diff --git a/src/lib/cmdline_rdline.h b/src/lib/cmdline_rdline.h index fac36ae..702a0ab 100644 --- a/src/lib/cmdline_rdline.h +++ b/src/lib/cmdline_rdline.h @@ -119,7 +119,7 @@ enum rdline_status { RDLINE_INIT, - RDLINE_RUNNING, + RDLINE_RUNNING }; struct rdline; diff --git a/src/lib/cmdline_socket.c b/src/lib/cmdline_socket.c index bba3847..abff38b 100644 --- a/src/lib/cmdline_socket.c +++ b/src/lib/cmdline_socket.c @@ -76,6 +76,7 @@ #include "cmdline_parse.h" #include "cmdline_rdline.h" +#include "cmdline_socket.h" #include "cmdline.h" /**********************/ diff --git a/src/lib/cmdline_vt100.h b/src/lib/cmdline_vt100.h index 14ca5f8..612d12b 100644 --- a/src/lib/cmdline_vt100.h +++ b/src/lib/cmdline_vt100.h @@ -115,7 +115,7 @@ extern const char *cmdline_vt100_commands[]; enum cmdline_vt100_parser_state { CMDLINE_VT100_INIT, CMDLINE_VT100_ESCAPE, - CMDLINE_VT100_ESCAPE_CSI, + CMDLINE_VT100_ESCAPE_CSI }; #define CMDLINE_VT100_BUF_SIZE 8