Merge branch 't/clang'
authorAndre Noll <maan@systemlinux.org>
Thu, 21 Jul 2011 20:40:40 +0000 (22:40 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 21 Jul 2011 20:44:27 +0000 (22:44 +0200)
Makefile.in
NEWS
audiod_command.c
command.c
net.c

index 7e6287e..5016b06 100644 (file)
@@ -19,9 +19,9 @@ codename := nested assignment
 
 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
 
-DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
+DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
 DEBUG_CPPFLAGS += -Wredundant-decls
-DEBUG_CPPFLAGS += -Wall
+DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
 DEBUG_CPPFLAGS += -Wformat-security
 DEBUG_CPPFLAGS += -Wmissing-format-attribute
 # produces false positives
diff --git a/NEWS b/NEWS
index 57ef197..c6c2e4d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@
          writers is now treated as a regular expression. This allows
          to replace 5 lines in the config file (one for each audio
          format) by one single line. See the manual for details.
+       - Compiles cleanly also with llvm/clang.
 
 --------------------------------------
 0.4.7 (2011-06-01) "infinite rollback"
index 05059ac..0f7aa7e 100644 (file)
@@ -120,24 +120,22 @@ void stat_client_write_item(int item_num)
        struct para_buffer pb = {.flags = 0};
        struct para_buffer pfpb = {.flags = PBF_SIZE_PREFIX};
        const uint64_t one = 1;
+       char *msg = stat_item_values[item_num];
+       struct para_buffer *b;
 
        list_for_each_entry_safe(sc, tmp, &client_list, node) {
                int fd = sc->fd, ret;
 
                if (!((one << item_num) & sc->item_mask))
                        continue;
-               if (write_ok(fd) > 0) {
-                       struct para_buffer *b =
-                               (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",
-                                       msg? msg : "");
-                       ret = write(fd, b->buf, b->offset);
-                       if (ret == b->offset)
-                               continue;
-               }
-               /* write error or fd not ready for writing */
+               b = (sc->flags & SCF_PARSER_FRIENDLY)? &pfpb : &pb;
+               if (!b->buf)
+                       (void)WRITE_STATUS_ITEM(b, item_num, "%s\n",
+                               msg? msg : "");
+               ret = write(fd, b->buf, b->offset);
+               if (ret == b->offset)
+                       continue;
+               /* write error or short write */
                close(fd);
                num_clients--;
                PARA_INFO_LOG("deleting client on fd %d\n", fd);
@@ -147,8 +145,6 @@ void stat_client_write_item(int item_num)
        }
        free(pb.buf);
        free(pfpb.buf);
-//     if (num_clients)
-//             PARA_DEBUG_LOG("%d client(s)\n", num_clients);
 }
 
 /**
@@ -307,6 +303,9 @@ int com_stat(int fd, int argc, char **argv)
        const uint64_t one = 1;
        struct para_buffer b = {.flags = 0};
 
+       ret = mark_fd_nonblocking(fd);
+       if (ret < 0)
+               return ret;
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
                if (arg[0] != '-')
@@ -334,7 +333,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)
index d82bd5d..69bbbb7 100644 (file)
--- 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(&current_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);
diff --git a/net.c b/net.c
index 2f720b1..ae596e5 100644 (file)
--- a/net.c
+++ b/net.c
@@ -607,8 +607,7 @@ int generic_max_transport_msg_size(int sockfd)
  * \sa getsockname(2), getpeername(2), parse_url(), getnameinfo(3),
  * services(5), nsswitch.conf(5).
  */
-static char *__get_sock_name(int fd, int (*getname)(int, struct sockaddr*,
-               socklen_t *))
+static char *__get_sock_name(int fd, typeof(getsockname) getname)
 {
        struct sockaddr_storage ss;
        const struct sockaddr *sa;