diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-08-01 04:18:41 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-08-01 04:18:41 +0000 |
commit | 5aca21a502839e2cfd30f0cfb186badc302a7eb5 (patch) | |
tree | 9e8b25b4b2c648a85dedcfe69c1bc7100564b4f9 /src | |
parent | 9ccf40b24293198c8091ca5dc269006776b080bc (diff) | |
download | mpd-5aca21a502839e2cfd30f0cfb186badc302a7eb5.tar.gz mpd-5aca21a502839e2cfd30f0cfb186badc302a7eb5.tar.xz mpd-5aca21a502839e2cfd30f0cfb186badc302a7eb5.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/compress.c | 12 | ||||
-rw-r--r-- | src/directory.c | 6 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 4 | ||||
-rw-r--r-- | src/interface.c | 10 | ||||
-rw-r--r-- | src/playerData.c | 4 | ||||
-rw-r--r-- | src/sllist.c | 4 |
6 files changed, 20 insertions, 20 deletions
diff --git a/src/compress.c b/src/compress.c index 08923c22a..a29d4ef78 100644 --- a/src/compress.c +++ b/src/compress.c @@ -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)); diff --git a/src/directory.c b/src/directory.c index 9f07b203e..da4b0a4eb 100644 --- a/src/directory.c +++ b/src/directory.c @@ -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); } diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index c016a9ad6..29a0c43d9 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -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 { diff --git a/src/interface.c b/src/interface.c index 130deffad..99d891bee 100644 --- a/src/interface.c +++ b/src/interface.c @@ -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; diff --git a/src/playerData.c b/src/playerData.c index 2c18b6937..a023d76e9 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -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); } diff --git a/src/sllist.c b/src/sllist.c index e25615863..e87be6ad5 100644 --- a/src/sllist.c +++ b/src/sllist.c @@ -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; } |