This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Unused snprintf results noticed by clang in Linux.
authorJarkko Hietaniemi <jhi@iki.fi>
Tue, 24 Jun 2014 22:08:58 +0000 (18:08 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 25 Jun 2014 10:24:39 +0000 (06:24 -0400)
A bit dubious to ignore the snprintf results, but at least
for these cases it looks acceptable.  We could assign the
length and croak if not expected, but it seems that with
gcc brace groups we already do that.

pp_ctl.c
toke.c

index 71542db..72266fa 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -838,10 +838,10 @@ PP(pp_formline)
            /* Formats aren't yet marked for locales, so assume "yes". */
            {
                 DECLARE_STORE_LC_NUMERIC_SET_TO_NEEDED();
-               arg &= ~(FORM_NUM_POINT|FORM_NUM_BLANK);
+                arg &= ~(FORM_NUM_POINT|FORM_NUM_BLANK);
                 /* we generate fmt ourselves so it is safe */
                 GCC_DIAG_IGNORE(-Wformat-nonliteral);
-               my_snprintf(t, SvLEN(PL_formtarget) - (t - SvPVX(PL_formtarget)), fmt, (int) fieldsize, (int) arg, value);
+                PERL_UNUSED_RESULT(my_snprintf(t, SvLEN(PL_formtarget) - (t - SvPVX(PL_formtarget)), fmt, (int) fieldsize, (int) arg, value));
                 GCC_DIAG_RESTORE;
                 RESTORE_LC_NUMERIC();
            }
diff --git a/toke.c b/toke.c
index 01578e0..e5c048f 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3379,8 +3379,10 @@ S_scan_const(pTHX_ char *start)
                                 d += 5;
                                 while (str < str_end) {
                                     char hex_string[4];
-                                    my_snprintf(hex_string, sizeof(hex_string),
-                                                "%02X.", (U8) *str);
+                                    PERL_UNUSED_RESULT(
+                                        my_snprintf(hex_string,
+                                                    sizeof(hex_string),
+                                                    "%02X.", (U8) *str));
                                     Copy(hex_string, d, 3, char);
                                     d += 3;
                                     str++;
@@ -7439,7 +7441,7 @@ Perl_yylex(pTHX)
                if (!PL_in_my_stash) {
                    char tmpbuf[1024];
                    PL_bufptr = s;
-                   my_snprintf(tmpbuf, sizeof(tmpbuf), "No such class %.1000s", PL_tokenbuf);
+                   PERL_UNUSED_RESULT(my_snprintf(tmpbuf, sizeof(tmpbuf), "No such class %.1000s", PL_tokenbuf));
                    yyerror_pv(tmpbuf, UTF ? SVf_UTF8 : 0);
                }
            }