emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-28 fd274d7 2/2: Pacify -Wanalyzer-null-argument in lisp_malloc


From: Paul Eggert
Subject: emacs-28 fd274d7 2/2: Pacify -Wanalyzer-null-argument in lisp_malloc
Date: Sun, 3 Oct 2021 19:55:26 -0400 (EDT)

branch: emacs-28
commit fd274d7d24ec35d64974b007cfe881c0e07edf9d
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Pacify -Wanalyzer-null-argument in lisp_malloc
    
    * src/alloc.c (lisp_malloc): Document that NBYTES must be
    positive, and omit a needless runtime check.  This pacifies a
    false alarm with gcc 11.2.1 -Wanalyzer-possible-null-dereference.
---
 src/alloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 0895a0f..0c04d5c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -988,7 +988,8 @@ record_xmalloc (size_t size)
 
 /* Like malloc but used for allocating Lisp data.  NBYTES is the
    number of bytes to allocate, TYPE describes the intended use of the
-   allocated memory block (for strings, for conses, ...).  */
+   allocated memory block (for strings, for conses, ...).
+   NBYTES must be positive.  */
 
 #if ! USE_LSB_TAG
 void *lisp_malloc_loser EXTERNALLY_VISIBLE;
@@ -1030,7 +1031,7 @@ lisp_malloc (size_t nbytes, bool clearit, enum mem_type 
type)
 #endif
 
   MALLOC_UNBLOCK_INPUT;
-  if (!val && nbytes)
+  if (!val)
     memory_full (nbytes);
   MALLOC_PROBE (nbytes);
   return val;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]