Skip to contentSkip to conversation

sunrpc: svc: Remove unnecessary (void*) conversions

PATCH In review Li zeming 4 participants 5 messages Nov 3, 2022 – Nov 4, 2022

Subsystems (2)
lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 sunrpc: svc: Remove unnecessary (void*) conversions

The iov_base pointer does not need to cast the type.

---
 include/linux/sunrpc/svc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sunrpc/svc.h +1 -1
index daecb009c05b..4b0eead91c94 100644
@@ -222,7 +222,7 @@ static inline __be32 svc_getu32(struct kvec *iov)
 
 static inline void svc_ungetu32(struct kvec *iov)
 {
-	__be32 *vp = (__be32 *)iov->iov_base;
+	__be32 *vp = iov->iov_base;
 	iov->iov_base = (void *)(vp - 1);
 	iov->iov_len += sizeof(*vp);
 }
Signature · 1 line
2.18.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Li zeming

The iov_base pointer does not need to cast the type.

---
 include/linux/sunrpc/svc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sunrpc/svc.h +0 -0
index daecb009c05b..4b0eead91c94 100644

include/linux/sunrpc/svc.h static inline __be32 svc_getu32(struct kvec *iov) · line 228

Quoted 8 lines
include/linux/sunrpc/svc.h +1 -1
@@ -222,7 +222,7 @@ static inline __be32 svc_getu32(struct kvec *iov)
 
 static inline void svc_ungetu32(struct kvec *iov)
 {
-	__be32 *vp = (__be32 *)iov->iov_base;
+	__be32 *vp = iov->iov_base;
 	iov->iov_base = (void *)(vp - 1);
 	iov->iov_len += sizeof(*vp);
 }
maintainer
#2 lore raw
In reply to Li zeming
Quoted 12 lines · Li zeming

The iov_base pointer does not need to cast the type.

---
 include/linux/sunrpc/svc.h | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sunrpc/svc.h +0 -0
index daecb009c05b..4b0eead91c94 100644
@@ -222,7 +222,7 @@ static inline __be32 svc_getu32(struct kvec *iov)
Quoted 8 lines


 static inline void svc_ungetu32(struct kvec *iov) {
-       __be32 *vp = (__be32 *)iov->iov_base; +       __be32 *vp = iov->iov_base; iov->iov_base = (void *)(vp - 1); iov->iov_len += sizeof(*vp);
 }

If you're going to submit a patch just in order to strip unnecessary casts, then why are you leaving the equally unnecessary cast in the next line?

That said, why waste time "fixing" an inlined function that is not actually called anywhere in the kernel? svc_ungetu32() should just be removed.

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
#3 lore raw
Quoted 30 lines · Trond Myklebust
Quoted 12 lines · Li zeming

The iov_base pointer does not need to cast the type.

---
 include/linux/sunrpc/svc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sunrpc/svc.h +0 -0
index daecb009c05b..4b0eead91c94 100644

include/linux/sunrpc/svc.h static inline __be32 svc_getu32(struct kvec *iov) · line 228

Quoted 8 lines
include/linux/sunrpc/svc.h +1 -1
@@ -222,7 +222,7 @@ static inline __be32 svc_getu32(struct kvec *iov)
 
 static inline void svc_ungetu32(struct kvec *iov)
 {
-       __be32 *vp = (__be32 *)iov->iov_base;
+       __be32 *vp = iov->iov_base;
        iov->iov_base = (void *)(vp - 1);
        iov->iov_len += sizeof(*vp);
 }

If you're going to submit a patch just in order to strip unnecessary casts, then why are you leaving the equally unnecessary cast in the next line?

Quoted 3 lines

That said, why waste time "fixing" an inlined function that is not actually called anywhere in the kernel? svc_ungetu32() should just be removed.

Sorry for the delay, I was expecting an electrical service outage here at home yesterday, so the lab was powered off.

So, Li, can you drop this one, and instead send a patch that removes the definition of svc_ungetu32 ?

--
Chuck Lever

author
#4 lore raw

of course, I will submit a new one to delete the static svc_ungetu32() function for Patch.