sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 62bf8f950a47dae97d51cb199fa7e0060c3e59e7
parent 3e05da45dfcf81667f313fdb3bb8a13fb74badd2
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 23 Jan 2015 14:02:14 +0100

fix some warnings

- mp3.c:    mp3close(): return -1 on failure.
- notify.c: missing include <string.h> for strcmp().
- notify.c: int initnotifier():return a value.
- sad.h:    include limits.h for PATH_MAX.
- ignore warning for unused function arguments: (void)arg;
- fix signed/unsigned warnings, use size_t and unsigned int for Format fields.
- remove unused variables.

Diffstat:
Mcmd.c | 12+++++-------
Mdecoder.c | 2+-
Mfifo.c | 4++++
Mmp3.c | 2+-
Mnotify.c | 8+++++---
Moutput.c | 28+++++++++++++---------------
Mplaylist.c | 14+++++++-------
Msad.h | 8+++++---
8 files changed, 41 insertions(+), 37 deletions(-)

diff --git a/cmd.c b/cmd.c @@ -25,13 +25,13 @@ cmdstatus(int fd, char *arg) if (!strncmp(arg, "random", 7)) { r = 1; - dprintf(fd, "random: %d\n", getplaylistmode() & RANDOM == 1); + dprintf(fd, "random: %d\n", (getplaylistmode() & RANDOM) == 1); } else if (!strncmp(arg, "repeat", 7)) { r = 1; - dprintf(fd, "repeat: %d\n", getplaylistmode() & REPEAT == 1); + dprintf(fd, "repeat: %d\n", (getplaylistmode() & REPEAT) == 1); } else if (!strncmp(arg, "single", 7)) { r = 1; - dprintf(fd, "single: %d\n", getplaylistmode() & SINGLE == 1); + dprintf(fd, "single: %d\n", (getplaylistmode() & SINGLE) == 1); } else if (!strncmp(arg, "songid", 7)) { r = 1; s = getcursong(); @@ -255,8 +255,6 @@ cmdstop(int fd, char *arg) static void cmdadd(int fd, char *arg) { - const char *errstr; - if (!arg[0]) { dprintf(fd, "ERR expected file path\n"); return; @@ -444,9 +442,9 @@ docmd(int clifd) static size_t sz; static size_t resid; ssize_t n; - size_t cmdlen; + size_t cmdlen, i; char *new_buf; - int i, c; + int c; /* If no buffer, set it up. */ if (!buf) { diff --git a/decoder.c b/decoder.c @@ -22,7 +22,7 @@ Decoder * matchdecoder(const char *name) { char *ext; - int i; + size_t i; ext = strrchr(name, '.'); if (!ext) diff --git a/fifo.c b/fifo.c @@ -15,12 +15,16 @@ static int fifofd = -1; static int fifovol(int vol) { + (void)vol; + return 0; } static int fifoopen(Format *fmt) { + (void)fmt; + unlink("/tmp/sad-fifo"); if (mkfifo("/tmp/sad-fifo", 0644) < 0) { warn("mkfifo /tmp/sad-fifo"); diff --git a/mp3.c b/mp3.c @@ -88,7 +88,7 @@ mp3close(void) mpg123_exit(); } hdl = NULL; - return 0; + return r; } Decoder mp3decoder = { diff --git a/notify.c b/notify.c @@ -4,6 +4,7 @@ #include <limits.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "queue.h" #include "sad.h" @@ -24,13 +25,14 @@ int initnotifier(void) { TAILQ_INIT(&subscribers); + return 0; } int addsubscriber(int clifd, int event) { struct subscriber *s; - int i; + size_t i; for (i = 0; i < LEN(Eventmap); i++) if (Eventmap[i].event == event) @@ -57,7 +59,7 @@ addsubscriber(int clifd, int event) int addsubscribername(int clifd, const char *name) { - int i; + size_t i; for (i = 0; i < LEN(Eventmap); i++) if (!strcmp(Eventmap[i].name, name)) @@ -69,7 +71,7 @@ int notify(int event) { struct subscriber *s, *tmp; - int i; + size_t i; for (i = 0; i < LEN(Eventmap); i++) if (Eventmap[i].event == event) diff --git a/output.c b/output.c @@ -32,7 +32,7 @@ static Outputdesc outputdescs[LEN(outputcfgs)]; int initoutputs(void) { - int i; + size_t i; for (i = 0; i < LEN(outputcfgs); i++) { outputdescs[i].name = outputcfgs[i].name; @@ -50,7 +50,6 @@ initresampler(Format *fmt, Outputdesc *desc) { soxr_quality_spec_t quality; soxr_io_spec_t iospec; - int i; quality = soxr_quality_spec(RESAMPLEQUALITY, 0); iospec = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I); @@ -67,7 +66,6 @@ initresampler(Format *fmt, Outputdesc *desc) warnx("soxr_create: failed to initialize resampler"); return -1; } - return 0; } @@ -75,7 +73,8 @@ int initresamplers(Format *fmt) { Outputdesc *desc; - int i, r = 0; + size_t i; + int r = 0; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -90,8 +89,6 @@ initresamplers(Format *fmt) static int openoutput(Outputdesc *desc) { - int i; - if (desc->active) return 0; @@ -109,7 +106,8 @@ int openoutputs(void) { Outputdesc *desc; - int i, r = 0; + size_t i; + int r = 0; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -124,8 +122,6 @@ openoutputs(void) static int closeoutput(Outputdesc *desc) { - int i; - if (!desc->active) return 0; @@ -138,7 +134,8 @@ int closeoutputs(void) { Outputdesc *desc; - int i, r = 0; + size_t i; + int r = 0; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -160,7 +157,6 @@ playoutput(Format *fmt, Outputdesc *desc, void *buf, size_t nbytes) void *inbuf; void *outbuf; float ratio; - int i; if (!desc->active) return 0; @@ -225,7 +221,8 @@ int playoutputs(Format *fmt, void *inbuf, size_t nbytes) { Outputdesc *desc; - int i, r = 0; + size_t i; + int r = 0; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -241,7 +238,8 @@ int setvol(int vol) { Outputdesc *desc; - int i, r = 0; + size_t i; + int r = 0; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -257,7 +255,7 @@ int enableoutput(const char *name) { Outputdesc *desc; - int i, r; + size_t i; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; @@ -278,7 +276,7 @@ int disableoutput(const char *name) { Outputdesc *desc; - int i; + size_t i; for (i = 0; i < LEN(outputdescs); i++) { desc = &outputdescs[i]; diff --git a/playlist.c b/playlist.c @@ -53,7 +53,7 @@ int rmplaylist(int id) { Song *s; - int i; + size_t i; for (i = 0; i < playlist.nsongs; i++) { s = playlist.songs[i]; @@ -76,7 +76,7 @@ Song * findsong(const char *path) { Song *s; - int i; + size_t i; for (i = 0; i < playlist.nsongs; i++) { s = playlist.songs[i]; @@ -90,7 +90,7 @@ Song * findsongid(int id) { Song *s; - int i; + size_t i; for (i = 0; i < playlist.nsongs; i++) { s = playlist.songs[i]; @@ -104,7 +104,7 @@ Song * getnextsong(void) { Song *s, *cur; - int i; + size_t i; cur = playlist.cursong; for (i = 0; i < playlist.nsongs; i++) { @@ -125,7 +125,7 @@ Song * getprevsong(void) { Song *s, *cur; - int i; + size_t i; cur = playlist.cursong; for (i = 0; i < playlist.nsongs; i++) { @@ -158,7 +158,7 @@ void dumpplaylist(int fd) { Song *s; - int i; + size_t i; for (i = 0; i < playlist.nsongs; i++) { s = playlist.songs[i]; @@ -169,7 +169,7 @@ dumpplaylist(int fd) void clearplaylist(void) { - int i; + size_t i; for (i = 0; i < playlist.nsongs; i++) { free(playlist.songs[i]); diff --git a/sad.h b/sad.h @@ -2,6 +2,8 @@ #include "compat.h" #endif +#include <limits.h> + #define LEN(x) (sizeof (x) / sizeof *(x)) #define PROTOCOLVERSION "0.0" @@ -28,9 +30,9 @@ enum { }; typedef struct { - int bits; - int rate; - int channels; + unsigned int bits; + unsigned int rate; + unsigned int channels; } Format; typedef struct {