xenalyze: fixes for gcc-6's -Wmisleading-indentation
cover xenalyze: fixes for gcc-6's -Wmisleading-indentation
Debian bug 812166[0] concerned failures due to -Werror=misleading- indentation when building the Xen package.
While trying (and failing) to reproduce those failures I came across these two warnings in xenalyze, one relating to misleading indenation and the other for unused code.
Cheers,
Ian.
[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812166
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH 1/2 xenalyze: fix misleading indentation.
gcc-6 adds -Wmisleading-indentation which found these issues.
xenalyze.c: In function 'weighted_percentile':
xenalyze.c:2136:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
L=I; L_weight = I_weight;
^~~~~~~~xenalyze.c:2135:9: note: ...this 'if' clause, but it is not
if(J_weight<K_weight)
^~xenalyze.c:2138:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
R=J; R_weight = J_weight;
^~~~~~~~xenalyze.c:2137:9: note: ...this 'if' clause, but it is not
if(K_weight<I_weight)
^~xenalyze.c: In function 'self_weighted_percentile':
xenalyze.c:2215:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
L=I; L_weight = I_weight;
^~~~~~~~xenalyze.c:2214:9: note: ...this 'if' clause, but it is not
if(J_weight<K_weight)
^~xenalyze.c:2217:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
R=J; R_weight = J_weight;
^~~~~~~~xenalyze.c:2216:9: note: ...this 'if' clause, but it is not
if(K_weight<I_weight)
^~I've modified according to what I think the intention is, i.e. added braces rather than moving the line in question out a level.
I have only build tested the result.
--- tools/xentrace/xenalyze.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
tools/xentrace/xenalyze.c +16 -8
@@ -2132,10 +2132,14 @@ float weighted_percentile(float * A, /* values */ }while (I <=J );/* Keep going until our pointers meet or pass */ /* Re-adjust L and R, based on which element we're looking for */ -if (J_weight<K_weight) -L =I ; L_weight = I_weight; -if (K_weight<I_weight) -R =J ; R_weight = J_weight; +if (J_weight<K_weight) { +L =I ; + L_weight = I_weight; + } +if (K_weight<I_weight) { +R =J ; + R_weight = J_weight; + } }return A [L ];
@@ -2211,10 +2215,14 @@ long long self_weighted_percentile(long long * A, }while (I <=J );/* Keep going until our pointers meet or pass */ /* Re-adjust L and R, based on which element we're looking for */ -if (J_weight<K_weight) -L =I ; L_weight = I_weight; -if (K_weight<I_weight) -R =J ; R_weight = J_weight; +if (J_weight<K_weight) { +L =I ; + L_weight = I_weight; + } +if (K_weight<I_weight) { +R =J ; + R_weight = J_weight; + } }return A [L ];
Signature · 1 line
2.6.1
Re: [PATCH 1/2] xenalyze: fix misleading indentation.
Quoted 36 lines · Ian Campbell
gcc-6 adds -Wmisleading-indentation which found these issues.
xenalyze.c: In function 'weighted_percentile':
xenalyze.c:2136:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]L=I; L_weight = I_weight; ^~~~~~~~xenalyze.c:2135:9: note: ...this 'if' clause, but it is not
if(J_weight<K_weight) ^~xenalyze.c:2138:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
R=J; R_weight = J_weight; ^~~~~~~~xenalyze.c:2137:9: note: ...this 'if' clause, but it is not
if(K_weight<I_weight) ^~
xenalyze.c: In function 'self_weighted_percentile':
xenalyze.c:2215:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]L=I; L_weight = I_weight; ^~~~~~~~xenalyze.c:2214:9: note: ...this 'if' clause, but it is not
if(J_weight<K_weight) ^~xenalyze.c:2217:18: error: statement is indented as if it were guarded by... [-Werror=misleading-indentation]
R=J; R_weight = J_weight; ^~~~~~~~xenalyze.c:2216:9: note: ...this 'if' clause, but it is not
if(K_weight<I_weight) ^~
Quoted 6 lines
I've modified according to what I think the intention is, i.e. added braces rather than moving the line in question out a level.
I have only build tested the result.
Signed-off-by Ian Campbell <[email protected]>
!!!
Hrm, well obviously the "weighted percentiles" have been wonky for a long time. :-/
PATCH 2/2 xenalyze: remove cr3_compare_total
In reply to Ian Campbellgcc-6 complains:
xenalyze.c:4132:9: error: 'cr3_compare_total' defined but not used [-Werror=unused-function]
int cr3_compare_total(const void *_a, const void *_b) {
^~~~~~~~~~~~~~~~~I believe it is correct.
--- tools/xentrace/xenalyze.c | 17 ----------------- 1 file changed, 17 deletions(-)
tools/xentrace/xenalyze.c +0 -17
@@ -4129,23 +4129,6 @@ void cr3_dump_list(struct cr3_value_struct *head){struct cr3_value_struct **qsort_array;int i,N =0 ; -int cr3_compare_total (const void *_a,const void *_b) { - struct cr3_value_struct *a=*(typeof(&a))_a; - struct cr3_value_struct *b=*(typeof(&a))_b; - -if (a->total_time.cycles < b->total_time.cycles) -return 1 ; -else if (b->total_time.cycles == a->total_time.cycles) { -if (a->total_time.count < b->total_time.count) -return 1 ; -else if (a->total_time.count == b->total_time.count) -return 0 ; -else -return -1 ; - }else -return -1 ; - } -int cr3_compare_start (const void *_a,const void *_b) { struct cr3_value_struct *a=*(typeof(&a))_a; struct cr3_value_struct *b=*(typeof(&a))_b;
Signature · 1 line
2.6.1
Re: [PATCH 2/2] xenalyze: remove cr3_compare_total
Quoted 8 lines · Ian Campbell
gcc-6 complains:
xenalyze.c:4132:9: error: 'cr3_compare_total' defined but not used [-Werror=unused-function]int cr3_compare_total(const void *_a, const void *_b) { ^~~~~~~~~~~~~~~~~I believe it is correct.
Signed-off-by Ian Campbell <[email protected]>
Thanks,
Quoted 7 lines · Ian Campbell
Debian bug 812166[0] concerned failures due to -Werror=misleading- indentation when building the Xen package.
While trying (and failing) to reproduce those failures I came across these
two warnings in xenalyze, one relating to misleading indenation and the other for unused code.
Applied both with George's R-by.