bug-coreutils
[Top][All Lists]
Advanced

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

Re: recent const churn


From: Eric Blake
Subject: Re: recent const churn
Date: Mon, 16 Jun 2008 21:22:23 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666

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

According to Jim Meyering on 6/16/2008 9:49 AM:
|> Sounds like an updated maintainer rule to check for redundant const
might be
|> useful?
|
| Thanks for keeping watch!
| Anything to protect me from myself ;-)
| If you feel like it, a patch would be most welcome.

Attached, or...
$ git fetch git://repo.or.cz/coreutils/ericb.git const:const

Hopefully the use of "grep '\b'" in maint.mk is acceptable, even though it
is GNU-specific (at any rate, I'm not the first to use it).  I had to use
it to avoid a false positive in tr.c (a comment mentioned the word
contruct twice).

- --
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

iEYEARECAAYFAkhXLe8ACgkQ84KuGfSFAYAmrACdGYyLak71fccvEas6fniJjIM1
PDMAoNfszCbFgqBE3qDqzD2KLu7ZfQeF
=sbtT
-----END PGP SIGNATURE-----
>From 3f42f54ba6bd22e16b27f51b9549d76ad02312df Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 16 Jun 2008 21:16:07 -0600
Subject: [PATCH] ls, od: avoid redundant const

* src/ls.c (long_time_format, sort_functions): Avoid redundant
const.
* src/od.c (charname): Likewise.
* maint.mk (sc_redundant_const): Add rule to detect this.
(sc_const_long_option): Tweak to avoid tripping new rule.
---
 maint.mk |    7 ++++++-
 src/ls.c |    4 ++--
 src/od.c |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/maint.mk b/maint.mk
index df6b7f3..859d405 100644
--- a/maint.mk
+++ b/maint.mk
@@ -483,9 +483,14 @@ sc_proper_name_utf8_requires_ICONV:
              exit 1; } || :;                                           \
        fi
 
+sc_redundant_const:
+       @grep 'const\b[^*]*const' $$($(VC_LIST_EXCEPT)) &&              \
+           { echo 1>&2 '$(ME): redundant "const" in declarations';     \
+             exit 1; } || :
+
 sc_const_long_option:
        @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT))         \
-         | grep -Ev 'const struct option|struct option const' && {     \
+         | grep -Ev 'const *struct option|struct option const' && {    \
              echo 1>&2 '$(ME): add "const" to the above declarations'; \
              exit 1; } || :
 
diff --git a/src/ls.c b/src/ls.c
index 87f7997..4e044a9 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -672,7 +672,7 @@ enum { TIME_STAMP_LEN_MAXIMUM = MAX (1000, INT_STRLEN_BOUND 
(time_t)) };
 /* strftime formats for non-recent and recent files, respectively, in
    -l output.  */
 
-static const char const *long_time_format[2] =
+static char const *long_time_format[2] =
   {
     /* strftime format for non-recent files (older than 6 months), in
        -l output.  This should contain the year, month and day (at
@@ -3151,7 +3151,7 @@ static int rev_xstrcoll_df_version (V a, V b)
     }                                                               \
   }
 
-static const qsortFunc const sort_functions[][2][2][2] =
+static qsortFunc const sort_functions[][2][2][2] =
   {
     LIST_SORTFUNCTION_VARIANTS (name),
     LIST_SORTFUNCTION_VARIANTS (extension),
diff --git a/src/od.c b/src/od.c
index 70ba59c..5b4b7bd 100644
--- a/src/od.c
+++ b/src/od.c
@@ -174,7 +174,7 @@ static const int width_bytes[] =
 verify (sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS);
 
 /* Names for some non-printing characters.  */
-static const char const charname[33][4] =
+static char const charname[33][4] =
 {
   "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
   "bs", "ht", "nl", "vt", "ff", "cr", "so", "si",
-- 
1.5.5.1


reply via email to

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