[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/17] diff3: suppress -fanalyzer alarms
From: |
Paul Eggert |
Subject: |
[PATCH 03/17] diff3: suppress -fanalyzer alarms |
Date: |
Sun, 22 Aug 2021 14:02:52 -0700 |
* src/diff3.c: Add pragma to suppress -Wanalyzer-null-dereference
alarms.
* src/diff.h (find_dir_file_pathname): Add malloc-related
attributes, to pacify gcc -Wsuggest-attribute=malloc.
---
src/diff.h | 12 +++++++++---
src/diff3.c | 8 ++++++++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/diff.h b/src/diff.h
index 27362c0..c469371 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -355,7 +355,9 @@ extern void print_context_script (struct change *, bool);
extern int diff_dirs (struct comparison const *,
int (*) (struct comparison const *,
char const *, char const *));
-extern char *find_dir_file_pathname (char const *, char const *);
+extern char *find_dir_file_pathname (char const *, char const *)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
/* ed.c */
extern void print_ed_script (struct change *);
@@ -380,12 +382,16 @@ extern void print_sdiff_script (struct change *);
/* util.c */
extern char const change_letter[4];
extern char const pr_program[];
-extern char *concat (char const *, char const *, char const *);
+extern char *concat (char const *, char const *, char const *)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
extern bool lines_differ (char const *, char const *) _GL_ATTRIBUTE_PURE;
extern lin translate_line_number (struct file_data const *, lin);
extern struct change *find_change (struct change *);
extern struct change *find_reverse_change (struct change *);
-extern void *zalloc (size_t);
+extern void *zalloc (size_t)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
extern enum changes analyze_hunk (struct change *, lin *, lin *, lin *, lin *);
extern void begin_output (void);
extern void debug_script (struct change *);
diff --git a/src/diff3.c b/src/diff3.c
index 6be7e3c..1f656b6 100644
--- a/src/diff3.c
+++ b/src/diff3.c
@@ -16,6 +16,14 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* As of GCC 11.2.1, gcc -Wanalyzer-too-complex reports that this
+ program's code is too complicated for gcc -fanalyzer.
+ FIXME: Compile with -DANALYZER_NULL_DEFERENCE and see whether the
+ resulting diagnostics are false alarms. */
+#if 10 <= __GNUC__ && !ANALYZER_NULL_DEREFERENCE
+# pragma GCC diagnostic ignored "-Wanalyzer-null-dereference"
+#endif
+
#include "system.h"
#include "paths.h"
--
2.31.1
- [PATCH 01/17] build: update gnulib submodule to latest, Paul Eggert, 2021/08/22
- [PATCH 06/17] maint: omit unused function if not debugging, Paul Eggert, 2021/08/22
- [PATCH 12/17] diff3: simplify process_diff, Paul Eggert, 2021/08/22
- [PATCH 09/17] diff: remove printint, Paul Eggert, 2021/08/22
- [PATCH 14/17] diff: use mempcpy, Paul Eggert, 2021/08/22
- [PATCH 08/17] diff: remove INT_MAX limit on -F/-p searches, Paul Eggert, 2021/08/22
- [PATCH 03/17] diff3: suppress -fanalyzer alarms,
Paul Eggert <=
- [PATCH 16/17] maint: refactor integer overflow checking, Paul Eggert, 2021/08/22
- [PATCH 04/17] maint: zalloc → xzalloc, Paul Eggert, 2021/08/22
- [PATCH 13/17] sdiff: fix unlikely memory leak, Paul Eggert, 2021/08/22
- [PATCH 02/17] maint: remove January workaround for Gnulib issue, Paul Eggert, 2021/08/22
- [PATCH 17/17] diff: add integer overflow checking, Paul Eggert, 2021/08/22
- [PATCH 10/17] maint: lint → GCC_LINT, Paul Eggert, 2021/08/22
- [PATCH 05/17] maint: remove prepargs, Paul Eggert, 2021/08/22
- [PATCH 07/17] maint: .gitignore updates, Paul Eggert, 2021/08/22
- [PATCH 11/17] maint: modernize IF_LINT for GCC 11.2.1, Paul Eggert, 2021/08/22
- [PATCH 15/17] diff: avoid sprintf %s, Paul Eggert, 2021/08/22