Skip to contentSkip to conversation

asm-generic: Remove unnecessary ‘0’ values from guest_id

PATCH In review Li zeming 2 participants 3 messages Sep 19, 2022 – Sep 20, 2022

Subsystems (3)
lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 asm-generic: Remove unnecessary ‘0’ values from guest_id

The file variable is assigned guest_id, it does not need to be initialized.

---
 include/asm-generic/mshyperv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/mshyperv.h +1 -1
index c05d2ce9b6cd..cd5ce86c218a 100644
@@ -108,7 +108,7 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
 static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 				       __u64 d_info2)
 {
-	__u64 guest_id = 0;
+	__u64 guest_id;
 
 	guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
 	guest_id |= (d_info1 << 48);
Signature · 1 line
2.18.2
#1 lore raw
Quoted 12 lines · Li zeming

The file variable is assigned guest_id, it does not need to be initialized.

---
 include/asm-generic/mshyperv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/mshyperv.h +0 -0
index c05d2ce9b6cd..cd5ce86c218a 100644

include/asm-generic/mshyperv.h static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size, · line 114

Quoted 8 lines
include/asm-generic/mshyperv.h +1 -1
@@ -108,7 +108,7 @@ static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
 static inline  __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,
 				       __u64 d_info2)
 {
-	__u64 guest_id = 0;
+	__u64 guest_id;
 
 	guest_id = (((__u64)HV_LINUX_VENDOR_ID) << 48);
 	guest_id |= (d_info1 << 48);

The initializer is certainly not needed, however, if we are to do some changes, let's be bold. Suggestions:

1) Stop using "__u64" type, "u64" is good enough.

2) Drop all the parameters from the function, both call sites look like

generate_guest_id(0, LINUX_VERSION_CODE, 0);

3) Rename the function to make it clear it's Hyper-V related, e.g. "hv_generate_guest_id()".

...

Signature · 1 line
Vitaly
author
#2 lore raw

Thank you very much for your suggestion. I will submit the new version after passing the test code.