diff options
Diffstat (limited to 'lib/util/util.c')
-rw-r--r-- | lib/util/util.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index 2a809d3ccb..fd0e6b8d79 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -579,18 +579,18 @@ _PUBLIC_ _PURE_ size_t count_chars(const char *s, char c) **/ _PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t strhex_len) { - size_t i; + size_t i = 0; size_t num_chars = 0; uint8_t lonybble, hinybble; const char *hexchars = "0123456789ABCDEF"; char *p1 = NULL, *p2 = NULL; - for (i = 0; i < strhex_len && strhex[i] != 0; i++) { - if (strncasecmp(hexchars, "0x", 2) == 0) { - i++; /* skip two chars */ - continue; - } + /* skip leading 0x prefix */ + if (strncasecmp(strhex, "0x", 2) == 0) { + i += 2; /* skip two chars */ + } + for (; i < strhex_len && strhex[i] != 0; i++) { if (!(p1 = strchr(hexchars, toupper((unsigned char)strhex[i])))) break; @@ -804,8 +804,8 @@ static bool next_token_internal_talloc(TALLOC_CTX *ctx, const char *sep, bool ltrim) { - char *s; - char *saved_s; + const char *s; + const char *saved_s; char *pbuf; bool quoted; size_t len=1; @@ -815,7 +815,7 @@ static bool next_token_internal_talloc(TALLOC_CTX *ctx, return(false); } - s = (char *)*ptr; + s = *ptr; /* default to simple separators */ if (!sep) { |