]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: standard: The parse_binary() returns the length consumed and his documentation...
authorThierry FOURNIER <tfournier@exceliance.fr>
Tue, 21 Jan 2014 10:36:14 +0000 (11:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 21 Jan 2014 21:14:44 +0000 (22:14 +0100)
Actually the values returned by this function is never used. All the
callers just check if the resultat is non-zero. Before this patch, the
function returns the length of the produced content. This value is not
useful because is returned twice: the first time in the return value and
the second time in the <binstrlen> argument. Now the function returns
the number of bytes consumed from <source>.

src/standard.c

index 3ed1e2aed26edee3a68e43461a9692d4bfef937d..adaba75ba8060e36f4771ea89d833c75733a5981 100644 (file)
@@ -1360,7 +1360,7 @@ const char *parse_size_err(const char *text, unsigned *ret) {
  * Parse binary string written in hexadecimal (source) and store the decoded
  * result into binstr and set binstrlen to the lengh of binstr. Memory for
  * binstr is allocated by the function. In case of error, returns 0 with an
- * error message in err.
+ * error message in err. In succes case, it returns the consumed length.
  */
 int parse_binary(const char *source, char **binstr, int *binstrlen, char **err)
 {
@@ -1403,7 +1403,7 @@ int parse_binary(const char *source, char **binstr, int *binstrlen, char **err)
                        goto bad_input;
                (*binstr)[j++] =  (hex2i(p[i-2]) << 4) + hex2i(p[i-1]);
        }
-       return len;
+       return len << 1;
 
 bad_input:
        memprintf(err, "an hex digit is expected (found '%c')", p[i-1]);