GNU bug report logs - #51503
[PATCH 1/1] Silly patch to avoid some gcc 11.2 warnings

Previous Next

Package: grep;

Reported by: Duncan Roe <duncan_roe <at> optusnet.com.au>

Date: Sat, 30 Oct 2021 10:17:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51503 in the body.
You can then email your comments to 51503 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#51503; Package grep. (Sat, 30 Oct 2021 10:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Duncan Roe <duncan_roe <at> optusnet.com.au>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Sat, 30 Oct 2021 10:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Duncan Roe <duncan_roe <at> optusnet.com.au>
To: bug-grep <at> gnu.org
Cc: duncan.roe2 <at> gmail.com, Duncan Roe <duncan_roe <at> optusnet.com.au>
Subject: [PATCH 1/1] Silly patch to avoid some gcc 11.2 warnings
Date: Sat, 30 Oct 2021 19:40:26 +1100
DO NOT APPLY THIS PATCH.
The patch is to highlight code constructs that gcc can't analyse
adequately.

Signed-off-by: Duncan Roe <duncan_roe <at> optusnet.com.au>
---
 lib/exclude.c        | 9 +++++++--
 lib/fts.c            | 2 +-
 lib/regex_internal.c | 6 +++---
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/exclude.c b/lib/exclude.c
index 417ab23d1..cf9a17bb1 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -676,7 +676,7 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
 {
   bool use_stdin = file_name[0] == '-' && !file_name[1];
   FILE *in;
-  int rc = 0;
+  int rc = 0, rc2;
 
   if (use_stdin)
     in = stdin;
@@ -685,7 +685,12 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
 
   rc = add_exclude_fp (call_addfn, ex, in, options, line_end, &add_func);
 
-  if (!use_stdin && fclose (in) != 0)
+  if (use_stdin)
+    return rc;
+
+  rc2 = fclose (in);
+
+  if (rc2)
     rc = -1;
 
   return rc;
diff --git a/lib/fts.c b/lib/fts.c
index 31ff21d00..54f29e99b 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1494,7 +1494,7 @@ mem1:                           saved_errno = errno;
                 /* Build a file name for fts_stat to stat. */
                 if (ISSET(FTS_NOCHDIR)) {
                         p->fts_accpath = p->fts_path;
-                        memmove(cp, p->fts_name, p->fts_namelen + 1);
+                        if(cp)memmove(cp, p->fts_name, p->fts_namelen + 1);
                 } else
                         p->fts_accpath = p->fts_name;
 
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index aefcfa2f5..0ace61cc9 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -984,7 +984,7 @@ re_node_set_init_1 (re_node_set *set, Idx elem)
   set->alloc = 1;
   set->nelem = 1;
   set->elems = re_malloc (Idx, 1);
-  if (__glibc_unlikely (set->elems == NULL))
+  if (set->elems == NULL)
     {
       set->alloc = set->nelem = 0;
       return REG_ESPACE;
@@ -999,7 +999,7 @@ re_node_set_init_2 (re_node_set *set, Idx elem1, Idx elem2)
 {
   set->alloc = 2;
   set->elems = re_malloc (Idx, 2);
-  if (__glibc_unlikely (set->elems == NULL))
+  if (set->elems == NULL)
     return REG_ESPACE;
   if (elem1 == elem2)
     {
@@ -1032,7 +1032,7 @@ re_node_set_init_copy (re_node_set *dest, const re_node_set *src)
     {
       dest->alloc = dest->nelem;
       dest->elems = re_malloc (Idx, dest->alloc);
-      if (__glibc_unlikely (dest->elems == NULL))
+      if (dest->elems == NULL)
 	{
 	  dest->alloc = dest->nelem = 0;
 	  return REG_ESPACE;
-- 
2.33.1





bug closed, send any further explanations to 51503 <at> debbugs.gnu.org and Duncan Roe <duncan_roe <at> optusnet.com.au> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Mon, 01 Nov 2021 05:40:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 29 Nov 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 203 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.