[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-diffutils] [PATCH 09/19] maint: add an assertion to suppress clang-
From: |
Jim Meyering |
Subject: |
[bug-diffutils] [PATCH 09/19] maint: add an assertion to suppress clang-detected warning |
Date: |
Fri, 20 Nov 2009 10:12:18 +0100 |
From: Jim Meyering <address@hidden>
The clang static analyzer reported that a NULL parent could be
dereferenced. However, that cannot happen, because for all callers,
the parameter, parent, is always non-NULL at that point.
* src/diff.c: Include <assert.h>.
Assert that parent is not NULL.
---
src/diff.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/diff.c b/src/diff.c
index 708d892..5e82381 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -20,6 +20,7 @@
#define GDIFF_MAIN
#include "diff.h"
+#include <assert.h>
#include "paths.h"
#include <c-stack.h>
#include <dirname.h>
@@ -1221,8 +1222,11 @@ compare_files (struct comparison const *parent,
status = diff_dirs (&cmp, compare_files);
else
{
- char const *dir
- = parent->file[cmp.file[0].desc == NONEXISTENT].name;
+ char const *dir;
+
+ /* PARENT must be non-NULL here. */
+ assert (parent);
+ dir = parent->file[cmp.file[0].desc == NONEXISTENT].name;
/* See POSIX 1003.1-2001 for this format. */
message ("Only in %s: %s\n", dir, name0);
--
1.6.5.3.433.g11067
- [bug-diffutils] [PATCH 12/19] build: update gnulib submodule to latest, (continued)
- [bug-diffutils] [PATCH 12/19] build: update gnulib submodule to latest, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 17/19] build: suppress warnings about bindtextdomain and textdomain, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 15/19] use xfreopen rather than freopen, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 10/19] build: let automake generate better man-installation rules, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 11/19] maint: hide build commands behind $(AM_V_GEN), Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 18/19] maint: add gnulib's announce-gen module, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 16/19] build: use more gnulib modules, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 13/19] build: "make stable" emitted an invalid gnupload command, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 07/19] admin: ignore all of gnulib-tests, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 03/19] maint: address@hidden is the new bug-reporting address, Jim Meyering, 2009/11/20
- [bug-diffutils] [PATCH 09/19] maint: add an assertion to suppress clang-detected warning,
Jim Meyering <=
- [bug-diffutils] [PATCH 08/19] maint: remove dead assignment from diff3.c, Jim Meyering, 2009/11/20