Commit 5aca21a5 authored by Eric Wong's avatar Eric Wong

Several fixes uncovered with -pedantic

playerData.c: proper error checking directory.c: properly check myFgets() for errors (it returns NULL on error) inputPlugins/mp3_plugin.c get rid of commas at the end of enums interface.c: we weren't using long long, so strtoll isn't needed get rid of void-pointer arithmetic sllist.c: get rid of void-pointer arithmetic compress.c: get rid of C++ comments, some compilers don't accept them Note that I personally like void pointer arithmetic, but some ancient compilers don't support them :( git-svn-id: https://svn.musicpd.org/mpd/trunk@4510 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 9ccf40b2
......@@ -253,10 +253,10 @@ void CompressDo(void *data, unsigned int length)
127);
clipped = 0;
// target line
//XDrawPoint(display, window, redGC,
// pn, 127 - TARGET/256);
// amplification edge
/* target line */
/* XDrawPoint(display, window, redGC, */
/* pn, 127 - TARGET/256); */
/* amplification edge */
XDrawLine(display, window, dkyellowGC,
pn,
127 - (peaks[pn]*gainCurrent
......@@ -311,7 +311,7 @@ void CompressDo(void *data, unsigned int length)
127 - (peak*gainCurrent
>> (GAINSHIFT + 8)));
// gain indicator
/* gain indicator */
XFillRectangle(display, window, whiteGC, 0, 128,
prefs.buckets, 8);
x = (gainTarget - (1 << GAINSHIFT))*prefs.buckets
......@@ -326,7 +326,7 @@ void CompressDo(void *data, unsigned int length)
x, 132 - 1,
x, 132 + 1);
// blue peak line
/* blue peak line */
XDrawLine(display, window, blueGC,
0, 127 - (peak >> 8), prefs.buckets,
127 - (peak >> 8));
......
......@@ -940,14 +940,14 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
&& 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) {
if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) {
key = strdup(&(buffer[strlen(DIRECTORY_DIR)]));
if (myFgets(buffer, bufferSize, fp) < 0) {
if (!myFgets(buffer, bufferSize, fp)) {
ERROR("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
/* for compatibility with db's prior to 0.11 */
if (0 == strncmp(DIRECTORY_MTIME, buffer,
strlen(DIRECTORY_MTIME))) {
if (myFgets(buffer, bufferSize, fp) < 0) {
if (!myFgets(buffer, bufferSize, fp)) {
ERROR("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
......@@ -1140,7 +1140,7 @@ int readDirectoryDB()
int foundFsCharset = 0;
int foundVersion = 0;
if (myFgets(buffer, bufferSize, fp) < 0) {
if (!myFgets(buffer, bufferSize, fp)) {
ERROR("Error reading db, fgets\n");
exit(EXIT_FAILURE);
}
......
......@@ -451,7 +451,7 @@ static int decodeNextFrame(mp3DecodeData * data)
enum xing_magic {
XING_MAGIC_XING, /* VBR */
XING_MAGIC_INFO, /* CBR */
XING_MAGIC_INFO /* CBR */
};
struct xing {
......@@ -467,7 +467,7 @@ enum {
XING_FRAMES = 0x00000001L,
XING_BYTES = 0x00000002L,
XING_TOC = 0x00000004L,
XING_SCALE = 0x00000008L,
XING_SCALE = 0x00000008L
};
struct lame {
......
......@@ -570,8 +570,8 @@ void initInterfaces(void)
param = getConfigParam(CONF_MAX_COMMAND_LIST_SIZE);
if (param) {
interface_max_command_list_size = strtoll(param->value,
&test, 10);
interface_max_command_list_size = strtol(param->value,
&test, 10);
if (*test != '\0' || interface_max_command_list_size <= 0) {
ERROR("max command list size \"%s\" is not a positive "
"integer, line %i\n", param->value, param->line);
......@@ -583,8 +583,8 @@ void initInterfaces(void)
param = getConfigParam(CONF_MAX_OUTPUT_BUFFER_SIZE);
if (param) {
interface_max_output_buffer_size = strtoll(param->value, &test,
10);
interface_max_output_buffer_size = strtol(param->value,
&test, 10);
if (*test != '\0' || interface_max_output_buffer_size <= 0) {
ERROR("max output buffer size \"%s\" is not a positive "
"integer, line %i\n", param->value, param->line);
......@@ -660,7 +660,7 @@ static void flushInterfaceBuffer(Interface * interface)
break;
else if (ret < buf->size) {
interface->deferred_bytes -= ret;
buf->data += ret;
buf->data = (char *)buf->data + ret;
buf->size -= ret;
} else {
struct sllnode *tmp = buf;
......
......@@ -96,7 +96,7 @@ void initPlayerData(void)
ERROR("problems shmget'ing\n");
exit(EXIT_FAILURE);
}
if ((playerData_pd = shmat(shmid, NULL, 0)) < 0) {
if (!(playerData_pd = shmat(shmid, NULL, 0))) {
ERROR("problems shmat'ing\n");
exit(EXIT_FAILURE);
}
......@@ -112,7 +112,7 @@ void initPlayerData(void)
ERROR("problems shmget'ing\n");
exit(EXIT_FAILURE);
}
if ((player_pid = shmat(shmid, NULL, 0)) < 0) {
if (!(player_pid = shmat(shmid, NULL, 0))) {
ERROR("problems shmat'ing\n");
exit(EXIT_FAILURE);
}
......
......@@ -39,7 +39,7 @@ struct strnode *new_strnode_dup(char *s, const size_t size)
{
struct strnode *x = malloc(sizeof(struct strnode) + size);
x->next = NULL;
x->data = ((void *)x + sizeof(struct strnode));
x->data = ((char *)x + sizeof(struct strnode));
memcpy((void *)x->data, (void*)s, size);
return x;
}
......@@ -49,7 +49,7 @@ struct sllnode *new_sllnode(void *s, const size_t size)
struct sllnode *x = malloc(sizeof(struct sllnode) + size);
x->next = NULL;
x->size = size;
x->data = ((void *)x + sizeof(struct sllnode));
x->data = ((char *)x + sizeof(struct sllnode));
memcpy(x->data, (void *)s, size);
return x;
}
......
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