[PATCH] build: update to latest gnulib and adapt

Jim Meyering jim at meyering.net
Wed Dec 14 17:52:47 UTC 2011


I've just updated to the latest from gnulib
That pulled in a few new gcc warning options that
suggest additions of the const and pure attributes.  I've added the ones
that I could.  For the one bogus suggestion I added a #pragma
to disable the offending suggestion/error in dc-vmware-image.c
(the function calls exit, so cannot be "pure").  I added another
such #pragma to parser.y to avoid warnings about function definitions
emitted by bison.

It also enabled the -Wformat-nonliteral option, which gets too many
false positives, so I've disabled that one.

There were also a couple more reversed-compare-argument nits
caught by a stricter version of a new syntax-check rule.


>From a17c231d4f71f2271b069af206f158a955374c29 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Wed, 14 Dec 2011 17:41:30 +0100
Subject: [PATCH] build: update to latest gnulib and adapt

* configure.ac: Use -Wno-format-nonliteral.
Mark functions as pure, per recommendations enabled by new
gcc -W options.
* dc-rhev-image.c: Use _GL_ATTRIBUTE_PURE.
* rest.c: Likewise.
* setup.c: Likewise.
* setup.h: Likewise.
* user.h: Likewise.
* dc-vmware-image.c: Likewise, and disable -Wsuggest-attribute=pure.
* qparser.y: Likewise, and disable -Wsuggest-attribute=pure
* t/provider: Reverse compare arguments, to avoid new syntax-check.
* t/parse-test: Likewise.
---
 configure.ac      |    1 +
 dc-rhev-image.c   |    6 ++++--
 dc-vmware-image.c |   13 +++++++++++--
 gnulib            |    2 +-
 qparser.y         |   12 +++++++++---
 rest.c            |    4 ++--
 setup.c           |    2 +-
 setup.h           |    2 +-
 t/parse-test      |    6 +++---
 t/provider        |    2 +-
 user.h            |    2 +-
 11 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index a147cd8..2c11bb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,6 +162,7 @@ if test "$gl_gcc_warnings" = yes; then
   gl_WARN_ADD([-Wno-unused-function])
   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
   gl_WARN_ADD([-Wno-sign-compare])     # warnings in bison-generated qparser.c
+  gl_WARN_ADD([-Wno-format-nonliteral])

   # In spite of excluding -Wlogical-op above, it is enabled, as of
   # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index bf26212..99d2b8b 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -461,7 +461,8 @@ static size_t api_rcb(void *ptr, size_t bsz, size_t nmemb, void *arg)
 	return count;
 }

