arch/x86/xen/time.c: fix bugon.cocci warnings
Subsystems (2)
PATCH 1/1 arch/x86/xen/time.c: fix bugon.cocci warnings
From: Jing Yangyang <[email protected]>
Use BUG_ON instead of a if condition followed by BUG.
Generated by: scripts/coccinelle/misc/bugon.cocci
--- arch/x86/xen/time.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
arch/x86/xen/time.c +8 -12
@@ -210,8 +210,7 @@ static int xen_timerop_set_next_event(unsigned long delta, {WARN_ON (!clockevent_state_oneshot (evt)); -if (HYPERVISOR_set_timer_op (get_abs_timeout (delta)) <0 ) -BUG (); +BUG_ON (HYPERVISOR_set_timer_op (get_abs_timeout (delta)) <0 );/* We may have missed the deadline, but there's no real way of knowing for sure. If the event was in the past, then we'll
@@ -241,11 +240,10 @@ static int xen_vcpuop_shutdown(struct clock_event_device *evt) {int cpu =smp_processor_id (); -if (HYPERVISOR_vcpu_op (VCPUOP_stop_singleshot_timer,xen_vcpu_nr (cpu), +BUG_ON (HYPERVISOR_vcpu_op (VCPUOP_stop_singleshot_timer,xen_vcpu_nr (cpu),NULL ) || -HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), -NULL )) -BUG (); +HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), +NULL ));return 0 ; }
@@ -254,9 +252,8 @@ static int xen_vcpuop_set_oneshot(struct clock_event_device *evt) {int cpu =smp_processor_id (); -if (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), -NULL )) -BUG (); +BUG_ON (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), +NULL ));return 0 ; }
@@ -373,9 +370,8 @@ void xen_timer_resume(void)return ;for_each_online_cpu (cpu) { -if (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer, -xen_vcpu_nr (cpu),NULL )) -BUG (); +BUG_ON (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer, +xen_vcpu_nr (cpu),NULL )); } }
Signature · 1 line
1.8.3.1
Juergen Gross
maintainerQuoted 27 lines · CGEL
From: Jing Yangyang <[email protected]>
Use
BUG_ONinstead of a if condition followed by BUG.Generated by:
scripts/coccinelle/misc/bugon.cocciReported-by Zeal Robot <[email protected]>Signed-off-by Jing Yangyang <[email protected]>--- arch/x86/xen/time.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)arch/x86/xen/time.c +1
-2@@ -210,8 +210,7 @@ static int xen_timerop_set_next_event(unsigned long delta, {WARN_ON (!clockevent_state_oneshot (evt)); -if (HYPERVISOR_set_timer_op (get_abs_timeout (delta)) <0 ) -BUG (); +BUG_ON (HYPERVISOR_set_timer_op (get_abs_timeout (delta)) <0 );/* We may have missed the deadline, but there's no real way of knowing for sure. If the event was in the past, then we'll
arch/x86/xen/time.c static int xen_vcpuop_shutdown(struct clock_event_device *evt) · line 244
Quoted 6 lines
arch/x86/xen/time.c +1
-1@@ -241,11 +240,10 @@ static int xen_vcpuop_shutdown(struct clock_event_device *evt) {int cpu =smp_processor_id (); - if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, xen_vcpu_nr(cpu), + BUG_ON(HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, xen_vcpu_nr(cpu), NULL) ||
Please adjust the alignment of the continuation line (i.e. insert 2 blanks). Same below.
Even better would be to avoid the repeated "xen_vcpu_nr(cpu)" by using "int vcpu = xen_vcpu_nr(smp_processor_id());" leading to the possibility to not need the continuation lines at all.
Quoted 9 lines
arch/x86/xen/time.c +2
-3- HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu), - NULL)) -BUG (); +HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), + NULL));return 0 ; }
arch/x86/xen/time.c static int xen_vcpuop_set_oneshot(struct clock_event_device *evt) · line 256
Quoted 8 lines
arch/x86/xen/time.c +2
-3@@ -254,9 +252,8 @@ static int xen_vcpuop_set_oneshot(struct clock_event_device *evt) {int cpu =smp_processor_id (); -if (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), -NULL )) -BUG (); +BUG_ON (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer,xen_vcpu_nr (cpu), +NULL ));
See above.
arch/x86/xen/time.c void xen_timer_resume(void) · line 374
Quoted 12 lines
arch/x86/xen/time.c +2
-3return 0 ; }@@ -373,9 +370,8 @@ void xen_timer_resume(void)return ;for_each_online_cpu (cpu) { -if (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer, -xen_vcpu_nr (cpu),NULL )) -BUG (); +BUG_ON (HYPERVISOR_vcpu_op (VCPUOP_stop_periodic_timer, +xen_vcpu_nr (cpu),NULL ));
See above.
Juergen