diff options
author | Colin Watson <cjwatson@debian.org> | 2022-01-30 15:03:39 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-01-30 15:03:40 +0000 |
commit | 43aa5a2b077fafa7b5239302d6e41f42830bf6ac (patch) | |
tree | ac58ae008d16b9fe9b02bd4b05ec81ca27de26c0 /bootstrap.conf | |
parent | b3f2788945722093b3c9e95eb4905395a634d9f5 (diff) |
Simplify static analysis of fatal errors
The usual idiom for fatal error reporting in man-db is `error (FATAL,
...)` (there are a few cases using different exit codes, but they're
less common). Unfortunately, there's no easy way to tell the compiler
that this call doesn't return, because `error (0, ...)` *does* return.
As a result, some call sites required extra work to give the compiler
this information, which can sometimes make a difference to static
analysis.
To simplify this, add a new `fatal` helper function which always exits
`FATAL` (i.e. 2) and never returns. This is declared with `_Noreturn`
so that the compiler can straightforwardly know what's going on.
* bootstrap.conf (gnulib_modules): Add verror.
(XGETTEXT_OPTIONS): Add --flag=fatal:2:c-format.
* lib/fatal.c, lib/fatal.h: New files.
* lib/Makefile.am (libman_la_SOURCES): Add fatal.c and fatal.h.
* src/tests/Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/lib.
(get_mtime_LDADD): Add $(top_builddir)/lib/libman.la.
* lib/pathsearch.c (pathsearch, directory_on_path): Use fatal.
* lib/sandbox.c (can_load_seccomp, make_seccomp_filter, _sandbox_load):
Likewise.
* lib/security.c (gripe_set_euid): Likewise.
* lib/xregcomp.c (xregcomp): Likewise.
* libdb/db_lookup.c (gripe_corrupt_data, dblookup_pattern): Likewise.
* libdb/db_ver.c (dbver_wr): Likewise.
* src/accessdb.c (main): Likewise.
* src/catman.c (parse_for_sec): Likewise.
* src/check_mandirs.c (chown_if_possible): Likewise.
* src/man-recode.c (recode): Likewise.
* src/man.c (open_cat_stream, format_display, gripe_converting_name):
Likewise.
* src/manconv.c (add_output): Likewise.
* src/manp.c (add_dir_to_path_list): Likewise.
* src/tests/get-mtime.c (main): Likewise.
* src/whatis.c (do_apropos): Likewise.
* src/zsoelim.l (<so>\"?[^ \t\n\"]+\"?): Likewise.
* libdb/db_lookup.c (gripe_corrupt_data, gripe_replace_key): Declare as
_Noreturn.
* src/accessdb.c (main): Remove now-unnecessary assertion.
* src/man.c (gripe_converting_name): Remove now-unnecessary abort.
Diffstat (limited to 'bootstrap.conf')
-rw-r--r-- | bootstrap.conf | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/bootstrap.conf b/bootstrap.conf index dcc403d5..3b53c932 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -76,6 +76,7 @@ gnulib_modules=" timespec unlinkat utimens + verror warnings xalloc xgetcwd @@ -112,6 +113,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ --from-code=UTF-8\\\ --flag=debug:1:c-format\\\ --flag=debug_error:1:c-format\\\ + --flag=fatal:2:c-format\\\ ' checkout_only_file= |