Skip to content

Commit

Permalink
Improve errExit error messages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kmk3 committed Jun 28, 2023
1 parent e06c3e9 commit b963fe4
Show file tree
Hide file tree
Showing 28 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions src/etc-cleanup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/etc-cleanup
PROG = etc-cleanup
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fbuilder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fbuilder
PROG = fbuilder
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fcopy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fcopy
PROG = fcopy
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fids/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fids
PROG = fids
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/firecfg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firecfg
PROG = firecfg
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/firejail/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firejail
PROG = firejail
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/firemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/firemon
PROG = firemon
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fldd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fldd
PROG = fldd
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnet/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnet
PROG = fnet
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnetfilter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnetfilter
PROG = fnetfilter
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-dns/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-dns
PROG = fnettrace-dns
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-icmp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-icmp
PROG = fnettrace-icmp
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace-sni/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace-sni
PROG = fnettrace-sni
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fnettrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fnettrace
PROG = fnettrace
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fsec-optimize/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fsec-optimize
PROG = fsec-optimize
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fsec-print/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fsec-print
PROG = fsec-print
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fseccomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fseccomp
PROG = fseccomp
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/ftee/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/ftee
PROG = ftee
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/fzenity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/fzenity
PROG = fzenity
TARGET = $(PROG)

Expand Down
3 changes: 2 additions & 1 deletion src/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/jailcheck/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/jailcheck
PROG = jailcheck
TARGET = $(PROG)

Expand Down
1 change: 1 addition & 0 deletions src/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/lib
TARGET = lib

include $(ROOT)/src/prog.mk
Expand Down
1 change: 1 addition & 0 deletions src/libpostexecseccomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libpostexecseccomp
SO = libpostexecseccomp.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/libtrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libtrace
SO = libtrace.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/libtracelog/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/libtracelog
SO = libtracelog.so
TARGET = $(SO)

Expand Down
1 change: 1 addition & 0 deletions src/profstats/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ROOT = ../..
-include $(ROOT)/config.mk

MOD_DIR = src/profstats
PROG = profstats
TARGET = $(PROG)

Expand Down
2 changes: 1 addition & 1 deletion test/appimage/filename.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b963fe4

Please sign in to comment.