libiberty: {count,dup,write}argv: constify argv input slightly
authorMike Frysinger <vapier@gentoo.org>
Sun, 3 Jan 2016 06:30:32 +0000 (01:30 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 5 Jan 2016 20:25:13 +0000 (15:25 -0500)
Would be more useful if we could use "const char * const *", but there's
a long standing bug where gcc warns about incompatible pointers when you
try to pass in "char **".  We can at least constify the array itself as
gcc will not warn in that case.

include/ChangeLog
include/libiberty.h
libiberty/ChangeLog
libiberty/argv.c
libiberty/functions.texi

index 70e19b783dabcaed114f6d28e65cb51a8ff3902f..07c24d338bde6d41416ac9a237b28bbc7f96cbdf 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * libiberty.h (dupargv): Change arg to char * const *.
+       (writeargv, countargv): Likewise.
+
 2016-01-01  Alan Modra  <amodra@gmail.com>
 
        Update year range in copyright notice of all files.
index 6aa8700ebb3e8a9cfc9537f399d961990e104bef..8f7d5f64930ee4111f1cce245c90c720c7b46b10 100644 (file)
@@ -80,7 +80,7 @@ extern void freeargv (char **);
 /* Duplicate an argument vector. Allocates memory using malloc.  Use
    freeargv to free the vector.  */
 
-extern char **dupargv (char **) ATTRIBUTE_MALLOC;
+extern char **dupargv (char * const *) ATTRIBUTE_MALLOC;
 
 /* Expand "@file" arguments in argv.  */
 
@@ -88,11 +88,11 @@ extern void expandargv (int *, char ***);
 
 /* Write argv to an @-file, inserting necessary quoting.  */
 
-extern int writeargv (char **, FILE *);
+extern int writeargv (char * const *, FILE *);
 
 /* Return the number of elements in argv.  */
 
-extern int countargv (char**);
+extern int countargv (char * const *);
 
 /* Return the last component of a path name.  Note that we can't use a
    prototype here because the parameter is declared inconsistently
index ba1e0a51c337f004ae8ce2df9781eb15ae1170c1..77c1ecbf3fc2b750cb1b5aec6d4b1a151eaae4cd 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-05  Mike Frysinger  <vapier@gentoo.org>
+
+       * argv.c (dupargv): Change arg to char * const *.  Update comment.
+       (writeargv, countargv): Likewise.
+       * functions.texi (dupargv, writeargv, countargv): Likewise.
+
 2016-01-05  Mike Frysinger  <vapier@gentoo.org>
 
        * argv.c (dupargv): Replace strlen/xmalloc/strcpy with xstrdup.
index 5c3dd70b0422c77076944d0266c5817c96b284a3..994dd3531c00952f79dbdabf4341cbea85ac22c8 100644 (file)
@@ -49,7 +49,7 @@ Boston, MA 02110-1301, USA.  */
 
 /*
 
-@deftypefn Extension char** dupargv (char **@var{vector})
+@deftypefn Extension char** dupargv (char * const *@var{vector})
 
 Duplicate an argument vector.  Simply scans through @var{vector},
 duplicating each argument until the terminating @code{NULL} is found.
@@ -62,7 +62,7 @@ argument vector.
 */
 
 char **
-dupargv (char **argv)
+dupargv (char * const *argv)
 {
   int argc;
   char **copy;
@@ -279,7 +279,7 @@ char **buildargv (const char *input)
 
 /*
 
-@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file})
+@deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file})
 
 Write each member of ARGV, handling all necessary quoting, to the file
 named by FILE, separated by whitespace.  Return 0 on success, non-zero
@@ -290,7 +290,7 @@ if an error occurred while writing to FILE.
 */
 
 int
-writeargv (char **argv, FILE *f)
+writeargv (char * const *argv, FILE *f)
 {
   int status = 0;
 
@@ -463,7 +463,7 @@ expandargv (int *argcp, char ***argvp)
 
 /*
 
-@deftypefn Extension int countargv (char **@var{argv})
+@deftypefn Extension int countargv (char * const *@var{argv})
 
 Return the number of elements in @var{argv}.
 Returns zero if @var{argv} is NULL.
@@ -473,7 +473,7 @@ Returns zero if @var{argv} is NULL.
 */
 
 int
-countargv (char **argv)
+countargv (char * const *argv)
 {
   int argc;
 
index b5f4e809d063bca7e5c22a997b6001796ea82b75..24dcc373ac044eb1fe736f735f06a1311db65ab4 100644 (file)
@@ -176,7 +176,7 @@ Concatenate zero or more of strings and return the result in freshly
 @end deftypefn
 
 @c argv.c:470
-@deftypefn Extension int countargv (char **@var{argv})
+@deftypefn Extension int countargv (char * const *@var{argv})
 
 Return the number of elements in @var{argv}.
 Returns zero if @var{argv} is NULL.
@@ -213,7 +213,7 @@ make it easy to compose the values of multiple blocks.
 @end deftypefn
 
 @c argv.c:52
-@deftypefn Extension char** dupargv (char **@var{vector})
+@deftypefn Extension char** dupargv (char * const *@var{vector})
 
 Duplicate an argument vector.  Simply scans through @var{vector},
 duplicating each argument until the terminating @code{NULL} is found.
@@ -1915,7 +1915,7 @@ does the return value.  The third argument is unused in @libib{}.
 @end deftypefn
 
 @c argv.c:286
-@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file})
+@deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file})
 
 Write each member of ARGV, handling all necessary quoting, to the file
 named by FILE, separated by whitespace.  Return 0 on success, non-zero
This page took 0.037299 seconds and 4 git commands to generate.