From e2301aabc3cbed5d1a500b9cce8fe673d44e0fc0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 1 Aug 2021 17:40:30 -0700 Subject: [PATCH] readutmp: improve -fanalyzer malloc checking --- ChangeLog | 1 + lib/readutmp.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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, -- 2.39.5