I've recently been improving some GCC-based static analysis in Gnulib, and syncing from Gnulib to diffutils meant that you have a bit of a work-in-progress there. I plan to make further such changes soon.

The Gnulib work already installed is conservative and I see no harm in releasing what we've got in diffutils now. I'm sending this email mainly to give you a heads-up that more Gnulib changes are coming.

FWIW attached are the diffutils patches I have so far. They assume the abovementioned Gnulib work-in-progress and this should not be installed in diffutils yet. Most likely more minor diffutils patches will be needed once I've finished the Gnulib changes I have in mind.

Until today I've been using the Gnulib work-in-progress on grep rather than on diffutils. I've found one memory leak there and hope to find more bugs - after all, that's the point of all this. I didn't find any diffutils bugs in my brief run-through today.
diff --git a/configure.ac b/configure.ac
index 73adb80..b532d43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,10 +96,6 @@ if test "$gl_gcc_warnings" = yes; then
   nw="$nw -Wsuggest-attribute=pure"
   nw="$nw -Wduplicated-branches"    # Too many false alarms
 
-  # Avoid false alarm in lib/vasnprintf.c.
-  # https://lists.gnu.org/r/bug-gnulib/2021-01/msg00031.html
-  gl_WARN_ADD([-Wno-analyzer-null-argument])
-
   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
   AC_SUBST([GNULIB_WARN_CFLAGS])
 fi
diff --git a/src/diff.h b/src/diff.h
index 27362c0..0849a55 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 *);
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"
 

Reply via email to