silence some compiler warnings
authorDavid Mitchell <davem@iabyn.com>
Tue, 12 Nov 2013 15:51:21 +0000 (15:51 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 13 Nov 2013 10:38:40 +0000 (10:38 +0000)
Actually, most of this commit is adding (void) to various function returns
where we know its ok to ignore the return value. This doesn't actually
silence the -Wunused-result warning (thanks a bundle gcc), but at least
it marks our intentions.

doio.c
op.c
perlio.c
thread.h
util.c

diff --git a/doio.c b/doio.c
index 50ab24f..39cbf6d 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1395,7 +1395,7 @@ S_exec_failed(pTHX_ const char *cmd, int fd, int do_report)
        Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't exec \"%s\": %s",
                    cmd, Strerror(e));
     if (do_report) {
-       PerlLIO_write(fd, (void*)&e, sizeof(int));
+       (void)PerlLIO_write(fd, (void*)&e, sizeof(int));
        PerlLIO_close(fd);
     }
 }
diff --git a/op.c b/op.c
index 072d0d0..625eaba 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1964,6 +1964,8 @@ S_finalize_op(pTHX_ OP* o)
        }
 
         lexname = NULL; /* just to silence compiler warnings */
+        fields  = NULL; /* just to silence compiler warnings */
+
        check_fields =
            rop
         && (lexname = *av_fetch(PL_comppad_name, rop->op_targ, TRUE),
index 279b529..60b6a59 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -463,7 +463,7 @@ PerlIO_debug(const char *fmt, ...)
        char buffer[1024];
        const STRLEN len1 = my_snprintf(buffer, sizeof(buffer), "%.40s:%" IVdf " ", s ? s : "(none)", (IV) CopLINE(PL_curcop));
        const STRLEN len2 = my_vsnprintf(buffer + len1, sizeof(buffer) - len1, fmt, ap);
-       PerlLIO_write(PL_perlio_debug_fd, buffer, len1 + len2);
+       (void)PerlLIO_write(PL_perlio_debug_fd, buffer, len1 + len2);
 #else
        const char *s = CopFILE(PL_curcop);
        STRLEN len;
@@ -472,7 +472,7 @@ PerlIO_debug(const char *fmt, ...)
        Perl_sv_vcatpvf(aTHX_ sv, fmt, &ap);
 
        s = SvPV_const(sv, len);
-       PerlLIO_write(PL_perlio_debug_fd, s, len);
+       (void)PerlLIO_write(PL_perlio_debug_fd, s, len);
        SvREFCNT_dec(sv);
 #endif
     }
index 15d2665..de23d75 100644 (file)
--- a/thread.h
+++ b/thread.h
 #  define ALLOC_THREAD_KEY \
     STMT_START {                                               \
        if (pthread_key_create(&PL_thr_key, 0)) {               \
-            write(2, STR_WITH_LEN("panic: pthread_key_create failed\n")); \
+            (void)write(2, STR_WITH_LEN("panic: pthread_key_create failed\n")); \
            exit(1);                                            \
        }                                                       \
     } STMT_END
diff --git a/util.c b/util.c
index b62caf8..c68bb90 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1597,7 +1597,7 @@ Perl_croak_no_mem()
     dTHX;
 
     /* Can't use PerlIO to write as it allocates memory */
-    PerlLIO_write(PerlIO_fileno(Perl_error_log),
+    (void)PerlLIO_write(PerlIO_fileno(Perl_error_log),
                  PL_no_mem, sizeof(PL_no_mem)-1);
     my_exit(1);
 }