rsync 2.6.2: clean up compilation warnings

Jeremy Buhler jbuhler at cse.wustl.edu
Sun May 2 18:32:56 GMT 2004


While building rsync 2.6.2 on my x86 Linux system using gcc 3.3.3, I
observed a number of warnings from popt.c/h about ignoring qualifiers
on return types.  On further investigation, it looks like a few
functions are declaring their return types as "const char * const".
The first const is appropriate ("the chars pointed to by this pointer
are const"), but the second is bogus ("the value returned is const",
which is meaningless since the value is copied) and is the cause of
the warnings.

The patch below removes the spurious consts and silences the warnings.

                                                         Jeremy

diff -uwr rsync-2.6.2-old/popt/popt.c rsync-2.6.2/popt/popt.c
--- rsync-2.6.2-old/popt/popt.c	2004-01-27 10:27:05.000000000 -0600
+++ rsync-2.6.2/popt/popt.c	2004-05-02 13:22:53.000000000 -0500
@@ -1128,7 +1128,7 @@
     /*@=nullderef@*/
 }

-const char *const poptStrerror(const int error)
+const char * poptStrerror(const int error)
 {
     switch (error) {
       case POPT_ERROR_NOARG:
diff -uwr rsync-2.6.2-old/popt/popt.h rsync-2.6.2/popt/popt.h
--- rsync-2.6.2-old/popt/popt.h	2004-01-27 10:27:05.000000000 -0600
+++ rsync-2.6.2/popt/popt.h	2004-05-02 13:23:01.000000000 -0500
@@ -373,7 +373,7 @@
  * @return		error string
  */
 /*@-redecl@*/
-/*@observer@*/ const char *const poptStrerror(const int error)
+/*@observer@*/ const char * poptStrerror(const int error)
 	/*@*/;
 /*@=redecl@*/

diff -uwr rsync-2.6.2-old/popt/popthelp.c rsync-2.6.2/popt/popthelp.c
--- rsync-2.6.2-old/popt/popthelp.c	2004-01-27 10:27:05.000000000 -0600
+++ rsync-2.6.2/popt/popthelp.c	2004-05-02 13:23:52.000000000 -0500
@@ -63,7 +63,7 @@
 /**
  * @param table		option(s)
  */
-/*@observer@*/ /*@null@*/ static const char *const
+/*@observer@*/ /*@null@*/ static const char *
 getTableTranslationDomain(/*@null@*/ const struct poptOption *table)
 	/*@*/
 {
@@ -81,7 +81,7 @@
  * @param opt		option(s)
  * @param translation_domain	translation domain
  */
-/*@observer@*/ /*@null@*/ static const char *const
+/*@observer@*/ /*@null@*/ static const char *
 getArgDescrip(const struct poptOption * opt,
 		/*@-paramuse@*/		/* FIX: wazzup? */
 		/*@null@*/ UNUSED(const char * translation_domain))


More information about the rsync mailing list