Minor fixes of compiler warnings and one bug in the number of parameters which
would not crash the test but it is better fixed for correctness sake.
As the general climate in the Linux kernel community is to fix all compiler
warnings, this could be on the right track, even if only in the testing suite.
Mirsad Todorovac (4):
kselftest: alsa: fix the number of parameters to ksft_exit_fail_msg()
kselftest: alsa: Fix the printf format specifier in call to
ksft_print_msg()
ksellftest: alsa: Fix the printf format specifier to unsigned int
selftests: alsa: Fix the exit error message parameter in sysfs_get()
tools/testing/selftests/alsa/conf.c | 2 +-
tools/testing/selftests/alsa/mixer-test.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
--
2.40.1
Fix the number of arguments to error reporting function in the test program
as reported in the GCC 13.2.0 warning:
mixer-test.c: In function ‘find_controls’:
mixer-test.c:169:44: warning: too many arguments for format [-Wformat-extra-args]
169 | ksft_exit_fail_msg("snd_ctl_poll_descriptors() failed for %d\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The number of arguments in call to ksft_exit_fail_msg() doesn't correspond
to the format specifiers, so this is adjusted to mimic the sibling calls
to the error function.
Fixes: b1446bda56456 ("kselftest: alsa: Check for event generation when we write to controls")
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Mirsad Todorovac <[email protected]>
---
tools/testing/selftests/alsa/mixer-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index 23df154fcdd7..208c2170c074 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -166,7 +166,7 @@ static void find_controls(void)
err = snd_ctl_poll_descriptors(card_data->handle,
&card_data->pollfd, 1);
if (err != 1) {
- ksft_exit_fail_msg("snd_ctl_poll_descriptors() failed for %d\n",
+ ksft_exit_fail_msg("snd_ctl_poll_descriptors() failed for card %d: %d\n",
card, err);
}
--
2.40.1
The GCC 13.2.0 compiler issued the following warning:
mixer-test.c: In function ‘ctl_value_index_valid’:
mixer-test.c:322:79: warning: format ‘%lld’ expects argument of type ‘long long int’, \
but argument 5 has type ‘long int’ [-Wformat=]
322 | ksft_print_msg("%s.%d value %lld more than maximum %lld\n",
| ~~~^
| |
| long long int
| %ld
323 | ctl->name, index, int64_val,
324 | snd_ctl_elem_info_get_max(ctl->info));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| long int
Fixing the format specifier as advised by the compiler suggestion removes the
warning.
Fixes: 3f48b137d88e7 ("kselftest: alsa: Factor out check that values meet constraints")
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Mirsad Todorovac <[email protected]>
---
tools/testing/selftests/alsa/mixer-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index 208c2170c074..df942149c6f6 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -319,7 +319,7 @@ static bool ctl_value_index_valid(struct ctl_data *ctl,
}
if (int64_val > snd_ctl_elem_info_get_max64(ctl->info)) {
- ksft_print_msg("%s.%d value %lld more than maximum %lld\n",
+ ksft_print_msg("%s.%d value %lld more than maximum %ld\n",
ctl->name, index, int64_val,
snd_ctl_elem_info_get_max(ctl->info));
return false;
--
2.40.1
GCC 13.2.0 compiler issued the following warning:
mixer-test.c:350:80: warning: format ‘%ld’ expects argument of type ‘long int’, \
but argument 5 has type ‘unsigned int’ [-Wformat=]
350 | ksft_print_msg("%s.%d value %ld more than item count %ld\n",
| ~~^
| |
| long int
| %d
351 | ctl->name, index, int_val,
352 | snd_ctl_elem_info_get_items(ctl->info));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| unsigned int
Fixing the format specifier in call to ksft_print_msg() according to the
compiler suggestion silences the warning.
Fixes: 10f2f194663af ("kselftest: alsa: Validate values read from enumerations")
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Mirsad Todorovac <[email protected]>
---
tools/testing/selftests/alsa/mixer-test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c
index df942149c6f6..e3708cc52db7 100644
--- a/tools/testing/selftests/alsa/mixer-test.c
+++ b/tools/testing/selftests/alsa/mixer-test.c
@@ -347,7 +347,7 @@ static bool ctl_value_index_valid(struct ctl_data *ctl,
}
if (int_val >= snd_ctl_elem_info_get_items(ctl->info)) {
- ksft_print_msg("%s.%d value %ld more than item count %ld\n",
+ ksft_print_msg("%s.%d value %ld more than item count %d\n",
ctl->name, index, int_val,
snd_ctl_elem_info_get_items(ctl->info));
return false;
--
2.40.1
On Sun, Jan 07, 2024 at 04:12:18PM +0100, Mirsad Todorovac wrote:
> The GCC 13.2.0 compiler issued the following warning:
>
> mixer-test.c: In function ‘ctl_value_index_valid’:
> mixer-test.c:322:79: warning: format ‘%lld’ expects argument of type ‘long long int’, \
Acked-by: Mark Brown <[email protected]>
Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.
On Sun, Jan 07, 2024 at 04:12:16PM +0100, Mirsad Todorovac wrote:
> Fix the number of arguments to error reporting function in the test program
> as reported in the GCC 13.2.0 warning:
Acked-by: Mark Brown <[email protected]>
On Sun, Jan 07, 2024 at 04:12:20PM +0100, Mirsad Todorovac wrote:
> mixer-test.c:350:80: warning: format ‘%ld’ expects argument of type ‘long int’, \
> but argument 5 has type ‘unsigned int’ [-Wformat=]
If this is the issue then...
> - ksft_print_msg("%s.%d value %ld more than item count %ld\n",
> + ksft_print_msg("%s.%d value %ld more than item count %d\n",
> ctl->name, index, int_val,
> snd_ctl_elem_info_get_items(ctl->info));
...why are we not using an unsigned format specifier here? I am very
suprised this doesn't continue to warn.
Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.
GCC 13.2.0 reported the warning of the print format specifier:
conf.c: In function ‘sysfs_get’:
conf.c:181:72: warning: format ‘%s’ expects argument of type ‘char *’, \
but argument 3 has type ‘int’ [-Wformat=]
181 | ksft_exit_fail_msg("sysfs: unable to read value '%s': %s\n",
| ~^
| |
| char *
| %d
The fix passes strerror(errno) as it was intended, like in the sibling error
exit message.
Fixes: aba51cd0949ae ("selftests: alsa - add PCM test")
Cc: Mark Brown <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Mirsad Todorovac <[email protected]>
---
tools/testing/selftests/alsa/conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/alsa/conf.c b/tools/testing/selftests/alsa/conf.c
index 00925eb8d9f4..89e3656a042d 100644
--- a/tools/testing/selftests/alsa/conf.c
+++ b/tools/testing/selftests/alsa/conf.c
@@ -179,7 +179,7 @@ static char *sysfs_get(const char *sysfs_root, const char *id)
close(fd);
if (len < 0)
ksft_exit_fail_msg("sysfs: unable to read value '%s': %s\n",
- path, errno);
+ path, strerror(errno));
while (len > 0 && path[len-1] == '\n')
len--;
path[len] = '\0';
--
2.40.1
On 07. 01. 2024. 16:33, Mark Brown wrote:
> On Sun, Jan 07, 2024 at 04:12:20PM +0100, Mirsad Todorovac wrote:
>
>> mixer-test.c:350:80: warning: format ‘%ld’ expects argument of type ‘long int’, \
>> but argument 5 has type ‘unsigned int’ [-Wformat=]
>
> If this is the issue then...
>
>> - ksft_print_msg("%s.%d value %ld more than item count %ld\n",
>> + ksft_print_msg("%s.%d value %ld more than item count %d\n",
>> ctl->name, index, int_val,
>> snd_ctl_elem_info_get_items(ctl->info));
>
> ...why are we not using an unsigned format specifier here? I am very
> suprised this doesn't continue to warn.
I double-checked and there is no warning, but I will fix it as you
suggested.
> Please submit patches using subject lines reflecting the style for the
> subsystem, this makes it easier for people to identify relevant patches.
> Look at what existing commits in the area you're changing are doing and
> make sure your subject lines visually resemble what they're doing.
> There's no need to resubmit to fix this alone.
I am just looking at the `git log --oneline tools/testing/selftests/alsa`
and I can't seem to get inspiration.
I guess I can keep the Acked-by tags. Will the patchwork find the tag in
the v1 patch set?
Sorry for the lag in [PATCH v1 4/4]. I thought I pressed submit, but I
obviously did not.
Thanks,
Mirsad
--
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
The European Union
"I see something approaching fast ... Will it be friends with me?"
On Sun, Jan 07, 2024 at 05:21:00PM +0100, Mirsad Todorovac wrote:
> I guess I can keep the Acked-by tags. Will the patchwork find the tag in
> the v1 patch set?
No, you need to include it.
On 07. 01. 2024. 19:14, Mark Brown wrote:
> On Sun, Jan 07, 2024 at 05:21:00PM +0100, Mirsad Todorovac wrote:
>
>> I guess I can keep the Acked-by tags. Will the patchwork find the tag in
>> the v1 patch set?
>
> No, you need to include it.
Great. Sent v2 for review.
I heard that there is a rule "one version per day or when confirmed"?
Nevertheless, these are minor fixes in the error reporting logic (though
no change is small enough to bee taken lightly), so I am sending now
because I don't know about the load tomorrow.
Please find v2 of the patch set on the LKML.
Kept two ACKs (code unchnaged), two left to review.
Thanks,
Mirsad
--
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
The European Union
"I see something approaching fast ... Will it be friends with me?"
s/ksellftest/kselftest/
--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
On 07. 01. 2024. 19:40, Andreas Schwab wrote:
> s/ksellftest/kselftest/
Thx.
Fixed in v2.
Thanks,
Mirsad
--
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
The European Union
"I see something approaching fast ... Will it be friends with me?"