aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-07 19:14:39 +0200
committerMax Kellermann <max@duempel.org>2008-09-07 19:14:39 +0200
commit4dd9d4b2fdfb6adde66920d4fd1bb65a1cf0695a (patch)
treefe980e309ed81201e44f612968d4bf04825bf36f /src
parentb67bb05d05aef568a2614943625386a8cd67690d (diff)
downloadmpd-4dd9d4b2fdfb6adde66920d4fd1bb65a1cf0695a.tar.gz
mpd-4dd9d4b2fdfb6adde66920d4fd1bb65a1cf0695a.tar.xz
mpd-4dd9d4b2fdfb6adde66920d4fd1bb65a1cf0695a.zip
fix -Wcast-qual -Wwrite-strings warnings
The previous patch enabled these warnings. In Eric's branch, they were worked around with a generic deconst_ptr() function. There are several places where we can add "const" to pointers, and in others, libraries want non-const strings. In the latter, convert string literals to "static char[]" variables - this takes the same space, and seems safer than deconsting a string literal.
Diffstat (limited to 'src')
-rw-r--r--src/audioOutputs/audioOutput_jack.c17
-rw-r--r--src/audioOutputs/audioOutput_shout.c2
-rw-r--r--src/inputPlugins/mod_plugin.c17
-rw-r--r--src/inputPlugins/wavpack_plugin.c12
-rw-r--r--src/list.c9
-rw-r--r--src/pcm_utils.c19
6 files changed, 43 insertions, 33 deletions
diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c
index 8818bb739..b8add85d9 100644
--- a/src/audioOutputs/audioOutput_jack.c
+++ b/src/audioOutputs/audioOutput_jack.c
@@ -31,8 +31,8 @@ static const size_t sample_size = sizeof(jack_default_audio_sample_t);
typedef struct _JackData {
/* configuration */
- char *name;
- char *output_ports[2];
+ const char *name;
+ const char *output_ports[2];
int ringbuf_sz;
/* locks */
@@ -52,6 +52,7 @@ typedef struct _JackData {
static JackData *newJackData(void)
{
JackData *ret;
+
ret = xcalloc(sizeof(JackData), 1);
ret->name = "mpd";
@@ -97,12 +98,12 @@ static void freeJackData(AudioOutput *audioOutput)
freeJackClient(jd);
if (strcmp(jd->name, "mpd") != 0)
- free(jd->name);
+ xfree(jd->name);
for ( i = ARRAY_SIZE(jd->output_ports); --i >= 0; ) {
if (!jd->output_ports[i])
continue;
- free(jd->output_ports[i]);
+ xfree(jd->output_ports[i]);
}
free(jd);
@@ -267,7 +268,7 @@ static int jack_testDefault(void)
static int connect_jack(AudioOutput *audioOutput)
{
JackData *jd = audioOutput->data;
- char **jports;
+ const char **jports;
char *port_name;
if ( (jd->client = jack_client_new(jd->name)) == NULL ) {
@@ -304,9 +305,9 @@ static int connect_jack(AudioOutput *audioOutput)
/* hay que buscar que hay */
if ( !jd->output_ports[1]
- && (jports = (char **)jack_get_ports(jd->client, NULL, NULL,
- JackPortIsPhysical|
- JackPortIsInput)) ) {
+ && (jports = jack_get_ports(jd->client, NULL, NULL,
+ JackPortIsPhysical|
+ JackPortIsInput)) ) {
jd->output_ports[0] = jports[0];
jd->output_ports[1] = jports[1] ? jports[1] : jports[0];
DEBUG("output_ports: %s %s\n",
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c
index f33455850..7a07f5357 100644
--- a/src/audioOutputs/audioOutput_shout.c
+++ b/src/audioOutputs/audioOutput_shout.c
@@ -637,7 +637,7 @@ static int myShout_play(AudioOutput * audioOutput,
for (i = 0; i < samples; i++) {
for (j = 0; j < sd->audioFormat->channels; j++) {
- vorbbuf[j][i] = (*((mpd_sint16 *) playChunk)) / 32768.0;
+ vorbbuf[j][i] = (*((const mpd_sint16 *) playChunk)) / 32768.0;
playChunk += bytes;
}
}
diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c
index 1d458919c..4b891f609 100644
--- a/src/inputPlugins/mod_plugin.c
+++ b/src/inputPlugins/mod_plugin.c
@@ -48,14 +48,21 @@ static BOOL mod_mpd_IsThere(void)
return 1;
}
+static char drv_name[] = "MPD";
+static char drv_version[] = "MPD Output Driver v0.1";
+
+#if (LIBMIKMOD_VERSION > 0x030106)
+static char drv_alias[] = "mpd";
+#endif
+
static MDRIVER drv_mpd = {
NULL,
- "MPD",
- "MPD Output Driver v0.1",
+ drv_name,
+ drv_version,
0,
255,
#if (LIBMIKMOD_VERSION > 0x030106)
- "mpd", /* Alias */
+ drv_alias,
#if (LIBMIKMOD_VERSION >= 0x030200)
NULL, /* CmdLineHelp */
#endif
@@ -92,6 +99,8 @@ static int mod_mikModInitError;
static int mod_initMikMod(void)
{
+ static char params[] = "";
+
if (mod_mikModInitError)
return -1;
@@ -110,7 +119,7 @@ static int mod_initMikMod(void)
md_mode = (DMODE_SOFT_MUSIC | DMODE_INTERP | DMODE_STEREO |
DMODE_16BITS);
- if (MikMod_Init("")) {
+ if (MikMod_Init(params)) {
ERROR("Could not init MikMod: %s\n",
MikMod_strerror(MikMod_errno));
mod_mikModInitError = 1;
diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c
index 0b3b52472..38e970fa6 100644
--- a/src/inputPlugins/wavpack_plugin.c
+++ b/src/inputPlugins/wavpack_plugin.c
@@ -235,34 +235,38 @@ static char *wavpack_tag(WavpackContext *wpc, char *key)
static ReplayGainInfo *wavpack_replaygain(WavpackContext *wpc)
{
+ static char replaygain_track_gain[] = "replaygain_track_gain";
+ static char replaygain_album_gain[] = "replaygain_album_gain";
+ static char replaygain_track_peak[] = "replaygain_track_peak";
+ static char replaygain_album_peak[] = "replaygain_album_peak";
ReplayGainInfo *replayGainInfo;
int found = 0;
char *value;
replayGainInfo = newReplayGainInfo();
- value = wavpack_tag(wpc, "replaygain_track_gain");
+ value = wavpack_tag(wpc, replaygain_track_gain);
if (value) {
replayGainInfo->trackGain = atof(value);
free(value);
found = 1;
}
- value = wavpack_tag(wpc, "replaygain_album_gain");
+ value = wavpack_tag(wpc, replaygain_album_gain);
if (value) {
replayGainInfo->albumGain = atof(value);
free(value);
found = 1;
}
- value = wavpack_tag(wpc, "replaygain_track_peak");
+ value = wavpack_tag(wpc, replaygain_track_peak);
if (value) {
replayGainInfo->trackPeak = atof(value);
free(value);
found = 1;
}
- value = wavpack_tag(wpc, "replaygain_album_peak");
+ value = wavpack_tag(wpc, replaygain_album_peak);
if (value) {
replayGainInfo->albumPeak = atof(value);
free(value);
diff --git a/src/list.c b/src/list.c
index 0f1f31ad4..01da7bdab 100644
--- a/src/list.c
+++ b/src/list.c
@@ -301,11 +301,6 @@ int deleteFromList(List * list, const char *key)
return 1;
}
-static void free_const_string(const char *p)
-{
- free((char *)p);
-}
-
void deleteNodeFromList(List * list, ListNode * node)
{
assert(list != NULL);
@@ -326,7 +321,7 @@ void deleteNodeFromList(List * list, ListNode * node)
}
if (list->strdupKeys)
- free_const_string(node->key);
+ xfree(node->key);
free(node);
list->numberOfNodes--;
@@ -353,7 +348,7 @@ void freeList(void *list)
while (tmpNode != NULL) {
tmpNode2 = tmpNode->nextNode;
if (((List *) list)->strdupKeys)
- free_const_string(tmpNode->key);
+ xfree(tmpNode->key);
if (((List *) list)->freeDataFunc) {
((List *) list)->freeDataFunc(tmpNode->data);
}
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index f716c279d..90856fa1d 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -149,6 +149,7 @@ static int pcm_getSampleRateConverter(void)
const char *conf = getConfigParamValue(CONF_SAMPLERATE_CONVERTER);
long convalgo;
char *test;
+ const char *test2;
size_t len;
if (!conf) {
@@ -162,12 +163,12 @@ static int pcm_getSampleRateConverter(void)
len = strlen(conf);
for (convalgo = 0 ; ; convalgo++) {
- test = (char *)src_get_name(convalgo);
- if (!test) {
+ test2 = src_get_name(convalgo);
+ if (!test2) {
convalgo = SRC_SINC_FASTEST;
break;
}
- if (strncasecmp(test, conf, len) == 0)
+ if (strncasecmp(test2, conf, len) == 0)
goto out;
}
@@ -239,7 +240,7 @@ static size_t pcm_convertSampleRate(mpd_sint8 channels, mpd_uint32 inSampleRate,
data->data_out = xrealloc(data->data_out, dataOutSize);
}
- src_short_to_float_array((short *)inBuffer, data->data_in,
+ src_short_to_float_array((const short *)inBuffer, data->data_in,
data->input_frames * channels);
error = src_process(convState->state, data);
@@ -305,7 +306,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
static char *buf;
static size_t len;
char *outBuffer = NULL;
- mpd_sint16 *in;
+ const mpd_sint16 *in;
mpd_sint16 *out;
int inSamples, i;
@@ -320,7 +321,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
outBuffer = buf;
inSamples = inSize >> 1;
- in = (mpd_sint16 *)inBuffer;
+ in = (const mpd_sint16 *)inBuffer;
out = (mpd_sint16 *)outBuffer;
for (i = 0; i < inSamples; i++) {
*out++ = *in;
@@ -338,7 +339,7 @@ static char *pcm_convertChannels(mpd_sint8 channels, const char *inBuffer,
outBuffer = buf;
inSamples = inSize >> 2;
- in = (mpd_sint16 *)inBuffer;
+ in = (const mpd_sint16 *)inBuffer;
out = (mpd_sint16 *)outBuffer;
for (i = 0; i < inSamples; i++) {
*out = (*in++) / 2;
@@ -359,7 +360,7 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
static char *buf;
static size_t len;
char *outBuffer = NULL;
- mpd_sint8 *in;
+ const mpd_sint8 *in;
mpd_sint16 *out;
size_t i;
@@ -372,7 +373,7 @@ static const char *pcm_convertTo16bit(mpd_sint8 bits, const char *inBuffer,
}
outBuffer = buf;
- in = (mpd_sint8 *)inBuffer;
+ in = (const mpd_sint8 *)inBuffer;
out = (mpd_sint16 *)outBuffer;
for (i = 0; i < inSize; i++)
*out++ = (*in++) << 8;