From: Andre Noll Date: Mon, 25 Jun 2012 18:59:17 +0000 (+0200) Subject: split_args(): Do not insist on checking the return value. X-Git-Tag: v1.0.0~22 X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=cc858ad54f6f5d5d35ea6473b92aad9186c8e363 split_args(): Do not insist on checking the return value. 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. --- diff --git a/select.c b/select.c index 6ef2891..d052dfb 100644 --- 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))); diff --git a/string.c b/string.c index 1355555..b089b78 100644 --- 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; diff --git a/string.h b/string.h index 68ad746..256747a 100644 --- 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);