From: Paul Eggert Date: Mon, 2 Aug 2021 00:40:30 +0000 (-0700) Subject: readutmp: improve -fanalyzer malloc checking X-Git-Tag: v1.0~2748 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e2301aabc3cbed5d1a500b9cce8fe673d44e0fc0;p=gnulib.git readutmp: improve -fanalyzer malloc checking --- diff --git a/ChangeLog b/ChangeLog index 8a3dcb3885..11c4395b96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ * lib/canonicalize.h, lib/dfa.h, lib/dirname.h, lib/exclude.h: * lib/filenamecat.h, lib/malloca.h, lib/modechange.h: * lib/mountlist.h, lib/pagealign_alloc.h, lib/quotearg.h: + * lib/readutmp.h: Add malloc-related attributes and include stdlib.h as needed. * lib/dfa.c: Include verify.h. (assume_nonnull): New macro. diff --git a/lib/readutmp.h b/lib/readutmp.h index a3a7eda01c..5be9818029 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -20,6 +20,7 @@ #ifndef __READUTMP_H__ # define __READUTMP_H__ +# include # include /* AIX 4.3.3 has both utmp.h and utmpx.h, but only struct utmp @@ -211,7 +212,9 @@ enum READ_UTMP_USER_PROCESS = 2 }; -char *extract_trimmed_name (const STRUCT_UTMP *ut); +char *extract_trimmed_name (const STRUCT_UTMP *ut) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_RETURNS_NONNULL; /* FIXME: This header should use idx_t, not size_t. */ int read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf,