Skip to contentSkip to conversation

x86: The return type of the function could be void

PATCH In review Li kunyu 2 participants 2 messages May 6, 2022

Subsystems (4)
lore
Share & tools
lore

Li kunyu

author
#0 lore raw

PATCH 1/1 x86: The return type of the function could be void

Perhaps the return value of the function is not used. It may be possible to optimize the execution instructions.

---
 arch/x86/kvm/hyperv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +3 -4
index 46f9dfb60469..64c0d1f54258 100644
@@ -608,7 +608,7 @@ static enum hrtimer_restart stimer_timer_callback(struct hrtimer *timer)
  * a) stimer->count is not equal to 0
  * b) stimer->config has HV_STIMER_ENABLE flag
  */
-static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
+static void stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 {
 	u64 time_now;
 	ktime_t ktime_now;
@@ -638,7 +638,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 			      ktime_add_ns(ktime_now,
 					   100 * (stimer->exp_time - time_now)),
 			      HRTIMER_MODE_ABS);
-		return 0;
+		return;
 	}
 	stimer->exp_time = stimer->count;
 	if (time_now >= stimer->count) {
@@ -649,7 +649,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 		 * the past, it will expire immediately."
 		 */
 		stimer_mark_pending(stimer, false);
-		return 0;
+		return;
 	}
 
 	trace_kvm_hv_stimer_start_one_shot(hv_stimer_to_vcpu(stimer)->vcpu_id,
@@ -659,7 +659,6 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 	hrtimer_start(&stimer->timer,
 		      ktime_add_ns(ktime_now, 100 * (stimer->count - time_now)),
 		      HRTIMER_MODE_ABS);
-	return 0;
 }
 
 static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,
Signature · 1 line
2.18.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 40 lines · Li kunyu

Perhaps the return value of the function is not used. It may be possible to optimize the execution instructions.

---
 arch/x86/kvm/hyperv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +3 -3
index 46f9dfb60469..64c0d1f54258 100644
@@ -608,7 +608,7 @@ static enum hrtimer_restart stimer_timer_callback(struct hrtimer *timer)
  * a) stimer->count is not equal to 0
  * b) stimer->config has HV_STIMER_ENABLE flag
  */
-static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
+static void stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 {
 	u64 time_now;
 	ktime_t ktime_now;
@@ -638,7 +638,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 			      ktime_add_ns(ktime_now,
 					   100 * (stimer->exp_time - time_now)),
 			      HRTIMER_MODE_ABS);
-		return 0;
+		return;
 	}
 	stimer->exp_time = stimer->count;
 	if (time_now >= stimer->count) {
@@ -649,7 +649,7 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 		 * the past, it will expire immediately."
 		 */
 		stimer_mark_pending(stimer, false);
-		return 0;
+		return;
 	}
 
 	trace_kvm_hv_stimer_start_one_shot(hv_stimer_to_vcpu(stimer)->vcpu_id,

arch/x86/kvm/hyperv.c static int stimer_start(struct kvm_vcpu_hv_stimer *stimer) · line 664

Quoted 7 lines
arch/x86/kvm/hyperv.c +0 -1
@@ -659,7 +659,6 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
 	hrtimer_start(&stimer->timer,
 		      ktime_add_ns(ktime_now, 100 * (stimer->count - time_now)),
 		      HRTIMER_MODE_ABS);
-	return 0;
 }
 
 static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,

stimer_start() has only one user so it'll likely get inlined by the compiler which then will be able to figure out that the return value is not used and thus the assembley code will likely remain the same but this is a good cleanup nevertheless, so

Signature · 1 line
Vitaly