Commit a383f451 authored by Max Kellermann's avatar Max Kellermann

enable -Wpointer-arith, -Wstrict-prototypes

Also enable -Wunused-parameter - this forces us to add the gcc "unused" attribute to a lot of parameters (mostly library callback functions), but it's worth it during code refactorizations.
parent d05c8fd4
...@@ -26,11 +26,12 @@ if test x$GCC = xyes ...@@ -26,11 +26,12 @@ if test x$GCC = xyes
then then
MPD_CHECK_FLAG([-Wall]) MPD_CHECK_FLAG([-Wall])
MPD_CHECK_FLAG([-Wextra]) MPD_CHECK_FLAG([-Wextra])
MPD_CHECK_FLAG([-Wno-unused-parameter])
MPD_CHECK_FLAG([-Wno-deprecated-declarations]) MPD_CHECK_FLAG([-Wno-deprecated-declarations])
MPD_CHECK_FLAG([-Wmissing-prototypes]) MPD_CHECK_FLAG([-Wmissing-prototypes])
MPD_CHECK_FLAG([-Wdeclaration-after-statement]) MPD_CHECK_FLAG([-Wdeclaration-after-statement])
MPD_CHECK_FLAG([-Wshadow]) MPD_CHECK_FLAG([-Wshadow])
MPD_CHECK_FLAG([-Wpointer-arith])
MPD_CHECK_FLAG([-Wstrict-prototypes])
fi fi
if test -z "$prefix" || test "x$prefix" = xNONE; then if test -z "$prefix" || test "x$prefix" = xNONE; then
......
...@@ -158,7 +158,7 @@ static void audioOutputAo_finishDriver(AudioOutput * audioOutput) ...@@ -158,7 +158,7 @@ static void audioOutputAo_finishDriver(AudioOutput * audioOutput)
ao_shutdown(); ao_shutdown();
} }
static void audioOutputAo_dropBufferedAudio(AudioOutput * audioOutput) static void audioOutputAo_dropBufferedAudio(mpd_unused AudioOutput * audioOutput)
{ {
/* not supported by libao */ /* not supported by libao */
} }
......
...@@ -102,7 +102,7 @@ static void jack_finishDriver(AudioOutput *audioOutput) ...@@ -102,7 +102,7 @@ static void jack_finishDriver(AudioOutput *audioOutput)
freeJackData(audioOutput); freeJackData(audioOutput);
} }
static int srate(jack_nframes_t rate, void *data) static int srate(mpd_unused jack_nframes_t rate, void *data)
{ {
JackData *jd = (JackData *) ((AudioOutput*) data)->data; JackData *jd = (JackData *) ((AudioOutput*) data)->data;
AudioFormat *audioFormat = &(((AudioOutput*) data)->outAudioFormat); AudioFormat *audioFormat = &(((AudioOutput*) data)->outAudioFormat);
...@@ -366,7 +366,7 @@ static void jack_closeDevice(AudioOutput * audioOutput) ...@@ -366,7 +366,7 @@ static void jack_closeDevice(AudioOutput * audioOutput)
DEBUG("jack_closeDevice (pid=%d)\n", getpid()); DEBUG("jack_closeDevice (pid=%d)\n", getpid());
} }
static void jack_dropBufferedAudio (AudioOutput * audioOutput) static void jack_dropBufferedAudio (mpd_unused AudioOutput * audioOutput)
{ {
} }
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#include "../audioOutput.h" #include "../audioOutput.h"
#include "../timer.h" #include "../timer.h"
static int null_initDriver(AudioOutput *audioOutput, ConfigParam *param) static int null_initDriver(AudioOutput *audioOutput,
mpd_unused ConfigParam *param)
{ {
audioOutput->data = NULL; audioOutput->data = NULL;
return 0; return 0;
...@@ -43,7 +44,7 @@ static void null_closeDevice(AudioOutput *audioOutput) ...@@ -43,7 +44,7 @@ static void null_closeDevice(AudioOutput *audioOutput)
} }
static int null_playAudio(AudioOutput *audioOutput, static int null_playAudio(AudioOutput *audioOutput,
const char *playChunk, size_t size) mpd_unused const char *playChunk, size_t size)
{ {
Timer *timer = audioOutput->data; Timer *timer = audioOutput->data;
......
...@@ -334,7 +334,8 @@ static int oss_testDefault(void) ...@@ -334,7 +334,8 @@ static int oss_testDefault(void)
return -1; return -1;
} }
static int oss_open_default(AudioOutput *ao, ConfigParam *param, OssData *od) static int oss_open_default(mpd_unused AudioOutput *ao, ConfigParam *param,
OssData *od)
{ {
int i; int i;
int err[ARRAY_SIZE(default_devices)]; int err[ARRAY_SIZE(default_devices)];
......
...@@ -45,7 +45,8 @@ typedef struct _SearchStats { ...@@ -45,7 +45,8 @@ typedef struct _SearchStats {
unsigned long playTime; unsigned long playTime;
} SearchStats; } SearchStats;
static int countSongsInDirectory(int fd, Directory * directory, void *data) static int countSongsInDirectory(mpd_unused int fd, Directory * directory,
void *data)
{ {
int *count = (int *)data; int *count = (int *)data;
...@@ -55,7 +56,7 @@ static int countSongsInDirectory(int fd, Directory * directory, void *data) ...@@ -55,7 +56,7 @@ static int countSongsInDirectory(int fd, Directory * directory, void *data)
} }
static int printDirectoryInDirectory(int fd, Directory * directory, static int printDirectoryInDirectory(int fd, Directory * directory,
void *data) mpd_unused void *data)
{ {
if (directory->path) { if (directory->path) {
fdprintf(fd, "directory: %s\n", getDirectoryPath(directory)); fdprintf(fd, "directory: %s\n", getDirectoryPath(directory));
...@@ -63,7 +64,7 @@ static int printDirectoryInDirectory(int fd, Directory * directory, ...@@ -63,7 +64,7 @@ static int printDirectoryInDirectory(int fd, Directory * directory,
return 0; return 0;
} }
static int printSongInDirectory(int fd, Song * song, void *data) static int printSongInDirectory(int fd, Song * song, mpd_unused void *data)
{ {
printSongUrl(fd, song); printSongUrl(fd, song);
return 0; return 0;
...@@ -133,7 +134,7 @@ static void printSearchStats(int fd, SearchStats *stats) ...@@ -133,7 +134,7 @@ static void printSearchStats(int fd, SearchStats *stats)
fdprintf(fd, "playtime: %li\n", stats->playTime); fdprintf(fd, "playtime: %li\n", stats->playTime);
} }
static int searchStatsInDirectory(int fd, Song * song, void *data) static int searchStatsInDirectory(mpd_unused int fd, Song * song, void *data)
{ {
SearchStats *stats = data; SearchStats *stats = data;
...@@ -171,7 +172,8 @@ int printAllIn(int fd, char *name) ...@@ -171,7 +172,8 @@ int printAllIn(int fd, char *name)
printDirectoryInDirectory, NULL); printDirectoryInDirectory, NULL);
} }
static int directoryAddSongToPlaylist(int fd, Song * song, void *data) static int directoryAddSongToPlaylist(int fd, Song * song,
mpd_unused void *data)
{ {
return addSongToPlaylist(fd, song, NULL); return addSongToPlaylist(fd, song, NULL);
} }
...@@ -194,12 +196,12 @@ int addAllInToStoredPlaylist(int fd, char *name, char *utf8file) ...@@ -194,12 +196,12 @@ int addAllInToStoredPlaylist(int fd, char *name, char *utf8file)
(void *)utf8file); (void *)utf8file);
} }
static int directoryPrintSongInfo(int fd, Song * song, void *data) static int directoryPrintSongInfo(int fd, Song * song, mpd_unused void *data)
{ {
return printSongInfo(fd, song); return printSongInfo(fd, song);
} }
static int sumSongTime(int fd, Song * song, void *data) static int sumSongTime(mpd_unused int fd, Song * song, void *data)
{ {
unsigned long *sum_time = (unsigned long *)data; unsigned long *sum_time = (unsigned long *)data;
...@@ -307,7 +309,8 @@ int listAllUniqueTags(int fd, int type, int numConditionals, ...@@ -307,7 +309,8 @@ int listAllUniqueTags(int fd, int type, int numConditionals,
return ret; return ret;
} }
static int sumSavedFilenameMemoryInDirectory(int fd, Directory * dir, static int sumSavedFilenameMemoryInDirectory(mpd_unused int fd,
Directory * dir,
void *data) void *data)
{ {
int *sum = data; int *sum = data;
...@@ -321,7 +324,8 @@ static int sumSavedFilenameMemoryInDirectory(int fd, Directory * dir, ...@@ -321,7 +324,8 @@ static int sumSavedFilenameMemoryInDirectory(int fd, Directory * dir,
return 0; return 0;
} }
static int sumSavedFilenameMemoryInSong(int fd, Song * song, void *data) static int sumSavedFilenameMemoryInSong(mpd_unused int fd, Song * song,
void *data)
{ {
int *sum = data; int *sum = data;
......
...@@ -181,7 +181,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, ...@@ -181,7 +181,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
void flac_error_common_cb(const char *plugin, void flac_error_common_cb(const char *plugin,
const FLAC__StreamDecoderErrorStatus status, const FLAC__StreamDecoderErrorStatus status,
FlacData * data) mpd_unused FlacData * data)
{ {
if (dc.stop) if (dc.stop)
return; return;
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/* this code was based on flac123, from flac-tools */ /* this code was based on flac123, from flac-tools */
static flac_read_status flacRead(const flac_decoder * flacDec, static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
FLAC__byte buf[], FLAC__byte buf[],
flac_read_status_size_t *bytes, flac_read_status_size_t *bytes,
void *fdata) void *fdata)
...@@ -57,7 +57,7 @@ static flac_read_status flacRead(const flac_decoder * flacDec, ...@@ -57,7 +57,7 @@ static flac_read_status flacRead(const flac_decoder * flacDec,
return flac_read_status_continue; return flac_read_status_continue;
} }
static flac_seek_status flacSeek(const flac_decoder * flacDec, static flac_seek_status flacSeek(mpd_unused const flac_decoder * flacDec,
FLAC__uint64 offset, FLAC__uint64 offset,
void *fdata) void *fdata)
{ {
...@@ -70,7 +70,7 @@ static flac_seek_status flacSeek(const flac_decoder * flacDec, ...@@ -70,7 +70,7 @@ static flac_seek_status flacSeek(const flac_decoder * flacDec,
return flac_seek_status_ok; return flac_seek_status_ok;
} }
static flac_tell_status flacTell(const flac_decoder * flacDec, static flac_tell_status flacTell(mpd_unused const flac_decoder * flacDec,
FLAC__uint64 * offset, FLAC__uint64 * offset,
void *fdata) void *fdata)
{ {
...@@ -81,7 +81,7 @@ static flac_tell_status flacTell(const flac_decoder * flacDec, ...@@ -81,7 +81,7 @@ static flac_tell_status flacTell(const flac_decoder * flacDec,
return flac_tell_status_ok; return flac_tell_status_ok;
} }
static flac_length_status flacLength(const flac_decoder * flacDec, static flac_length_status flacLength(mpd_unused const flac_decoder * flacDec,
FLAC__uint64 * length, FLAC__uint64 * length,
void *fdata) void *fdata)
{ {
...@@ -92,7 +92,7 @@ static flac_length_status flacLength(const flac_decoder * flacDec, ...@@ -92,7 +92,7 @@ static flac_length_status flacLength(const flac_decoder * flacDec,
return flac_length_status_ok; return flac_length_status_ok;
} }
static FLAC__bool flacEOF(const flac_decoder * flacDec, void *fdata) static FLAC__bool flacEOF(mpd_unused const flac_decoder * flacDec, void *fdata)
{ {
FlacData *data = (FlacData *) fdata; FlacData *data = (FlacData *) fdata;
...@@ -101,7 +101,7 @@ static FLAC__bool flacEOF(const flac_decoder * flacDec, void *fdata) ...@@ -101,7 +101,7 @@ static FLAC__bool flacEOF(const flac_decoder * flacDec, void *fdata)
return false; return false;
} }
static void flacError(const flac_decoder *dec, static void flacError(mpd_unused const flac_decoder *dec,
FLAC__StreamDecoderErrorStatus status, void *fdata) FLAC__StreamDecoderErrorStatus status, void *fdata)
{ {
flac_error_common_cb("flac", status, (FlacData *) fdata); flac_error_common_cb("flac", status, (FlacData *) fdata);
...@@ -199,7 +199,7 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state) ...@@ -199,7 +199,7 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state)
} }
#endif /* FLAC_API_VERSION_CURRENT >= 7 */ #endif /* FLAC_API_VERSION_CURRENT >= 7 */
static void flacMetadata(const flac_decoder * dec, static void flacMetadata(mpd_unused const flac_decoder * dec,
const FLAC__StreamMetadata * block, void *vdata) const FLAC__StreamMetadata * block, void *vdata)
{ {
flac_metadata_common_cb(block, (FlacData *) vdata); flac_metadata_common_cb(block, (FlacData *) vdata);
......
...@@ -86,7 +86,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence) ...@@ -86,7 +86,7 @@ static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence)
} }
/* TODO: check Ogg libraries API and see if we can just not have this func */ /* TODO: check Ogg libraries API and see if we can just not have this func */
static int ogg_close_cb(void *vdata) static int ogg_close_cb(mpd_unused void *vdata)
{ {
return 0; return 0;
} }
......
...@@ -114,7 +114,8 @@ static void format_samples_int(int Bps, void *buffer, uint32_t samcnt) ...@@ -114,7 +114,8 @@ static void format_samples_int(int Bps, void *buffer, uint32_t samcnt)
/* /*
* This function converts floating point sample data to 16 bit integer. * This function converts floating point sample data to 16 bit integer.
*/ */
static void format_samples_float(int Bps, void *buffer, uint32_t samcnt) static void format_samples_float(mpd_unused int Bps, void *buffer,
uint32_t samcnt)
{ {
int16_t *dst = (int16_t *)buffer; int16_t *dst = (int16_t *)buffer;
float *src = (float *)buffer; float *src = (float *)buffer;
......
...@@ -106,7 +106,7 @@ int inputStream_fileAtEOF(InputStream * inStream) ...@@ -106,7 +106,7 @@ int inputStream_fileAtEOF(InputStream * inStream)
return 0; return 0;
} }
int inputStream_fileBuffer(InputStream * inStream) int inputStream_fileBuffer(mpd_unused InputStream * inStream)
{ {
return 0; return 0;
} }
...@@ -750,7 +750,7 @@ closed: ...@@ -750,7 +750,7 @@ closed:
return NULL; return NULL;
} }
int inputStream_httpBuffer(InputStream *is) int inputStream_httpBuffer(mpd_unused InputStream *is)
{ {
return 0; return 0;
} }
......
...@@ -352,7 +352,7 @@ static void cleanUpPidFile(void) ...@@ -352,7 +352,7 @@ static void cleanUpPidFile(void)
unlink(pidFileParam->value); unlink(pidFileParam->value);
} }
static void killFromPidFile(char *cmd, int killOption) static void killFromPidFile(void)
{ {
FILE *fp; FILE *fp;
ConfigParam *pidFileParam = parseConfigFilePath(CONF_PID_FILE, 0); ConfigParam *pidFileParam = parseConfigFilePath(CONF_PID_FILE, 0);
...@@ -391,7 +391,7 @@ int main(int argc, char *argv[]) ...@@ -391,7 +391,7 @@ int main(int argc, char *argv[])
parseOptions(argc, argv, &options); parseOptions(argc, argv, &options);
if (options.kill) if (options.kill)
killFromPidFile(argv[0], options.kill); killFromPidFile();
initStats(); initStats();
initTagConfig(); initTagConfig();
......
...@@ -258,9 +258,11 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, ...@@ -258,9 +258,11 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate,
#else /* !HAVE_LIBSAMPLERATE */ #else /* !HAVE_LIBSAMPLERATE */
/* resampling code blatantly ripped from ESD */ /* resampling code blatantly ripped from ESD */
static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate, static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate,
const char *inBuffer, size_t inSize, const char *inBuffer,
mpd_unused size_t inSize,
mpd_uint32 outSampleRate, char *outBuffer, mpd_uint32 outSampleRate, char *outBuffer,
size_t outSize, ConvState *convState) size_t outSize,
mpd_unused ConvState *convState)
{ {
mpd_uint32 rd_dat = 0; mpd_uint32 rd_dat = 0;
mpd_uint32 wr_dat = 0; mpd_uint32 wr_dat = 0;
......
...@@ -126,7 +126,7 @@ int playerPlay(int fd, Song * song) ...@@ -126,7 +126,7 @@ int playerPlay(int fd, Song * song)
return 0; return 0;
} }
int playerStop(int fd) int playerStop(mpd_unused int fd)
{ {
if (pc.state != PLAYER_STATE_STOP) { if (pc.state != PLAYER_STATE_STOP) {
pc.stop = 1; pc.stop = 1;
...@@ -144,7 +144,7 @@ void playerKill(void) /* deprecated */ ...@@ -144,7 +144,7 @@ void playerKill(void) /* deprecated */
playerPause(STDERR_FILENO); playerPause(STDERR_FILENO);
} }
int playerPause(int fd) int playerPause(mpd_unused int fd)
{ {
if (pc.state != PLAYER_STATE_STOP) { if (pc.state != PLAYER_STATE_STOP) {
pc.pause = 1; pc.pause = 1;
......
...@@ -1258,7 +1258,7 @@ int previousSongInPlaylist(int fd) ...@@ -1258,7 +1258,7 @@ int previousSongInPlaylist(int fd)
} }
} }
int shufflePlaylist(int fd) int shufflePlaylist(mpd_unused int fd)
{ {
int i; int i;
int ri; int ri;
......
...@@ -47,7 +47,7 @@ int handlePendingSignals(void) ...@@ -47,7 +47,7 @@ int handlePendingSignals(void)
return 0; return 0;
} }
static void chldSigHandler(int sig) static void chldSigHandler(mpd_unused int sig)
{ {
int status; int status;
int pid; int pid;
......
...@@ -171,8 +171,7 @@ _SplitNode(TreeNode * node) ...@@ -171,8 +171,7 @@ _SplitNode(TreeNode * node)
static static
void void
_InsertNodeAndData(Tree * tree, _InsertNodeAndData(TreeNode * node,
TreeNode * node,
int pos, int pos,
TreeNode * newNode, TreeNode * newNode,
TreeKeyData keyData) TreeKeyData keyData)
...@@ -204,8 +203,7 @@ _InsertNodeAndData(Tree * tree, ...@@ -204,8 +203,7 @@ _InsertNodeAndData(Tree * tree,
static static
TreeKeyData TreeKeyData
_AddDataToSplitNodes(Tree * tree, _AddDataToSplitNodes(TreeNode * lessNode,
TreeNode * lessNode,
TreeNode * moreNode, TreeNode * moreNode,
int pos, int pos,
TreeNode * newNode, TreeNode * newNode,
...@@ -217,7 +215,7 @@ _AddDataToSplitNodes(Tree * tree, ...@@ -217,7 +215,7 @@ _AddDataToSplitNodes(Tree * tree,
if (pos <= lessNode->count) if (pos <= lessNode->count)
{ {
_InsertNodeAndData(tree, lessNode, pos, newNode, keyData); _InsertNodeAndData(lessNode, pos, newNode, keyData);
lessNode->count--; lessNode->count--;
retKeyData = lessNode->keyData[lessNode->count]; retKeyData = lessNode->keyData[lessNode->count];
_ClearKeyData(&(lessNode->keyData[lessNode->count])); _ClearKeyData(&(lessNode->keyData[lessNode->count]));
...@@ -277,8 +275,7 @@ _InsertAt(TreeIterator * iter, TreeKeyData keyData) ...@@ -277,8 +275,7 @@ _InsertAt(TreeIterator * iter, TreeKeyData keyData)
TreeNode * newNode = _SplitNode(node); TreeNode * newNode = _SplitNode(node);
/* insert data in split nodes */ /* insert data in split nodes */
keyData = _AddDataToSplitNodes(iter->tree, keyData = _AddDataToSplitNodes(node,
node,
newNode, newNode,
pos, pos,
insertNode, insertNode,
...@@ -306,8 +303,7 @@ _InsertAt(TreeIterator * iter, TreeKeyData keyData) ...@@ -306,8 +303,7 @@ _InsertAt(TreeIterator * iter, TreeKeyData keyData)
else else
{ {
/* insert the data and newNode */ /* insert the data and newNode */
_InsertNodeAndData(iter->tree, _InsertNodeAndData(node,
node,
pos, pos,
insertNode, insertNode,
keyData); keyData);
......
...@@ -469,7 +469,7 @@ int getVolumeLevel(void) ...@@ -469,7 +469,7 @@ int getVolumeLevel(void)
} }
} }
static int changeSoftwareVolume(int fd, int change, int rel) static int changeSoftwareVolume(mpd_unused int fd, int change, int rel)
{ {
int new = change; int new = change;
......
...@@ -94,7 +94,7 @@ struct AvahiTimeout { ...@@ -94,7 +94,7 @@ struct AvahiTimeout {
static AvahiWatch *avahiWatchList; static AvahiWatch *avahiWatchList;
static AvahiTimeout *avahiTimeoutList; static AvahiTimeout *avahiTimeoutList;
static AvahiWatch *avahiWatchNew(const AvahiPoll * api, int fd, static AvahiWatch *avahiWatchNew(mpd_unused const AvahiPoll * api, int fd,
AvahiWatchEvent event, AvahiWatchEvent event,
AvahiWatchCallback callback, void *userdata) AvahiWatchCallback callback, void *userdata)
{ {
...@@ -177,7 +177,7 @@ static void avahiTimeoutFree(AvahiTimeout * t) ...@@ -177,7 +177,7 @@ static void avahiTimeoutFree(AvahiTimeout * t)
free(t); free(t);
} }
static AvahiTimeout *avahiTimeoutNew(const AvahiPoll * api, static AvahiTimeout *avahiTimeoutNew(mpd_unused const AvahiPoll * api,
const struct timeval *tv, const struct timeval *tv,
AvahiTimeoutCallback callback, AvahiTimeoutCallback callback,
void *userdata) void *userdata)
...@@ -201,7 +201,8 @@ static AvahiTimeout *avahiTimeoutNew(const AvahiPoll * api, ...@@ -201,7 +201,8 @@ static AvahiTimeout *avahiTimeoutNew(const AvahiPoll * api,
/* Callback when the EntryGroup changes state */ /* Callback when the EntryGroup changes state */
static void avahiGroupCallback(AvahiEntryGroup * g, static void avahiGroupCallback(AvahiEntryGroup * g,
AvahiEntryGroupState state, void *userdata) AvahiEntryGroupState state,
mpd_unused void *userdata)
{ {
char *n; char *n;
assert(g); assert(g);
...@@ -291,7 +292,7 @@ fail: ...@@ -291,7 +292,7 @@ fail:
/* Callback when avahi changes state */ /* Callback when avahi changes state */
static void avahiClientCallback(AvahiClient * c, AvahiClientState state, static void avahiClientCallback(AvahiClient * c, AvahiClientState state,
void *userdata) mpd_unused void *userdata)
{ {
int reason; int reason;
assert(c); assert(c);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment