From b963fe41ae2cd669e5819aded531375ddaebc8b2 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Fri, 16 Jun 2023 15:42:20 -0300 Subject: Improve errExit error messages Changes: * Move msg to the end of errExit (right before perror(3p)) * Include the full file path (within the repository) * Add "()" to function name for clarity Before: Error malloc: main.c:123 main: Cannot allocate memory After: Error src/firejail/main.c:123 main(): malloc: Cannot allocate memory Note: This clarifies which is the exact file that the error message comes from, as there are many source files with the same name. For example: $ git ls-files 'src/*/main.c' | wc -l 20 --- src/include/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/common.h b/src/include/common.h index 23b00b6f8..4a2b8c1bf 100644 --- a/src/include/common.h +++ b/src/include/common.h @@ -41,7 +41,8 @@ #define errExit(msg) do { \ char msgout[500]; \ - snprintf(msgout, 500, "Error %s: %s:%d %s", msg, __FILE__, __LINE__, __func__); \ + snprintf(msgout, 500, "Error %s/%s:%d %s(): %s", \ + MOD_DIR, __FILE__, __LINE__, __func__, msg); \ perror(msgout); \ exit(1); \ } while (0) -- cgit v1.2.3-54-g00ecf