-static void require_api_root(const xmlChar *actual, const char *required)
+static void _GL_ATTRIBUTE_PURE
+require_api_root(const xmlChar *actual, const char *required)
 {
 	if (strcmp((const char *)actual, required) != 0) {
 		fprintf(stderr,
@@ -557,7 +558,8 @@ static void apipaths(struct api_conn *connection,
 	exit(EXIT_FAILURE);
 }

-static xmlNode *xmlGetChild(xmlNode *node, const char *name)
+static xmlNode * _GL_ATTRIBUTE_PURE
+xmlGetChild(xmlNode *node, const char *name)
 {
 	xmlNode *et;

diff --git a/dc-vmware-image.c b/dc-vmware-image.c
index 6f041b3..9fbe6a3 100644
--- a/dc-vmware-image.c
+++ b/dc-vmware-image.c
@@ -15,6 +15,13 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+/* Without this pragma, gcc 4.7.0 20111202 mistakenly suggests that
+   the x_getchild function might be candidate for attribute 'pure'  */
+#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+#endif
+
 #include <config.h>

 #include <stdbool.h>
@@ -366,7 +373,8 @@ static bool curlx_add_header(struct curl_slist **headers, const char *hdr)
 }

 /* No idea why DV never implemented this, but implemented xmlGetProp. */
-static xmlNode *xmlGetChild(xmlNode *etroot, const char *name)
+static xmlNode * _GL_ATTRIBUTE_PURE
+xmlGetChild(xmlNode *etroot, const char *name)
 {
 	xmlNode *et;

@@ -380,7 +388,8 @@ static xmlNode *xmlGetChild(xmlNode *etroot, const char *name)
 	return NULL;
 }

-static xmlNode *x_getchild(xmlNode *etroot, const char *name)
+static xmlNode *
+x_getchild(xmlNode *etroot, const char *name)
 {
 	xmlNode *et;
 	const xmlChar *p;
diff --git a/gnulib b/gnulib
index 996ce97..4e0358a 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 996ce97a8f8572ae9bade6c7df1aa364bd0e259f
+Subproject commit 4e0358a6af54a597c5a3a8f7558a7e856758b141
diff --git a/qparser.y b/qparser.y
index d1e8d52..76eaeb6 100644
--- a/qparser.y
+++ b/qparser.y
@@ -2,6 +2,12 @@
 %error-verbose

 %{
+/* Without this pragma, gcc 4.7.0 20111202 rightly suggests that
+   bison-emitted functions might be candidate for attribute 'pure'  */
+#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+#endif
+
 #include <config.h>
 #include "query.h"
 #include "qparser.h"
@@ -266,7 +272,7 @@ static const struct { char *name; char *value; } hacked_obj_fields[] = {
 };

 /* Fake out the eval code for unit testing. */
-static const char *
+static const char * _GL_ATTRIBUTE_PURE
 unit_oget_func (void * notused, const char *text)
 {
 	int i;
@@ -300,7 +306,7 @@ static const struct { char *obj; char *key; char *value; } hacked_links[] = {
 	{ NULL, NULL, NULL }
 };

-static char *
+static char * _GL_ATTRIBUTE_PURE
 follow_link (const char *object, const char *key)
 {
 	unsigned int i;
@@ -445,7 +451,7 @@ string_value (value_t *v, const getter_t *oget, const getter_t *sget)
  * Check whether a string looks like a simple decimal number.  There's
  * probably a library function for this somewhere.
  */
-static int
+static int _GL_ATTRIBUTE_PURE
 is_ok_number (const char *a_str)
 {
 	const char	*p;
diff --git a/rest.c b/rest.c
index 22acc1e..5dee8d7 100644
--- a/rest.c
+++ b/rest.c
@@ -220,7 +220,7 @@ validate_put (struct MHD_Connection *conn)
 	}
 }

-static int
+static int _GL_ATTRIBUTE_PURE
 is_reserved (const char *cand, char const *const *resv_list)
 {
 	int	i;
@@ -2216,7 +2216,7 @@ rebuild_url(bool is_ssl, struct MHD_Connection *conn, const char *path)
    the string, TYPE, followed by more optional spaces.
    If so, return a pointer to the first non-space following
    TYPE in VAL.  Otherwise, return NULL. */
-static const char *
+static const char * _GL_ATTRIBUTE_PURE
 auth_type_check (const char *val, const char *type)
 {
 	const char *p;
diff --git a/setup.c b/setup.c
index 184cfd5..a81477d 100644
--- a/setup.c
+++ b/setup.c
@@ -291,7 +291,7 @@ dup_json_string (const json_t *obj, const char *field)
 	return tmp;
 }

-static int
+static int _GL_ATTRIBUTE_PURE
 is_reserved_attr (const char *name)
 {
 	static char const *const rsvd[] = {
diff --git a/setup.h b/setup.h
index ca14735..f55f1f3 100644
--- a/setup.h
+++ b/setup.h
@@ -52,7 +52,7 @@ extern const char *auto_config (void);
 extern int validate_provider (Hash_table *h);
 extern provider_t *find_provider (const char *name);
 extern int add_provider (Hash_table *h);
-extern provider_t *get_main_provider (void);
+extern provider_t *get_main_provider (void) _GL_ATTRIBUTE_PURE;
 extern void set_main_provider (provider_t *prov);

 typedef int (*prov_iterator_fn) (provider_t *, void *);
diff --git a/t/parse-test b/t/parse-test
index d9eb6ec..c88a841 100755
--- a/t/parse-test
+++ b/t/parse-test
@@ -20,16 +20,16 @@ d= 0
 EOF

 parser-test '#a=="fubar"&&!($b.c.d<3)' > features 2> err || fail=1
-compare features f.exp || fail=1
+compare f.exp features || fail=1
 compare /dev/null err || fail=1

 parser-test '#a == "fubar" && ! ( $b.c.d < 3)' > white-space 2> err || fail=1
-compare white-space f.exp || fail=1
+compare f.exp white-space || fail=1
 compare /dev/null err || fail=1

 parser-test '$ a' > a.out 2>&1 || fail=1
 printf "OBJECT FIELD a (2)\ns= 2\n" > a.exp
-compare a.out a.exp || fail=1
+compare a.exp a.out || fail=1

 parser-test '$.a' > e1.out 2>&1; test $? = 1 || fail=1
 printf "could not parse '$.a'\n" > e1.exp
diff --git a/t/provider b/t/provider
index c858be2..083cfe0 100644
--- a/t/provider
+++ b/t/provider
@@ -65,7 +65,7 @@ for z in xml json; do
     emit_provider $z primary fs '' 0 '' '' is-last || fail=1
     emit_provider_list_suffix $z
   } > p-exp-$z
-  compare p-list-$z p-exp-$z || fail=1
+  compare p-exp-$z p-list-$z || fail=1

 done

diff --git a/user.h b/user.h
index 1308241..becb518 100644
--- a/user.h
+++ b/user.h
@@ -25,7 +25,7 @@ struct user {
 	char pass[USERPASS_MAX+1];
 };

-extern struct user *user_lookup (const char *userid);
+extern struct user *user_lookup (const char *userid) _GL_ATTRIBUTE_PURE;
 extern void user_add (const char *usercred);
 extern bool parse_users (const char *);

--
1.7.8.163.g9859a


More information about the iwhd-devel mailing list