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
This commit is contained in:
Kelvin M. Klann 2023-06-16 15:42:20 -03:00
parent e06c3e99d8
commit b963fe41ae
28 changed files with 29 additions and 3 deletions

View file

@ -83,7 +83,7 @@ LDFLAGS=@LDFLAGS@
# Project variables
EXTRA_CFLAGS =@EXTRA_CFLAGS@
COMMON_CFLAGS = \
-ggdb -O2 -DVERSION='"$(VERSION)"' \
-ggdb -O2 -DVERSION='"$(VERSION)"' -DMOD_DIR='"$(MOD_DIR)"' \
-Wall -Wextra $(HAVE_FATAL_WARNINGS) \
-Wformat -Wformat-security \
-fstack-protector-all -D_FORTIFY_SOURCE=2 \

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/etc-cleanup
PROG = etc-cleanup
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fbuilder
PROG = fbuilder
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fcopy
PROG = fcopy
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fids
PROG = fids
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/firecfg
PROG = firecfg
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/firejail
PROG = firejail
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/firemon
PROG = firemon
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fldd
PROG = fldd
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnet
PROG = fnet
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnetfilter
PROG = fnetfilter
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnettrace-dns
PROG = fnettrace-dns
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnettrace-icmp
PROG = fnettrace-icmp
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnettrace-sni
PROG = fnettrace-sni
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fnettrace
PROG = fnettrace
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fsec-optimize
PROG = fsec-optimize
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fsec-print
PROG = fsec-print
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fseccomp
PROG = fseccomp
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/ftee
PROG = ftee
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/fzenity
PROG = fzenity
TARGET = $(PROG)

View file

@ -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)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/jailcheck
PROG = jailcheck
TARGET = $(PROG)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/lib
TARGET = lib
include $(ROOT)/src/prog.mk

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/libpostexecseccomp
SO = libpostexecseccomp.so
TARGET = $(SO)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/libtrace
SO = libtrace.so
TARGET = $(SO)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/libtracelog
SO = libtracelog.so
TARGET = $(SO)

View file

@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk
MOD_DIR = src/profstats
PROG = profstats
TARGET = $(PROG)

View file

@ -24,7 +24,7 @@ after 100
send -- "firejail --appimage appimage.sh\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"Error mounting appimage"
-re "Error .*mounting appimage"
}
after 100