bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51503: [PATCH 1/1] Silly patch to avoid some gcc 11.2 warnings


From: Duncan Roe
Subject: bug#51503: [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@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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]