From 03acb64848c7cc3a02259a87b82a11a401c46810 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Tue, 12 Nov 2013 15:51:21 +0000 Subject: [PATCH] silence some compiler warnings 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 | 2 +- op.c | 2 ++ perlio.c | 4 ++-- thread.h | 2 +- util.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doio.c b/doio.c index 50ab24f..39cbf6d 100644 --- 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 --- 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), diff --git a/perlio.c b/perlio.c index 279b529..60b6a59 100644 --- 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 } diff --git a/thread.h b/thread.h index 15d2665..de23d75 100644 --- a/thread.h +++ b/thread.h @@ -336,7 +336,7 @@ # 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 --- 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); } -- 2.7.4