Skip to contentSkip to conversation

tinycompress: fix spare warnings

PATCH New Vinod Koul 1 participant 4 messages Jan 18, 2016

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover tinycompress: fix spare warnings

Sparse warns about few things in this project so fix them

Vinod Koul (3):
tinycompress: cplay: make functions static
tinycompress: crec: fix function declaration
tinycompress: crec: make functions static

 include/tinycompress/tinymp3.h | 4 ++--
 src/utils/cplay.c              | 4 ++--
 src/utils/crec.c               | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/3 tinycompress: cplay: make functions static

Sparse rightly complains some functions should be static so make them static

cplay.c:100:5: warning: symbol 'parse_mp3_header' was not declared. Should it be static? cplay.c:129:5: warning: symbol 'check_codec_format_supported' was not declared. Should it be static? ../../include/tinycompress/tinymp3.h:66:11: warning: symbol 'mp3_sample_rates' was not declared. Should it be static? ../../include/tinycompress/tinymp3.h:72:11: warning: symbol 'mp3_bit_rates' was not declared. Should it be static?

---
 include/tinycompress/tinymp3.h | 4 ++--
 src/utils/cplay.c              | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/tinycompress/tinymp3.h +2 -2
index b7b45e3a6109..a709c397ee09 100644
@@ -63,13 +63,13 @@ extern "C" {
 
 #define MP3_SYNC 0xe0ff
 
-const int mp3_sample_rates[3][3] = {
+static const int mp3_sample_rates[3][3] = {
 	{44100, 48000, 32000},        /* MPEG-1 */
 	{22050, 24000, 16000},        /* MPEG-2 */
 	{11025, 12000,  8000},        /* MPEG-2.5 */
 };
 
-const int mp3_bit_rates[3][3][15] = {
+static const int mp3_bit_rates[3][3][15] = {
 	{
 		/* MPEG-1 */
 		{  0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448}, /* Layer 1 */
src/utils/cplay.c +2 -2
index 2d1a1760b3ec..032a97111402 100644
@@ -97,7 +97,7 @@ struct mp3_header {
 	uint8_t format2;
 };
 
-int parse_mp3_header(struct mp3_header *header, unsigned int *num_channels,
+static int parse_mp3_header(struct mp3_header *header, unsigned int *num_channels,
 		unsigned int *sample_rate, unsigned int *bit_rate)
 {
 	int ver_idx, mp3_version, layer, bit_rate_idx, sample_rate_idx, channel_idx;
@@ -126,7 +126,7 @@ int parse_mp3_header(struct mp3_header *header, unsigned int *num_channels,
 	return 0;
 }
 
-int check_codec_format_supported(unsigned int card, unsigned int device, struct snd_codec *codec)
+static int check_codec_format_supported(unsigned int card, unsigned int device, struct snd_codec *codec)
 {
 	if (is_codec_supported(card, device, COMPRESS_IN, codec) == false) {
 		fprintf(stderr, "Error: This codec or format is not supported by DSP\n");
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 2/3 tinycompress: crec: fix function declaration

In reply to Vinod Koul

finish_record was not following ANSI standard for declaration as warned by sparse

crec.c:193:26: warning: non-ANSI function declaration of function 'finish_record'

---
 src/utils/crec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/utils/crec.c +1 -1
index e61e620d6490..6e8166d8f77b 100644
@@ -190,7 +190,7 @@ static int print_time(struct compress *compress)
 	return 0;
 }
 
-static int finish_record()
+static int finish_record(void)
 {
 	struct wave_header header;
 	int ret;
Signature · 1 line
1.9.1
author
#3 lore raw

PATCH 3/3 tinycompress: crec: make functions static

In reply to Vinod Koul

Sparse rightly complains some functions should be static so make them static

crec.c:113:26: warning: symbol 'blank_wave_header' was not declared. Should it be static? crec.c:239:6: warning: symbol 'capture_samples' was not declared. Should it be static?

---
 src/utils/crec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/utils/crec.c +2 -2
index 6e8166d8f77b..8d5b7b0b2c30 100644
@@ -110,7 +110,7 @@ struct wave_header {
 	} __attribute__((__packed__)) data;
 } __attribute__((__packed__));
 
-const struct wave_header blank_wave_header = {
+static const struct wave_header blank_wave_header = {
 	.riff = {
 		.chunk = {
 			.desc = "RIFF",
@@ -236,7 +236,7 @@ static int finish_record(void)
 	return 0;
 }
 
-void capture_samples(char *name, unsigned int card, unsigned int device,
+static void capture_samples(char *name, unsigned int card, unsigned int device,
 		     unsigned long buffer_size, unsigned int frag,
 		     unsigned int length, unsigned int rate,
 		     unsigned int channels, unsigned int format)
Signature · 1 line
1.9.1