Commit e654eb29 authored by Eric Sunshine's avatar Eric Sunshine Committed by Junio C Hamano

utf8: NO_ICONV: silence uninitialized variable warning

The last argument of reencode_string_len() is an 'int *' which is
assigned the length of the converted string. When NO_ICONV is defined,
however, reencode_string_len() is stubbed out by the macro:

    #define reencode_string_len(a,b,c,d,e) NULL

which never assigns a value to the final argument. When called like
this:

    int n;
    char *s = reencode_string_len(..., &n);
    if (s)
        do_something(s, n);

some compilers complain that 'n' is used uninitialized within the
conditional.
Signed-off-by: Eric Sunshine's avatarEric Sunshine <sunshine@sunshineco.com>
Reviewed-by: default avatarJeff King <peff@peff.net>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent 282616c7
......@@ -28,7 +28,9 @@ char *reencode_string_len(const char *in, int insz,
const char *in_encoding,
int *outsz);
#else
#define reencode_string_len(a,b,c,d,e) NULL
static inline char *reencode_string_len(const char *a, int b,
const char *c, const char *d, int *e)
{ if (e) *e = 0; return NULL; }
#endif
static inline char *reencode_string(const char *in,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment