summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/benchmark-tests.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-10-13 11:16:33 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-10-13 11:47:20 -0700
commit33525102e728134f5f7399a3490a154bb0078e6d (patch)
tree9d3e90a2cb302e63fce9ba97fd47e2af910567c1 /test/lisp/emacs-lisp/benchmark-tests.el
parent8e072e6abef2bf1ec75b7c73883caeb7b7459eb1 (diff)
downloademacs-33525102e728134f5f7399a3490a154bb0078e6d.tar.gz
emacs-33525102e728134f5f7399a3490a154bb0078e6d.tar.bz2
emacs-33525102e728134f5f7399a3490a154bb0078e6d.zip
Pacify GCC -Wanalyzer-possible-null-dereference
This fixes the only remaining GCC diagnostics when emacs-28 is configured with --enable-gcc-warnings. It does so by adding ATTRIBUTE_RETURNS_NONNULL so that GCC knows certain functions return nonnull. It also arranges for three of those functions to always return nonnull; I thought these functions already were doing so, but apparently not, and it is conceivable (though I haven’t checked this) that changing these functions to always return nonnull even on non-GNU platforms may fix unlikely portability bugs elsewhere in Emacs. I used GCC 11.2.1 20210728 (Red Hat 11.2.1-1) on x86-64 when checking the diagnostics. * configure.ac: Invoke gl_EEMALLOC before gl_INIT, in case the regex code doesn't invoke gl_EEMALLOC; needed for src/alloc.c’s use of MALLOC_0_IS_NONNULL. * src/alloc.c (xmalloc, xzalloc, xrealloc): Don’t worry about the special case where SIZE == 0, since lmalloc and lrealloc now return null only on allocation failure. (lmalloc, lrealloc): Return null only on allocation failure, instead of having special cases that treat malloc (0) and realloc (X, 0) as successes even when they return null. * src/lisp.h: Add ATTRIBUTE_RETURNS_NONNULL to a few functions that always return nonnull pointers, so that gcc -fanalyzer does not issue diagnostics like “alloc.c: In function ‘allocate_vector_block’: alloc.c:2985:15: warning: dereference of possibly-NULL ‘block’ [CWE-690] [-Wanalyzer-possible-null-dereference]” as per <https://cwe.mitre.org/data/definitions/690.html>.
Diffstat (limited to 'test/lisp/emacs-lisp/benchmark-tests.el')
0 files changed, 0 insertions, 0 deletions