From cc858ad54f6f5d5d35ea6473b92aad9186c8e363 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 25 Jun 2012 20:59:17 +0200 Subject: [PATCH] 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. --- select.c | 4 ++-- string.c | 2 +- string.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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); -- 2.39.5