From 3d09a04398b23c1baeaecd0e17601fd4f5c277bb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 11 Jan 2023 04:29:29 +0000 Subject: fix uninitialized warnings The `dump_fd' warning is legit but wasn't caught on my other system. The `lineno' warning pops up on my system with `-O0' --- mwrap_core.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mwrap_core.h b/mwrap_core.h index 86e4498..a2c6d4a 100644 --- a/mwrap_core.h +++ b/mwrap_core.h @@ -388,9 +388,8 @@ static const COP *mwp_curcop(void) static const char *mw_perl_src_file_cstr(unsigned *lineno) { const COP *cop = mwp_curcop(); - if (!cop) return NULL; - *lineno = CopLINE(cop); - return CopFILE(cop); + *lineno = cop ? CopLINE(cop) : 0; + return cop ? CopFILE(cop) : NULL; } # define SRC_FILE_CSTR(lineno) mw_perl_src_file_cstr(lineno) #endif /* MWRAP_PERL */ @@ -922,9 +921,13 @@ __attribute__ ((destructor)) static void mwrap_dtor(void) fprintf(stderr, "open %s failed: %m\n", dump_path); goto out; } - } else if ((s = strstr(opt, "dump_fd:")) && - !sscanf(s, "dump_fd:%d", &dump_fd)) - goto out; + } else { + s = strstr(opt, "dump_fd:"); + if (!s) + goto out; + if (!sscanf(s, "dump_fd:%d", &dump_fd)) + goto out; + } /* allow dump_csv standalone for dump_fd */ if (!a.dump_csv && strstr(opt, "dump_csv")) -- cgit v1.2.3-24-ge0c7