-----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 e...@byu.net -----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 <e...@byu.net> 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 <e...@byu.net> --- 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 <e...@byu.net> + + 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 <e...@byu.net> 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