bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] exclude: avoid an unwarranted warning


From: Eric Blake
Subject: Re: [PATCH] exclude: avoid an unwarranted warning
Date: Fri, 30 Oct 2009 06:54:53 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 10/28/2009 2:42 PM:
> Jim Meyering wrote:
>> There are other ways to avoid the warning that are cleaner
> 
> Yes, I would have handled this one by adding a 'default: break;'
> alternative to the 'switch' statement. As a by-product of silencing
> the warning, it would also increase the robustness of the code.

Like this?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrq4hwACgkQ84KuGfSFAYAyygCffpTrknR8tnfdNQmFf3ifREQc
zFAAnihR8s79YSPw4jdRjJn+QGrSV9Bd
=Z/QK
-----END PGP SIGNATURE-----
>From bd69b9290a79d349b204f50ceef9b5f5ab0fde39 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 30 Oct 2009 06:48:14 -0600
Subject: [PATCH] exclude: make more robust

* lib/exclude.c (excluded_file_name): Abort on unexpected value,
rather than masking a coding bug.
Suggested by Bruno Haible.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog     |    7 +++++++
 lib/exclude.c |    7 ++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4e5e0bb..152af2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-30  Eric Blake  <address@hidden>
+
+       exclude: make more robust
+       * lib/exclude.c (excluded_file_name): Abort on unexpected value,
+       rather than masking a coding bug.
+       Suggested by Bruno Haible.
+
 2009-10-29  Eric Blake  <address@hidden>

        filenamecat-lgpl: adjust clients
diff --git a/lib/exclude.c b/lib/exclude.c
index 310c5ab..d1b421d 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -412,9 +412,7 @@ excluded_file_name (struct exclude const *ex, char const *f)
      excluded to included or vice versa.  */
   for (seg = ex->head; seg; seg = seg->next)
     {
-      /* Pacify gcc, so it doesn't issue a spurious
-        "may be used uninitialized" warning.  */
-      bool rc = excluded;
+      bool rc;

       switch (seg->type)
        {
@@ -427,6 +425,9 @@ excluded_file_name (struct exclude const *ex, char const *f)
            filename = xmalloc (strlen (f) + 1);
          rc = excluded_file_name_p (seg, f, filename);
          break;
+
+       default:
+         abort ();
        }
       if (rc != excluded)
        {
-- 
1.6.5.rc1


reply via email to

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