about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <mwrap-perl@80x24.org>2023-01-11 04:29:29 +0000
committerEric Wong <mwrap-perl@80x24.org>2023-01-11 04:29:41 +0000
commit3d09a04398b23c1baeaecd0e17601fd4f5c277bb (patch)
tree7268e359f3d876c6ddd3e715e1e5dfe5f81f1900
parent20add372333a15adbb96b69c273f3f50e84189c7 (diff)
downloadmwrap-3d09a04398b23c1baeaecd0e17601fd4f5c277bb.tar.gz
The `dump_fd' warning is legit but wasn't caught on my other system.
The `lineno' warning pops up on my system with `-O0'
-rw-r--r--mwrap_core.h15
1 files 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"))