From 1d54a5412ef39590022e6dd4448881f267e96d0b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 9 Jun 2011 17:52:13 +0200 Subject: [PATCH] Work around some clang warnings. This fixes a bunch of warnings of the form command.c:126:2: warning: expression result unused [-Wunused-value] WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime); when compiling with clang. This warning is bogus, because the underlying call to para_printf() can only return failure if the max_size_handler fails, but this handler is never called here because the size of this para_buffer is unlimited. Casting to void makes the warning go away. --- audiod_command.c | 4 ++-- command.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/audiod_command.c b/audiod_command.c index 05059ac0..a54bd82d 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -131,7 +131,7 @@ void stat_client_write_item(int item_num) (sc->flags & SCF_PARSER_FRIENDLY)? &pfpb : &pb; char *msg = stat_item_values[item_num]; if (!b->buf) - WRITE_STATUS_ITEM(b, item_num, "%s\n", + (void)WRITE_STATUS_ITEM(b, item_num, "%s\n", msg? msg : ""); ret = write(fd, b->buf, b->offset); if (ret == b->offset) @@ -334,7 +334,7 @@ int com_stat(int fd, int argc, char **argv) char *item = stat_item_values[i]; if (!((one << i) & mask)) continue; - WRITE_STATUS_ITEM(&b, i, "%s\n", item? item : ""); + (void)WRITE_STATUS_ITEM(&b, i, "%s\n", item? item : ""); } ret = client_write(fd, b.buf); if (ret >= 0) diff --git a/command.c b/command.c index d82bd5d7..69bbbb74 100644 --- a/command.c +++ b/command.c @@ -122,16 +122,22 @@ static char *get_status(struct misc_meta_data *nmmd, int parser_friendly) strftime(mtime, 29, "%b %d %Y", &mtime_tm); } gettimeofday(¤t_time, NULL); - WRITE_STATUS_ITEM(&b, SI_FILE_SIZE, "%zu\n", nmmd->size / 1024); - WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime); - WRITE_STATUS_ITEM(&b, SI_STATUS, "%s\n", status); - WRITE_STATUS_ITEM(&b, SI_STATUS_FLAGS, "%s\n", flags); - WRITE_STATUS_ITEM(&b, SI_OFFSET, "%li\n", offset); - WRITE_STATUS_ITEM(&b, SI_AFS_MODE, "%s\n", mmd->afs_mode_string); - WRITE_STATUS_ITEM(&b, SI_STREAM_START, "%lu.%lu\n", + /* + * The calls to WRITE_STATUS_ITEM() below never fail because + * b->max_size is zero (unlimited), see para_printf(). However, clang + * is not smart enough to prove this and complains nevertheless. + * Casting the return value to void silences solves this. + */ + (void)WRITE_STATUS_ITEM(&b, SI_FILE_SIZE, "%zu\n", nmmd->size / 1024); + (void)WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime); + (void)WRITE_STATUS_ITEM(&b, SI_STATUS, "%s\n", status); + (void)WRITE_STATUS_ITEM(&b, SI_STATUS_FLAGS, "%s\n", flags); + (void)WRITE_STATUS_ITEM(&b, SI_OFFSET, "%li\n", offset); + (void)WRITE_STATUS_ITEM(&b, SI_AFS_MODE, "%s\n", mmd->afs_mode_string); + (void)WRITE_STATUS_ITEM(&b, SI_STREAM_START, "%lu.%lu\n", (long unsigned)nmmd->stream_start.tv_sec, (long unsigned)nmmd->stream_start.tv_usec); - WRITE_STATUS_ITEM(&b, SI_CURRENT_TIME, "%lu.%lu\n", + (void)WRITE_STATUS_ITEM(&b, SI_CURRENT_TIME, "%lu.%lu\n", (long unsigned)current_time.tv_sec, (long unsigned)current_time.tv_usec); free(flags); -- 2.39.5