From d5bab3afd88a792933c565744a16667beb2e593a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Sun, 23 Dec 2018 18:03:13 -0800
Subject: [PATCH] build: avoid build failure with --enable-gcc-warnings and
 latest gcc

* src/diff.c (usage): Assert that each line length is no longer than
the minimum required size of 4095.  This lets newer gcc (currently
9.0.0 20181219) infer that it need not issue this warning:
diff.c:1012:19: error: '%.*s' directive output between 0 and 2147483647
bytes may exceed minimum required size of 4095
[-Werror=format-overflow=]
1012 |        printf ("  %.*s", msglen, msg);
---
 src/diff.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/diff.c b/src/diff.c
index 474da1e..e2eb324 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1009,6 +1009,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
 	  while ((nl = strchr (msg, '\n')))
 	    {
 	      int msglen = nl + 1 - msg;
+	      /* This assertion is solely to avoid a warning from
+		 gcc's -Wformat-overflow=.  */
+	      assert (msglen < 4096);
 	      printf ("  %.*s", msglen, msg);
 	      msg = nl + 1;
 	    }
-- 
2.20.1.2.gb21ebb671b

