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
This commit is contained in:
		| @@ -253,10 +253,10 @@ void CompressDo(void *data, unsigned int length) | |||||||
| 				  127); | 				  127); | ||||||
| 		clipped = 0; | 		clipped = 0; | ||||||
|  |  | ||||||
| 		// target line | 		/* target line */ | ||||||
| 		//XDrawPoint(display, window, redGC, | 		/* XDrawPoint(display, window, redGC, */ | ||||||
| 		//         pn, 127 - TARGET/256); | 		/*         pn, 127 - TARGET/256); */ | ||||||
| 		// amplification edge | 		/* amplification edge */ | ||||||
| 		XDrawLine(display, window, dkyellowGC, | 		XDrawLine(display, window, dkyellowGC, | ||||||
| 			  pn, | 			  pn, | ||||||
| 			  127 - (peaks[pn]*gainCurrent | 			  127 - (peaks[pn]*gainCurrent | ||||||
| @@ -311,7 +311,7 @@ void CompressDo(void *data, unsigned int length) | |||||||
| 			   127 - (peak*gainCurrent | 			   127 - (peak*gainCurrent | ||||||
| 				  >> (GAINSHIFT + 8))); | 				  >> (GAINSHIFT + 8))); | ||||||
|  |  | ||||||
| 		// gain indicator | 		/* gain indicator */ | ||||||
| 		XFillRectangle(display, window, whiteGC, 0, 128, | 		XFillRectangle(display, window, whiteGC, 0, 128, | ||||||
| 			       prefs.buckets, 8); | 			       prefs.buckets, 8); | ||||||
| 		x = (gainTarget - (1 << GAINSHIFT))*prefs.buckets | 		x = (gainTarget - (1 << GAINSHIFT))*prefs.buckets | ||||||
| @@ -326,7 +326,7 @@ void CompressDo(void *data, unsigned int length) | |||||||
| 			  x, 132 - 1, | 			  x, 132 - 1, | ||||||
| 			  x, 132 + 1); | 			  x, 132 + 1); | ||||||
|  |  | ||||||
| 		// blue peak line | 		/* blue peak line */ | ||||||
| 		XDrawLine(display, window, blueGC, | 		XDrawLine(display, window, blueGC, | ||||||
| 			  0, 127 - (peak >> 8), prefs.buckets, | 			  0, 127 - (peak >> 8), prefs.buckets, | ||||||
| 			  127 - (peak >> 8)); | 			  127 - (peak >> 8)); | ||||||
|   | |||||||
| @@ -940,14 +940,14 @@ static void readDirectoryInfo(FILE * fp, Directory * directory) | |||||||
| 	       && 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) { | 	       && 0 != strncmp(DIRECTORY_END, buffer, strlen(DIRECTORY_END))) { | ||||||
| 		if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) { | 		if (0 == strncmp(DIRECTORY_DIR, buffer, strlen(DIRECTORY_DIR))) { | ||||||
| 			key = strdup(&(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"); | 				ERROR("Error reading db, fgets\n"); | ||||||
| 				exit(EXIT_FAILURE); | 				exit(EXIT_FAILURE); | ||||||
| 			} | 			} | ||||||
| 			/* for compatibility with db's prior to 0.11 */ | 			/* for compatibility with db's prior to 0.11 */ | ||||||
| 			if (0 == strncmp(DIRECTORY_MTIME, buffer, | 			if (0 == strncmp(DIRECTORY_MTIME, buffer, | ||||||
| 					 strlen(DIRECTORY_MTIME))) { | 					 strlen(DIRECTORY_MTIME))) { | ||||||
| 				if (myFgets(buffer, bufferSize, fp) < 0) { | 				if (!myFgets(buffer, bufferSize, fp)) { | ||||||
| 					ERROR("Error reading db, fgets\n"); | 					ERROR("Error reading db, fgets\n"); | ||||||
| 					exit(EXIT_FAILURE); | 					exit(EXIT_FAILURE); | ||||||
| 				} | 				} | ||||||
| @@ -1140,7 +1140,7 @@ int readDirectoryDB() | |||||||
| 		int foundFsCharset = 0; | 		int foundFsCharset = 0; | ||||||
| 		int foundVersion = 0; | 		int foundVersion = 0; | ||||||
|  |  | ||||||
| 		if (myFgets(buffer, bufferSize, fp) < 0) { | 		if (!myFgets(buffer, bufferSize, fp)) { | ||||||
| 			ERROR("Error reading db, fgets\n"); | 			ERROR("Error reading db, fgets\n"); | ||||||
| 			exit(EXIT_FAILURE); | 			exit(EXIT_FAILURE); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -451,7 +451,7 @@ static int decodeNextFrame(mp3DecodeData * data) | |||||||
|  |  | ||||||
| enum xing_magic { | enum xing_magic { | ||||||
| 	XING_MAGIC_XING, /* VBR */ | 	XING_MAGIC_XING, /* VBR */ | ||||||
| 	XING_MAGIC_INFO, /* CBR */ | 	XING_MAGIC_INFO  /* CBR */ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct xing { | struct xing { | ||||||
| @@ -467,7 +467,7 @@ enum { | |||||||
| 	XING_FRAMES = 0x00000001L, | 	XING_FRAMES = 0x00000001L, | ||||||
| 	XING_BYTES  = 0x00000002L, | 	XING_BYTES  = 0x00000002L, | ||||||
| 	XING_TOC    = 0x00000004L, | 	XING_TOC    = 0x00000004L, | ||||||
| 	XING_SCALE  = 0x00000008L, | 	XING_SCALE  = 0x00000008L | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct lame { | struct lame { | ||||||
|   | |||||||
| @@ -570,7 +570,7 @@ void initInterfaces(void) | |||||||
| 	param = getConfigParam(CONF_MAX_COMMAND_LIST_SIZE); | 	param = getConfigParam(CONF_MAX_COMMAND_LIST_SIZE); | ||||||
|  |  | ||||||
| 	if (param) { | 	if (param) { | ||||||
| 		interface_max_command_list_size = strtoll(param->value, | 		interface_max_command_list_size = strtol(param->value, | ||||||
| 							 &test, 10); | 							 &test, 10); | ||||||
| 		if (*test != '\0' || interface_max_command_list_size <= 0) { | 		if (*test != '\0' || interface_max_command_list_size <= 0) { | ||||||
| 			ERROR("max command list size \"%s\" is not a positive " | 			ERROR("max command list size \"%s\" is not a positive " | ||||||
| @@ -583,8 +583,8 @@ void initInterfaces(void) | |||||||
| 	param = getConfigParam(CONF_MAX_OUTPUT_BUFFER_SIZE); | 	param = getConfigParam(CONF_MAX_OUTPUT_BUFFER_SIZE); | ||||||
|  |  | ||||||
| 	if (param) { | 	if (param) { | ||||||
| 		interface_max_output_buffer_size = strtoll(param->value, &test, | 		interface_max_output_buffer_size = strtol(param->value, | ||||||
| 							   10); | 		                                          &test, 10); | ||||||
| 		if (*test != '\0' || interface_max_output_buffer_size <= 0) { | 		if (*test != '\0' || interface_max_output_buffer_size <= 0) { | ||||||
| 			ERROR("max output buffer size \"%s\" is not a positive " | 			ERROR("max output buffer size \"%s\" is not a positive " | ||||||
| 			      "integer, line %i\n", param->value, param->line); | 			      "integer, line %i\n", param->value, param->line); | ||||||
| @@ -660,7 +660,7 @@ static void flushInterfaceBuffer(Interface * interface) | |||||||
| 			break; | 			break; | ||||||
| 		else if (ret < buf->size) { | 		else if (ret < buf->size) { | ||||||
| 			interface->deferred_bytes -= ret; | 			interface->deferred_bytes -= ret; | ||||||
| 			buf->data += ret; | 			buf->data = (char *)buf->data + ret; | ||||||
| 			buf->size -= ret; | 			buf->size -= ret; | ||||||
| 		} else { | 		} else { | ||||||
| 			struct sllnode *tmp = buf; | 			struct sllnode *tmp = buf; | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ void initPlayerData(void) | |||||||
| 		ERROR("problems shmget'ing\n"); | 		ERROR("problems shmget'ing\n"); | ||||||
| 		exit(EXIT_FAILURE); | 		exit(EXIT_FAILURE); | ||||||
| 	} | 	} | ||||||
| 	if ((playerData_pd = shmat(shmid, NULL, 0)) < 0) { | 	if (!(playerData_pd = shmat(shmid, NULL, 0))) { | ||||||
| 		ERROR("problems shmat'ing\n"); | 		ERROR("problems shmat'ing\n"); | ||||||
| 		exit(EXIT_FAILURE); | 		exit(EXIT_FAILURE); | ||||||
| 	} | 	} | ||||||
| @@ -112,7 +112,7 @@ void initPlayerData(void) | |||||||
| 		ERROR("problems shmget'ing\n"); | 		ERROR("problems shmget'ing\n"); | ||||||
| 		exit(EXIT_FAILURE); | 		exit(EXIT_FAILURE); | ||||||
| 	} | 	} | ||||||
| 	if ((player_pid = shmat(shmid, NULL, 0)) < 0) { | 	if (!(player_pid = shmat(shmid, NULL, 0))) { | ||||||
| 		ERROR("problems shmat'ing\n"); | 		ERROR("problems shmat'ing\n"); | ||||||
| 		exit(EXIT_FAILURE); | 		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); | 	struct strnode *x = malloc(sizeof(struct strnode) + size); | ||||||
| 	x->next = NULL; | 	x->next = NULL; | ||||||
| 	x->data = ((void *)x + sizeof(struct strnode)); | 	x->data = ((char *)x + sizeof(struct strnode)); | ||||||
| 	memcpy((void *)x->data, (void*)s, size); | 	memcpy((void *)x->data, (void*)s, size); | ||||||
| 	return x; | 	return x; | ||||||
| } | } | ||||||
| @@ -49,7 +49,7 @@ struct sllnode *new_sllnode(void *s, const size_t size) | |||||||
| 	struct sllnode *x = malloc(sizeof(struct sllnode) + size); | 	struct sllnode *x = malloc(sizeof(struct sllnode) + size); | ||||||
| 	x->next = NULL; | 	x->next = NULL; | ||||||
| 	x->size = size; | 	x->size = size; | ||||||
| 	x->data = ((void *)x + sizeof(struct sllnode)); | 	x->data = ((char *)x + sizeof(struct sllnode)); | ||||||
| 	memcpy(x->data, (void *)s, size); | 	memcpy(x->data, (void *)s, size); | ||||||
| 	return x; | 	return x; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Eric Wong
					Eric Wong