]> git.tuebingen.mpg.de Git - adu.git/commitdiff
split_args(): Do not insist on checking the return value.
authorAndre Noll <maan@systemlinux.org>
Mon, 25 Jun 2012 18:59:17 +0000 (20:59 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 25 Jun 2012 18:59:17 +0000 (20:59 +0200)
Currently, split_args() of string.c has the __must_check attribute
which instructs gcc to warn whenever the return value of this function
is ignored by the caller.

However, since the returned array is NULL terminated anyway, there
are situations the return value my safely be ignored, for example if
the returned array is passed to execvp(), which does not receive a
length argument.

This patch removes the __must_check attribute and fixes a "set but
not used" warning on newer gcc versions.

select.c
string.c
string.h

index 6ef289152c42a77f6f14acb8042bcd345463b5f2..d052dfb953bf0f1f1159716107ed467e87436925 100644 (file)
--- a/select.c
+++ b/select.c
@@ -818,7 +818,7 @@ static int print_statistics(struct format_info *fi)
 
 static int open_pipe(char *path)
 {
-       int p[2], ret, argc;
+       int p[2], ret;
        char **argv;
 
        ret = pipe(p);
@@ -839,7 +839,7 @@ static int open_pipe(char *path)
        if (p[0] != STDIN_FILENO)
                dup2(p[0], STDIN_FILENO);
        DEBUG_LOG("executing %s\n", path);
-       argc = split_args(path, &argv, " \t");
+       split_args(path, &argv, " \t");
        execvp(argv[0], argv);
        ERROR_LOG("error executing %s: %s\n", path,
                adu_strerror(ERRNO_TO_ERROR(errno)));
index 13555550efb6e1e567f66ca6f03158b79645ed7e..b089b785f96a8463bf850b408791987378e69e93 100644 (file)
--- a/string.c
+++ b/string.c
@@ -209,7 +209,7 @@ __must_check int atoi64(const char *str, int64_t *result)
  *
  * \return The number of substrings found in \a args.
  */
-__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
+unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
 {
        char *p = args;
        char **argv;
index 68ad7462e2f5fea0dd43642cbaf00825717e41ed..256747a345d62812a6fed5ca7de8270ebe67d85a 100644 (file)
--- a/string.h
+++ b/string.h
@@ -14,6 +14,6 @@ __must_check __malloc char *adu_strcat(char *a, const char *b);
 __must_check __malloc __printf_1_2 char *make_message(const char *fmt, ...);
 __must_check __malloc char *absolute_path(const char *path);
 __must_check int atoi64(const char *str, int64_t *result);
-__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
+unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
 int create_argv(const char *line, char ***result);
 void free_argv(char **argv);