Re: [PATCH 2/2] checkpatch.pl: forbid strerrorname_np()

2024-04-24 Thread Philippe Mathieu-Daudé

On 24/4/24 11:47, Daniel Henrique Barboza 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 
---
  scripts/checkpatch.pl | 4 
  1 file changed, 4 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7026895074..be0982246d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3056,6 +3056,10 @@ sub process {
}
}
  
+	if ($line =~ /\bstrerrorname_np\(/) {

+   ERROR("use strerror() instead of strerrorname_np()\n" . 
$herecurr);
+   }
+
  # check for non-portable libc calls that have portable alternatives in QEMU


This should be added here in the "non-portable libc calls" section.


if ($line =~ /\bffs\(/) {
ERROR("use ctz32() instead of ffs()\n" . $herecurr);





Re: [PATCH 2/2] checkpatch.pl: forbid strerrorname_np()

2024-04-24 Thread Thomas Huth

On 24/04/2024 11.47, Daniel Henrique Barboza 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 
---
  scripts/checkpatch.pl | 4 
  1 file changed, 4 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7026895074..be0982246d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3056,6 +3056,10 @@ sub process {
}
}
  
+	if ($line =~ /\bstrerrorname_np\(/) {

+   ERROR("use strerror() instead of strerrorname_np()\n" . 
$herecurr);
+   }
+
  # check for non-portable libc calls that have portable alternatives in QEMU
if ($line =~ /\bffs\(/) {
ERROR("use ctz32() instead of ffs()\n" . $herecurr);


Reviewed-by: Thomas Huth 




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

2024-04-24 Thread Daniel Henrique Barboza
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 
---
 scripts/checkpatch.pl | 4 
 1 file changed, 4 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7026895074..be0982246d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3056,6 +3056,10 @@ sub process {
}
}
 
+   if ($line =~ /\bstrerrorname_np\(/) {
+   ERROR("use strerror() instead of strerrorname_np()\n" . 
$herecurr);
+   }
+
 # check for non-portable libc calls that have portable alternatives in QEMU
if ($line =~ /\bffs\(/) {
ERROR("use ctz32() instead of ffs()\n" . $herecurr);
-- 
2.44.0