Skip to contentSkip to conversation

riscv,kvm: remove another strerrorname_np()

PATCH Applied Daniel Henrique Barboza 3 participants 6 messages Apr 24, 2024 – Apr 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover riscv,kvm: remove another strerrorname_np()

Hi,

In this new version a small change suggested by Phil was made in patch
2. No other changes made.

Note: checkpatch.pl is nagging quite a bit about the checkpatch.pl change this time, claiming that I'm adding a line > 90 chars when in reality the line has 80 chars:

ERROR: line over 90 characters
#39: FILE: scripts/checkpatch.pl:3082:
+ ERROR("use strerror() instead of strerrorname_np()\n" . $herecurr);

total: 1 errors, 0 warnings, 9 lines checked

I supposed it's counting each TAB as more than one char. Let me know if I need to care about this error and I'll send a v3.

Changes from v1:
- patch 2:
- move the strerrorname_np() check to the "non-portable libc calls"
section
- v1 link: https://lore.kernel.org/qemu-riscv/[email protected]/

Daniel Henrique Barboza (2):
target/riscv/kvm: remove sneaky strerrorname_np() instance checkpatch.pl: forbid strerrorname_np()

 scripts/checkpatch.pl      | 3 +++
 target/riscv/kvm/kvm-cpu.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
2.44.0
#3 lore raw

PATCH v2 2/2 checkpatch.pl: forbid strerrorname_np()

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

---
 scripts/checkpatch.pl | 3 +++
 1 file changed, 3 insertions(+)
scripts/checkpatch.pl +3 -0
index 7026895074..f7ffa74858 100755
@@ -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|
Signature · 1 line
2.44.0
#1 lore raw

PATCH v2 1/2 target/riscv/kvm: remove sneaky strerrorname_np() instance

In reply to Daniel Henrique Barboza

Commit d424db2354 excluded some strerrorname_np() instances because they break musl libc builds. Another instance happened to slip by via commit d4ff3da8f4.

Remove it before it causes trouble again.

Fixes d4ff3da8f4 (target/riscv/kvm: initialize 'vlenb' via get-reg-list)
---
 target/riscv/kvm/kvm-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/kvm/kvm-cpu.c +2 -2
index 6a6c6cae80..ee69ea9785 100644
@@ -1054,8 +1054,8 @@ static void kvm_riscv_read_vlenb(RISCVCPU *cpu, KVMScratchCPU *kvmcpu,
 
         ret = ioctl(kvmcpu->cpufd, KVM_GET_ONE_REG, &reg);
         if (ret != 0) {
-            error_report("Unable to read vlenb register, error code: %s",
-                         strerrorname_np(errno));
+            error_report("Unable to read vlenb register, error code: %d",
+                         errno);
             exit(EXIT_FAILURE);
         }
 
Signature · 1 line
2.44.0
#5 lore raw
In reply to Daniel Henrique Barboza
Quoted 4 lines · Daniel Henrique Barboza

Hi,

In this new version a small change suggested by Phil was made in patch
2. No other changes made.

Applied to trivial-patches tree.

Quoted 8 lines

Note: checkpatch.pl is nagging quite a bit about the checkpatch.pl change this time, claiming that I'm adding a line > 90 chars when in reality the line has 80 chars:

ERROR: line over 90 characters
#39: FILE: scripts/checkpatch.pl:3082:

(quoted diff) +1 -0
+			ERROR("use strerror() instead of strerrorname_np()\n" . $herecurr);
Quoted 4 lines

total: 1 errors, 0 warnings, 9 lines checked

I supposed it's counting each TAB as more than one char. Let me know if I need to care about this error and I'll send a v3.

checkpatch complaining about checkpatch change is nice. Nope, it is the style used here, all other tests are like this too, but worse.

/mjt

Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] target/riscv/kvm: remove sneaky strerrorname_np() instance

In reply to Daniel Henrique Barboza
Quoted 11 lines · Daniel Henrique Barboza

Commit d424db2354 excluded some strerrorname_np() instances because they break musl libc builds. Another instance happened to slip by via commit d4ff3da8f4.

Remove it before it causes trouble again.

Fixes d4ff3da8f4 (target/riscv/kvm: initialize 'vlenb' via get-reg-list)

Alistair

Quoted 23 lines
---
 target/riscv/kvm/kvm-cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/kvm/kvm-cpu.c +2 -3
index 6a6c6cae80..ee69ea9785 100644
@@ -1054,8 +1054,8 @@ static void kvm_riscv_read_vlenb(RISCVCPU *cpu, KVMScratchCPU *kvmcpu,
 
         ret = ioctl(kvmcpu->cpufd, KVM_GET_ONE_REG, &reg);
         if (ret != 0) {
-            error_report("Unable to read vlenb register, error code: %s",
-                         strerrorname_np(errno));
+            error_report("Unable to read vlenb register, error code: %d",
+                         errno);
             exit(EXIT_FAILURE);
         }
 
--

2.44.0

Reviewed-by on v2 2/2
#4 lore raw

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

In reply to Daniel Henrique Barboza
Quoted 13 lines · 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));
Quoted 5 lines

total: 1 errors, 0 warnings, 10 lines checked

Alistair

Quoted 22 lines
---
 scripts/checkpatch.pl | 3 +++
 1 file changed, 3 insertions(+)
scripts/checkpatch.pl +3 -1
index 7026895074..f7ffa74858 100755
@@ -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