Skip to content

Commit e654eb2

Browse files
sunshinecogitster
authored andcommitted
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 <sunshine@sunshineco.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 282616c commit e654eb2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

utf8.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ char *reencode_string_len(const char *in, int insz,
2828
const char *in_encoding,
2929
int *outsz);
3030
#else
31-
#define reencode_string_len(a,b,c,d,e) NULL
31+
static inline char *reencode_string_len(const char *a, int b,
32+
const char *c, const char *d, int *e)
33+
{ if (e) *e = 0; return NULL; }
3234
#endif
3335

3436
static inline char *reencode_string(const char *in,

0 commit comments

Comments
 (0)