diff mbox series

[v2,2/2] checkpatch.pl: forbid strerrorname_np()

Message ID 20240424202425.534338-3-dbarboza@ventanamicro.com (mailing list archive)
State New, archived
Headers show
Series riscv,kvm: remove another strerrorname_np() | expand

Commit Message

Daniel Henrique Barboza April 24, 2024, 8:24 p.m. UTC
Commit d424db2354 removed an instance of strerrorname_np() because it
was breaking building with musl libc. A recent RISC-V patch ended up
re-introducing it again by accident.

Put this function in the baddies list in checkpatch.pl to avoid this
situation again. This is what it will look like next time:

 $ ./scripts/checkpatch.pl 0001-temp-test.patch
 ERROR: use strerror() instead of strerrorname_np()
 #22: FILE: target/riscv/kvm/kvm-cpu.c:1058:
 +                         strerrorname_np(errno));

 total: 1 errors, 0 warnings, 10 lines checked

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 scripts/checkpatch.pl | 3 +++
 1 file changed, 3 insertions(+)

Comments

Alistair Francis April 29, 2024, 2:16 a.m. UTC | #1
On Thu, Apr 25, 2024 at 6:26 AM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
> Commit d424db2354 removed an instance of strerrorname_np() because it
> was breaking building with musl libc. A recent RISC-V patch ended up
> re-introducing it again by accident.
>
> Put this function in the baddies list in checkpatch.pl to avoid this
> situation again. This is what it will look like next time:
>
>  $ ./scripts/checkpatch.pl 0001-temp-test.patch
>  ERROR: use strerror() instead of strerrorname_np()
>  #22: FILE: target/riscv/kvm/kvm-cpu.c:1058:
>  +                         strerrorname_np(errno));
>
>  total: 1 errors, 0 warnings, 10 lines checked
>
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  scripts/checkpatch.pl | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 7026895074..f7ffa74858 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3078,6 +3078,9 @@ sub process {
>                 if ($line =~ /\b(g_)?assert\(0\)/) {
>                         ERROR("use g_assert_not_reached() instead of assert(0)\n" . $herecurr);
>                 }
> +               if ($line =~ /\bstrerrorname_np\(/) {
> +                       ERROR("use strerror() instead of strerrorname_np()\n" . $herecurr);
> +               }
>                 my $non_exit_glib_asserts = qr{g_assert_cmpstr|
>                                                 g_assert_cmpint|
>                                                 g_assert_cmpuint|
> --
> 2.44.0
>
>
diff mbox series

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7026895074..f7ffa74858 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3078,6 +3078,9 @@  sub process {
 		if ($line =~ /\b(g_)?assert\(0\)/) {
 			ERROR("use g_assert_not_reached() instead of assert(0)\n" . $herecurr);
 		}
+		if ($line =~ /\bstrerrorname_np\(/) {
+			ERROR("use strerror() instead of strerrorname_np()\n" . $herecurr);
+		}
 		my $non_exit_glib_asserts = qr{g_assert_cmpstr|
 						g_assert_cmpint|
 						g_assert_cmpuint|