aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Wilson <ksattic@gmail.com>2016-02-14 14:48:31 -0800
committerSimon Wilson <ksattic@gmail.com>2016-02-14 14:48:31 -0800
commit2474d888d77882a84e322867d8f14906bd74b5fe (patch)
treecccf281e1fe1b1bd8d5db8a16ad83927de6f7780
parentad66b45add9677c4a732fc3a020f7b5d19c38def (diff)
parent9d3cdd0ebfcd827881e3e3f723c7405701679a21 (diff)
Merge pull request #72 from frgm/cppcheck
fix some cppcheck warnings
-rw-r--r--mixer.c4
-rw-r--r--tinycap.c6
-rw-r--r--tinymix.c12
-rw-r--r--tinypcminfo.c2
-rw-r--r--tinywavinfo.c4
5 files changed, 15 insertions, 13 deletions
diff --git a/mixer.c b/mixer.c
index fc9123d..7c5c5dc 100644
--- a/mixer.c
+++ b/mixer.c
@@ -188,11 +188,13 @@ struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id)
struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name)
{
unsigned int n;
- struct mixer_ctl *ctl = mixer->ctl;
+ struct mixer_ctl *ctl;
if (!mixer)
return NULL;
+ ctl = mixer->ctl;
+
for (n = 0; n < mixer->count; n++)
if (!strcmp(name, (char*) ctl[n].info.id.name))
return &ctl[n];
diff --git a/tinycap.c b/tinycap.c
index 180a2dd..ffccb18 100644
--- a/tinycap.c
+++ b/tinycap.c
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
format = PCM_FORMAT_S16_LE;
break;
default:
- fprintf(stderr, "%d bits is not supported.\n", bits);
+ fprintf(stderr, "%u bits is not supported.\n", bits);
return 1;
}
@@ -179,7 +179,7 @@ int main(int argc, char **argv)
header.sample_rate, format,
period_size, period_count);
if (prinfo) {
- printf("Captured %d frames\n", frames);
+ printf("Captured %u frames\n", frames);
}
/* write header now all information is known */
@@ -226,7 +226,7 @@ unsigned int capture_sample(FILE *file, unsigned int card, unsigned int device,
size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm));
buffer = malloc(size);
if (!buffer) {
- fprintf(stderr, "Unable to allocate %d bytes\n", size);
+ fprintf(stderr, "Unable to allocate %u bytes\n", size);
free(buffer);
pcm_close(pcm);
return 0;
diff --git a/tinymix.c b/tinymix.c
index 6e4b9a0..5966df9 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -90,7 +90,7 @@ static void tinymix_list_controls(struct mixer *mixer)
num_ctls = mixer_get_num_ctls(mixer);
- printf("Number of controls: %d\n", num_ctls);
+ printf("Number of controls: %u\n", num_ctls);
printf("ctl\ttype\tnum\t%-40s value\n", "name");
for (i = 0; i < num_ctls; i++) {
@@ -99,7 +99,7 @@ static void tinymix_list_controls(struct mixer *mixer)
name = mixer_ctl_get_name(ctl);
type = mixer_ctl_get_type_string(ctl);
num_values = mixer_ctl_get_num_values(ctl);
- printf("%d\t%s\t%d\t%-40s", i, type, num_values, name);
+ printf("%u\t%s\t%u\t%-40s", i, type, num_values, name);
tinymix_detail_control(mixer, name, 0);
}
}
@@ -149,7 +149,7 @@ static void tinymix_detail_control(struct mixer *mixer, const char *control,
if ((type == MIXER_CTL_TYPE_BYTE) && (num_values > 0)) {
buf = calloc(1, num_values);
if (buf == NULL) {
- fprintf(stderr, "Failed to alloc mem for bytes %d\n", num_values);
+ fprintf(stderr, "Failed to alloc mem for bytes %u\n", num_values);
return;
}
@@ -209,7 +209,7 @@ static void tinymix_set_byte_ctl(struct mixer_ctl *ctl,
buf = calloc(1, num_values);
if (buf == NULL) {
- fprintf(stderr, "set_byte_ctl: Failed to alloc mem for bytes %d\n", num_values);
+ fprintf(stderr, "set_byte_ctl: Failed to alloc mem for bytes %u\n", num_values);
exit(EXIT_FAILURE);
}
@@ -302,13 +302,13 @@ static void tinymix_set_value(struct mixer *mixer, const char *control,
/* Set multiple values */
if (num_values > num_ctl_values) {
fprintf(stderr,
- "Error: %d values given, but control only takes %d\n",
+ "Error: %u values given, but control only takes %u\n",
num_values, num_ctl_values);
return;
}
for (i = 0; i < num_values; i++) {
if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) {
- fprintf(stderr, "Error: invalid value for index %d\n", i);
+ fprintf(stderr, "Error: invalid value for index %u\n", i);
return;
}
}
diff --git a/tinypcminfo.c b/tinypcminfo.c
index 99eec34..4eb0afa 100644
--- a/tinypcminfo.c
+++ b/tinypcminfo.c
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
argv++;
}
- printf("Info for card %d, device %d:\n", card, device);
+ printf("Info for card %u, device %u:\n", card, device);
for (i = 0; i < 2; i++) {
struct pcm_params *params;
diff --git a/tinywavinfo.c b/tinywavinfo.c
index 9d15668..99ee5da 100644
--- a/tinywavinfo.c
+++ b/tinywavinfo.c
@@ -201,9 +201,9 @@ void analyse_sample(FILE *file, unsigned int channels, unsigned int bits,
for (ch = 0; ch < channels; ch++) {
float average_power = 10 * log10((*(power + ch)) / total_sample_per_channel);
if(isinf (average_power)) {
- printf("Channel [%2d] Average Power : NO signal or ZERO signal\n", ch);
+ printf("Channel [%2u] Average Power : NO signal or ZERO signal\n", ch);
} else {
- printf("Channel [%2d] Average Power : %.2f dB\n", ch, average_power);
+ printf("Channel [%2u] Average Power : %.2f dB\n", ch, average_power);
}
}