[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/27] dirname: improve -fanalyzer malloc checking
From: |
Paul Eggert |
Subject: |
[PATCH 04/27] dirname: improve -fanalyzer malloc checking |
Date: |
Sun, 1 Aug 2021 18:17:58 -0700 |
---
ChangeLog | 2 +-
lib/dirname.h | 12 +++++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d7740df52..884443438 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@
maint: improve -fanalyzer malloc checking
* lib/backup-internal.h, lib/backupfile.h:
- * lib/canonicalize.h, lib/dfa.h:
+ * lib/canonicalize.h, lib/dfa.h, lib/dirname.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/dirname.h b/lib/dirname.h
index 492a4381f..04f823eca 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -21,6 +21,7 @@
# include <stdbool.h>
# include <stddef.h>
+# include <stdlib.h>
# include "filename.h"
# include "basename-lgpl.h"
@@ -33,11 +34,16 @@ extern "C" {
#endif
# if GNULIB_DIRNAME
-char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC;
-char *dir_name (char const *file);
+char *base_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+char *dir_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
# endif
-char *mdir_name (char const *file);
+char *mdir_name (char const *file)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE;
size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
bool strip_trailing_slashes (char *file);
--
2.31.1
- [PATCH 01/27] backupfile: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 02/27] maint: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 03/27] dfa: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 04/27] dirname: improve -fanalyzer malloc checking,
Paul Eggert <=
- [PATCH 05/27] exclude: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 06/27] filenamecat-lgpl: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 08/27] modechange: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 07/27] malloca: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 09/27] mountlist: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 10/27] pagalign_alloc: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01
- [PATCH 11/27] quotearg: improve -fanalyzer malloc checking, Paul Eggert, 2021/08/01