diff options
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 58 | ||||
-rw-r--r-- | src/command.h | 16 | ||||
-rw-r--r-- | src/directory.c | 10 | ||||
-rw-r--r-- | src/gcc.h | 10 | ||||
-rw-r--r-- | src/player.c | 2 | ||||
-rw-r--r-- | src/playlist.c | 7 | ||||
-rw-r--r-- | src/stats.c | 4 | ||||
-rw-r--r-- | src/volume.c | 8 |
8 files changed, 58 insertions, 57 deletions
diff --git a/src/command.c b/src/command.c index b56956e74..b43882178 100644 --- a/src/command.c +++ b/src/command.c @@ -31,6 +31,7 @@ #include "dbUtils.h" #include "tag.h" +#include <stdarg.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -182,7 +183,7 @@ static int handlePlay(int fd, int *permission, int argc, song = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } } @@ -199,7 +200,7 @@ static int handlePlayId(int fd, int *permission, int argc, id = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } } @@ -284,7 +285,7 @@ static int commandStatus(int fd, int *permission, int argc, fdprintf(fd, "%s: %i:%i\n", COMMAND_STATUS_TIME, getPlayerElapsedTime(), getPlayerTotalTime()); fdprintf(fd, "%s: %li\n", COMMAND_STATUS_BITRATE, - getPlayerBitRate(), getPlayerTotalTime()); + getPlayerBitRate()); fdprintf(fd, "%s: %u:%i:%i\n", COMMAND_STATUS_AUDIO, getPlayerSampleRate(), getPlayerBits(), getPlayerChannels()); @@ -341,7 +342,7 @@ static int handleDelete(int fd, int *permission, int argc, song = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } return deleteFromPlaylist(fd, song); @@ -356,7 +357,7 @@ static int handleDeleteId(int fd, int *permission, int argc, id = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } return deleteFromPlaylistById(fd, id); @@ -434,8 +435,7 @@ static int handlePlaylistChanges(int fd, int *permission, version = strtoul(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need a positive integer", - NULL); + commandError(fd, ACK_ERROR_ARG, "need a positive integer"); return -1; } return playlistChanges(fd, version); @@ -449,8 +449,7 @@ static int handlePlaylistChangesPosId(int fd, int *permission, version = strtoul(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need a positive integer", - NULL); + commandError(fd, ACK_ERROR_ARG, "need a positive integer"); return -1; } return playlistChangesPosId(fd, version); @@ -466,7 +465,7 @@ static int handlePlaylistInfo(int fd, int *permission, song = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } } @@ -483,7 +482,7 @@ static int handlePlaylistId(int fd, int *permission, id = strtol(argv[1], &test, 10); if (*test != '\0') { commandError(fd, ACK_ERROR_ARG, - "need a positive integer", NULL); + "need a positive integer"); return -1; } } @@ -501,7 +500,7 @@ static int handleFind(int fd, int *permission, int argc, &items); if (numItems <= 0) { - commandError(fd, ACK_ERROR_ARG, "incorrect arguments", NULL); + commandError(fd, ACK_ERROR_ARG, "incorrect arguments"); return -1; } @@ -523,7 +522,7 @@ static int handleSearch(int fd, int *permission, int argc, &items); if (numItems <= 0) { - commandError(fd, ACK_ERROR_ARG, "incorrect arguments", NULL); + commandError(fd, ACK_ERROR_ARG, "incorrect arguments"); return -1; } @@ -609,7 +608,7 @@ static int handleVolume(int fd, int *permission, int argc, change = strtol(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need an integer", NULL); + commandError(fd, ACK_ERROR_ARG, "need an integer"); return -1; } return changeVolumeLevel(fd, change, 1); @@ -623,7 +622,7 @@ static int handleSetVol(int fd, int *permission, int argc, level = strtol(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need an integer", NULL); + commandError(fd, ACK_ERROR_ARG, "need an integer"); return -1; } return changeVolumeLevel(fd, level, 0); @@ -637,7 +636,7 @@ static int handleRepeat(int fd, int *permission, int argc, status = strtol(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need an integer", NULL); + commandError(fd, ACK_ERROR_ARG, "need an integer"); return -1; } return setPlaylistRepeatStatus(fd, status); @@ -651,7 +650,7 @@ static int handleRandom(int fd, int *permission, int argc, status = strtol(argv[1], &test, 10); if (*test != '\0') { - commandError(fd, ACK_ERROR_ARG, "need an integer", NULL); + commandError(fd, ACK_ERROR_ARG, "need an integer"); return -1; } return setPlaylistRandomStatus(fd, status); @@ -703,7 +702,7 @@ static int handleList(int fd, int *permission, int argc, if (numConditionals < 0) { commandError(fd, ACK_ERROR_ARG, - "not able to parse args", NULL); + "not able to parse args"); return -1; } } @@ -868,8 +867,7 @@ static int handlePassword(int fd, int *permission, int argc, char *argv[]) { if (getPermissionFromPassword(argv[1], permission) < 0) { - commandError(fd, ACK_ERROR_PASSWORD, "incorrect password", - NULL); + commandError(fd, ACK_ERROR_PASSWORD, "incorrect password"); return -1; } @@ -1212,3 +1210,23 @@ int processCommand(int fd, int *permission, char *commandString) { return processCommandInternal(fd, permission, commandString, NULL); } + +mpd_fprintf_ void commandError(int fd, int error, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + + if (current_command) { + fdprintf(fd, "ACK [%i@%i] {%s} ", + (int)error, command_listNum, current_command); + current_command = NULL; + } else + fdprintf(STDERR_FILENO, "ACK [%i@%i] ", + (int)error, command_listNum); + + vfdprintf(fd, fmt, args); + va_end(args); + fdprintf(fd,"\n"); +} + + diff --git a/src/command.h b/src/command.h index cab6562db..fdb1e0869 100644 --- a/src/command.h +++ b/src/command.h @@ -48,18 +48,6 @@ void finishCommands(); #define commandSuccess(fd) fdprintf(fd, "OK\n") -#define commandError(fd, error, format, ... ) do \ - {\ - if (current_command) { \ - fdprintf(fd, "ACK [%i@%i] {%s} " format "\n", \ - (int)error, command_listNum, \ - current_command, __VA_ARGS__); \ - current_command = NULL; \ - } \ - else { \ - fdprintf(STDERR_FILENO, "ACK [%i@%i] " format "\n", \ - (int)error, command_listNum, \ - __VA_ARGS__); \ - } \ - } while (0) +mpd_fprintf_ void commandError(int fd, int error, const char *fmt, ...); + #endif diff --git a/src/directory.c b/src/directory.c index 0bf2b6453..fe98ec67e 100644 --- a/src/directory.c +++ b/src/directory.c @@ -162,8 +162,7 @@ void readDirectoryDBIfUpdateIsFinished() int updateInit(int fd, List * pathList) { if (directory_updatePid > 0) { - commandError(fd, ACK_ERROR_UPDATE_ALREADY, "already updating", - NULL); + commandError(fd, ACK_ERROR_UPDATE_ALREADY, "already updating"); return -1; } @@ -217,7 +216,7 @@ int updateInit(int fd, List * pathList) unblockSignals(); ERROR("updateInit: Problems forking()'ing\n"); commandError(fd, ACK_ERROR_SYSTEM, - "problems trying to update", NULL); + "problems trying to update"); directory_updatePid = 0; return -1; } @@ -891,8 +890,7 @@ int printDirectoryInfo(int fd, char *name) Directory *directory; if ((directory = getDirectory(name)) == NULL) { - commandError(fd, ACK_ERROR_NO_EXIST, "directory not found", - NULL); + commandError(fd, ACK_ERROR_NO_EXIST, "directory not found"); return -1; } @@ -1288,7 +1286,7 @@ int traverseAllIn(int fd, char *name, return forEachSong(fd, song, data); } commandError(fd, ACK_ERROR_NO_EXIST, - "directory or file not found", NULL); + "directory or file not found"); return -1; } @@ -8,7 +8,7 @@ */ /* disabled (0) until I fix all the warnings :) */ -#if (0 && __GNUC__ >= 3) +#if __GNUC__ >= 3 # define mpd_const __attribute__ ((const)) # define mpd_deprecated __attribute__ ((deprecated)) # define mpd_malloc __attribute__ ((malloc)) @@ -25,8 +25,8 @@ # define mpd_used __attribute__ ((used)) /* # define inline inline __attribute__ ((always_inline)) */ # define mpd_noinline __attribute__ ((noinline)) -# define likely(x) __builtin_expect (!!(x), 1) -# define unlikely(x) __builtin_expect (!!(x), 0) +# define mpd_likely(x) __builtin_expect (!!(x), 1) +# define mpd_unlikely(x) __builtin_expect (!!(x), 0) #else # define mpd_const # define mpd_deprecated @@ -43,8 +43,8 @@ # define mpd_used /* # define inline */ # define mpd_noinline -# define likely(x) (x) -# define unlikely(x) (x) +# define mpd_likely(x) (x) +# define mpd_unlikely(x) (x) #endif #endif /* MPD_GCC_H */ diff --git a/src/player.c b/src/player.c index 5ebf22f79..2ffe66e76 100644 --- a/src/player.c +++ b/src/player.c @@ -396,7 +396,7 @@ int playerSeek(int fd, Song * song, float time) if (pc->state == PLAYER_STATE_STOP) { commandError(fd, ACK_ERROR_PLAYER_SYNC, - "player not currently playing", NULL); + "player not currently playing"); return -1; } diff --git a/src/playlist.c b/src/playlist.c index 288848fb0..374de976b 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -671,7 +671,7 @@ int addSongToPlaylist(int fd, Song * song, int printId) if (playlist.length == playlist_max_length) { commandError(fd, ACK_ERROR_PLAYLIST_MAX, - "playlist is at the max size", NULL); + "playlist is at the max size"); return -1; } @@ -1360,7 +1360,7 @@ int deletePlaylist(int fd, char *utf8file) if (unlink(actualFile) < 0) { commandError(fd, ACK_ERROR_SYSTEM, - "problems deleting file", NULL); + "problems deleting file"); return -1; } @@ -1407,8 +1407,7 @@ int savePlaylist(int fd, char *utf8file) while (!(fileP = fopen(actualFile, "w")) && errno == EINTR) ; if (fileP == NULL) { - commandError(fd, ACK_ERROR_SYSTEM, "problems opening file", - NULL); + commandError(fd, ACK_ERROR_SYSTEM, "problems opening file"); return -1; } diff --git a/src/stats.c b/src/stats.c index 32a7804c1..d4b69953b 100644 --- a/src/stats.c +++ b/src/stats.c @@ -36,8 +36,8 @@ void initStats(void) int printStats(int fd) { - fdprintf(fd, "artists: %li\n", getNumberOfTagItems(TAG_ITEM_ARTIST)); - fdprintf(fd, "albums: %li\n", getNumberOfTagItems(TAG_ITEM_ALBUM)); + fdprintf(fd, "artists: %i\n", getNumberOfTagItems(TAG_ITEM_ARTIST)); + fdprintf(fd, "albums: %i\n", getNumberOfTagItems(TAG_ITEM_ALBUM)); fdprintf(fd, "songs: %i\n", stats.numberOfSongs); fdprintf(fd, "uptime: %li\n", time(NULL) - stats.daemonStart); fdprintf(fd, "playtime: %li\n", diff --git a/src/volume.c b/src/volume.c index adff103ad..7d4fce584 100644 --- a/src/volume.c +++ b/src/volume.c @@ -178,7 +178,7 @@ static int changeOssVolumeLevel(int fd, int change, int rel) if (rel) { if ((current = getOssVolumeLevel()) < 0) { commandError(fd, ACK_ERROR_SYSTEM, - "problem getting current volume", NULL); + "problem getting current volume"); return -1; } @@ -198,8 +198,7 @@ static int changeOssVolumeLevel(int fd, int change, int rel) if (ioctl(volume_ossFd, MIXER_WRITE(volume_ossControl), &level) < 0) { closeOssMixer(); - commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume", - NULL); + commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume"); return -1; } @@ -361,8 +360,7 @@ static int changeAlsaVolumeLevel(int fd, int change, int rel) if ((err = snd_mixer_selem_set_playback_volume_all(volume_alsaElem, level)) < 0) { - commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume", - NULL); + commandError(fd, ACK_ERROR_SYSTEM, "problems setting volume"); WARNING("problems setting alsa volume: %s\n", snd_strerror(err)); closeAlsaMixer(); |