From: David Levine Date: Sun, 7 Sep 2014 14:56:21 +0000 (-0500) Subject: On some platforms, -D_FORTIFY_SOURCE=2 warns about ignoring the X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b2cc954248dff07883ef749c1c2851dd07e0d400?ds=sidebyside;hp=cf1f3bdaa19bf1b5e1e99ee1e8a28d61a524395e On some platforms, -D_FORTIFY_SOURCE=2 warns about ignoring the return value from mbtowc() even when it is called to reset the shift state. So wrap that in an if statement with a null body. --- diff --git a/sbr/charstring.c b/sbr/charstring.c index cc2e907e..d007e7b5 100644 --- a/sbr/charstring.c +++ b/sbr/charstring.c @@ -161,7 +161,7 @@ charstring_last_char_len (const charstring_t s) { const char *sp = charstring_buffer (s); size_t remaining = charstring_bytes (s); - (void) mbtowc (NULL, NULL, 0); /* reset shift state */ + if (mbtowc (NULL, NULL, 0)) {} /* reset shift state */ while (*sp && remaining > 0) { wchar_t wide_char; diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 47a5fe87..cc5c192d 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -144,7 +144,7 @@ cptrimmed(charstring_t dest, char *str, int wid, char fill, size_t max) { if ((sp = str)) { #ifdef MULTIBYTE_SUPPORT - mbtowc(NULL, NULL, 0); /* reset shift state */ + if (mbtowc(NULL, NULL, 0)) {} /* reset shift state */ #endif end = strlen(str); while (*sp && remaining > 0 && end > 0) { @@ -252,7 +252,7 @@ cpstripped (charstring_t dest, size_t max, char *str) len = strlen(str); #ifdef MULTIBYTE_SUPPORT - mbtowc(NULL, NULL, 0); /* Reset shift state */ + if (mbtowc(NULL, NULL, 0)) {} /* Reset shift state */ #endif /* MULTIBYTE_SUPPORT */ /* diff --git a/test/getcwidth.c b/test/getcwidth.c index 2c4755b1..c1717e17 100644 --- a/test/getcwidth.c +++ b/test/getcwidth.c @@ -114,7 +114,7 @@ getwidth(const char *string) * at a time. */ - mbtowc(NULL, NULL, 0); + if (mbtowc(NULL, NULL, 0)) {} while (charleft > 0) { int clen;