X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Funformat.c;h=da7622a90a823893bac0dbfbaa16cabfd73d61bd;hb=1c17e2ecac42e001ce905418463edcb26fe58b01;hp=7c636ccce89723a74f0e5ca0b4f358d0f0c4723c;hpb=32e1c010b0c34fd0984f7fc45fae648a182025c5;p=vpp.git diff --git a/src/vppinfra/unformat.c b/src/vppinfra/unformat.c index 7c636ccce89..da7622a90a8 100644 --- a/src/vppinfra/unformat.c +++ b/src/vppinfra/unformat.c @@ -167,7 +167,7 @@ di (unformat_input_t * i) #endif /* Parse delimited vector string. If string starts with { then string - is delimited by balenced parenthesis. Other string is delimited by + is delimited by balanced parenthesis. Other string is delimited by white space. {} were chosen since they are special to the shell. */ static uword unformat_string (unformat_input_t * input, @@ -306,6 +306,11 @@ unformat_hex_string (unformat_input_t * input, va_list * va) vec_free (s); return 0; } + /* Make sure something was processed. */ + else if (s == 0) + { + return 0; + } *hexstring_return = s; return 1; @@ -330,7 +335,7 @@ unformat_token (unformat_input_t * input, va_list * va) if (!token_chars) token_chars = (u8 *) "a-zA-Z0-9_"; - memset (map, 0, sizeof (map)); + clib_memset (map, 0, sizeof (map)); for (s = token_chars; *s;) { /* Parse range. */ @@ -396,7 +401,7 @@ unformat_line (unformat_input_t * i, va_list * va) } *result = line; - return 1; + return vec_len (line); } /* Parse a line ending with \n and return it as an unformat_input_t. */ @@ -405,7 +410,8 @@ unformat_line_input (unformat_input_t * i, va_list * va) { unformat_input_t *result = va_arg (*va, unformat_input_t *); u8 *line; - unformat_user (i, unformat_line, &line); + if (!unformat_user (i, unformat_line, &line)) + return 0; unformat_init_vector (result, line); return 1; } @@ -570,9 +576,9 @@ unformat_float (unformat_input_t * input, va_list * va) uword signs[2], sign_index = 0; uword n_input = 0; - memset (values, 0, sizeof (values)); - memset (n_digits, 0, sizeof (n_digits)); - memset (signs, 0, sizeof (signs)); + clib_memset (values, 0, sizeof (values)); + clib_memset (n_digits, 0, sizeof (n_digits)); + clib_memset (signs, 0, sizeof (signs)); while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT) { @@ -1031,7 +1037,7 @@ unformat_init_vector (unformat_input_t * input, u8 * vector_string) #ifdef CLIB_UNIX static uword -unix_file_fill_buffer (unformat_input_t * input) +clib_file_fill_buffer (unformat_input_t * input) { int fd = pointer_to_uword (input->fill_buffer_arg); uword l, n; @@ -1049,9 +1055,9 @@ unix_file_fill_buffer (unformat_input_t * input) } void -unformat_init_unix_file (unformat_input_t * input, int file_descriptor) +unformat_init_clib_file (unformat_input_t * input, int file_descriptor) { - unformat_init (input, unix_file_fill_buffer, + unformat_init (input, clib_file_fill_buffer, uword_to_pointer (file_descriptor, void *)); }