libceph: cleanup in crush_do_rule() method
Viacheslav Dubeyko
maintainerPATCH 1/1 libceph: cleanup in crush_do_rule() method
From: Viacheslav Dubeyko <[email protected]>
Commit 41ebcc0907c5 ("crush: remove forcefeed functionality") from May 7, 2012 (linux-next), leads to the following Smatch static checker warning:
net/ceph/crush/mapper.c:1015 crush_do_rule() warn: iterator 'j' not incremented
Before commit 41ebcc0907c5 ("crush: remove forcefeed functionality"), we had this logic:
j = 0;
if (osize == 0 && force_pos >= 0) {
o[osize] = force_context[force_pos];
if (recurse_to_leaf)
c[osize] = force_context[0];
j++; /* <-- this was the only increment, now gone */
force_pos--;
}
/* then crush_choose_*(..., o+osize, j, ...) */Now, the variable j is dead code — a variable that is set and never meaningfully varied. This patch simply remove the dead code.
--- net/ceph/crush/mapper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/ceph/crush/mapper.c +3 -4
@@ -911,7 +911,7 @@ int crush_do_rule(const struct crush_map *map,int osize;const struct crush_rule *rule;__u32 step; -int i, j; +int i;int numrep;int out_size;/*
@@ -1012,7 +1012,6 @@ int crush_do_rule(const struct crush_map *map,if (numrep <=0 )continue ; } - j =0 ;/* make sure bucket id is valid */ bno =-1 - w[i];if (bno <0 || bno >= map->max_buckets) {
@@ -1036,7 +1035,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , result_max-osize, choose_tries, recurse_tries,
@@ -1058,7 +1057,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, out_size, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , choose_tries, choose_leaf_tries ? choose_leaf_tries : 1,
Signature · 1 line
2.53.0
Looks good, but here are a couple of nits:
1. The subject prefix uses libceph: but the file changed isnet/ceph/crush/mapper.c. The conventional prefix for CRUSH code is
crush: (which is also what the original commit you reference in the Fixes tag uses). Something like crush: remove
dead variable j from crush_do_rule() would be more accurate.
2. Small typo in the commit message: "This patch simply remove the
dead code" → "removes".
Quoted 80 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
Commit
41ebcc0907c5("crush: remove forcefeed functionality") from May 7, 2012 (linux-next), leads to the following Smatch static checker warning:
net/ceph/crush/mapper.c:1015crush_do_rule()
warn: iterator 'j' not incrementedBefore commit
41ebcc0907c5("crush: remove forcefeed functionality"), we had this logic:j = 0; if (osize == 0 && force_pos >= 0) { o[osize] = force_context[force_pos]; if (recurse_to_leaf) c[osize] = force_context[0]; j++; /* <-- this was the only increment, now gone */ force_pos--; } /* then crush_choose_*(..., o+osize, j, ...) */Now, the variable j is dead code — a variable that is set and never meaningfully varied. This patch simply remove the dead code.
Reported-by Dan Carpenter <[email protected]>Fixes 41ebcc0907c5 ("crush: remove forcefeed functionality")Signed-off-by Viacheslav Dubeyko <[email protected]>cc Alex Markuze <[email protected]>cc Ilya Dryomov <[email protected]>cc Patrick Donnelly <[email protected]>cc Ceph Development <[email protected]>--- net/ceph/crush/mapper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/ceph/crush/mapper.c +3
-5@@ -911,7 +911,7 @@ int crush_do_rule(const struct crush_map *map,int osize;const struct crush_rule *rule;__u32 step; -int i, j; +int i;int numrep;int out_size;/* @@ -1012,7 +1012,6 @@ int crush_do_rule(const struct crush_map *map,if (numrep <=0 )continue ; } - j =0 ;/* make sure bucket id is valid */ bno =-1 - w[i];if (bno <0 || bno >= map->max_buckets) {@@ -1036,7 +1035,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , result_max-osize, choose_tries, recurse_tries,@@ -1058,7 +1057,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, out_size, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , choose_tries, choose_leaf_tries ? choose_leaf_tries : 1, --2.53.0
Quoted 7 lines · Alex Markuze
Looks good, but here are a couple of nits:
1. The subject prefix uses libceph: but the file changed is
net/ceph/crush/mapper.c. The conventional prefix for CRUSH code is
crush: (which is also what the original commit you reference in the Fixes tag uses). Something like crush: remove
dead variable j fromcrush_do_rule()would be more accurate.
Probably, it will be better to have "libceph/crush:" because crush is a subsystem of libceph. But I am OK with "crush:" if everyone can follow which subsystem is under the fix.
Quoted 3 lines
2. Small typo in the commit message: "This patch simply remove the
dead code" → "removes".
I can address these comments in second version of the patch if you like. But it sounds like not major ones. So, I assume that I can leave the patch as it is.
Thanks,
Slava.
Quoted 84 lines
Reviewed-by Alex Markuze <[email protected]>Quoted 80 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
Commit
41ebcc0907c5("crush: remove forcefeed functionality") from May 7, 2012 (linux-next), leads to the following Smatch static checker warning:
net/ceph/crush/mapper.c:1015crush_do_rule()
warn: iterator 'j' not incrementedBefore commit
41ebcc0907c5("crush: remove forcefeed functionality"), we had this logic:j = 0; if (osize == 0 && force_pos >= 0) { o[osize] = force_context[force_pos]; if (recurse_to_leaf) c[osize] = force_context[0]; j++; /* <-- this was the only increment, now gone */ force_pos--; } /* then crush_choose_*(..., o+osize, j, ...) */Now, the variable j is dead code — a variable that is set and never meaningfully varied. This patch simply remove the dead code.
Reported-by Dan Carpenter <[email protected]>Fixes 41ebcc0907c5 ("crush: remove forcefeed functionality")Signed-off-by Viacheslav Dubeyko <[email protected]>cc Alex Markuze <[email protected]>cc Ilya Dryomov <[email protected]>cc Patrick Donnelly <[email protected]>cc Ceph Development <[email protected]>--- net/ceph/crush/mapper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/ceph/crush/mapper.c +3
-5@@ -911,7 +911,7 @@ int crush_do_rule(const struct crush_map *map,int osize;const struct crush_rule *rule;__u32 step; -int i, j; +int i;int numrep;int out_size;/* @@ -1012,7 +1012,6 @@ int crush_do_rule(const struct crush_map *map,if (numrep <=0 )continue ; } - j =0 ;/* make sure bucket id is valid */ bno =-1 - w[i];if (bno <0 || bno >= map->max_buckets) {@@ -1036,7 +1035,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , result_max-osize, choose_tries, recurse_tries,@@ -1058,7 +1057,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, out_size, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , choose_tries, choose_leaf_tries ? choose_leaf_tries : 1, --2.53.0
Alex Markuze
maintainerAs I said, nits; its your call.
Quoted 108 lines · Viacheslav Dubeyko
Quoted 7 lines · Alex Markuze
Looks good, but here are a couple of nits:
1. The subject prefix uses libceph: but the file changed is
net/ceph/crush/mapper.c. The conventional prefix for CRUSH code is
crush: (which is also what the original commit you reference in the Fixes tag uses). Something like crush: remove
dead variable j fromcrush_do_rule()would be more accurate.Probably, it will be better to have "libceph/crush:" because crush is a subsystem of libceph. But I am OK with "crush:" if everyone can follow which subsystem is under the fix.
Quoted 3 lines
2. Small typo in the commit message: "This patch simply remove the
dead code" → "removes".I can address these comments in second version of the patch if you like. But it sounds like not major ones. So, I assume that I can leave the patch as it is.
Thanks,
Slava.Quoted 84 lines
Reviewed-by Alex Markuze <[email protected]>Quoted 80 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
Commit
41ebcc0907c5("crush: remove forcefeed functionality") from May 7, 2012 (linux-next), leads to the following Smatch static checker warning:
net/ceph/crush/mapper.c:1015crush_do_rule()
warn: iterator 'j' not incrementedBefore commit
41ebcc0907c5("crush: remove forcefeed functionality"), we had this logic:j = 0; if (osize == 0 && force_pos >= 0) { o[osize] = force_context[force_pos]; if (recurse_to_leaf) c[osize] = force_context[0]; j++; /* <-- this was the only increment, now gone */ force_pos--; } /* then crush_choose_*(..., o+osize, j, ...) */Now, the variable j is dead code — a variable that is set and never meaningfully varied. This patch simply remove the dead code.
Reported-by Dan Carpenter <[email protected]>Fixes 41ebcc0907c5 ("crush: remove forcefeed functionality")Signed-off-by Viacheslav Dubeyko <[email protected]>cc Alex Markuze <[email protected]>cc Ilya Dryomov <[email protected]>cc Patrick Donnelly <[email protected]>cc Ceph Development <[email protected]>--- net/ceph/crush/mapper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)net/ceph/crush/mapper.c +3
-5@@ -911,7 +911,7 @@ int crush_do_rule(const struct crush_map *map,int osize;const struct crush_rule *rule;__u32 step; -int i, j; +int i;int numrep;int out_size;/* @@ -1012,7 +1012,6 @@ int crush_do_rule(const struct crush_map *map,if (numrep <=0 )continue ; } - j =0 ;/* make sure bucket id is valid */ bno =-1 - w[i];if (bno <0 || bno >= map->max_buckets) {@@ -1036,7 +1035,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , result_max-osize, choose_tries, recurse_tries,@@ -1058,7 +1057,7 @@ int crush_do_rule(const struct crush_map *map, weight, weight_max, x, out_size, numrep, curstep->arg2, - o+osize, j, + o+osize,0 , choose_tries, choose_leaf_tries ? choose_leaf_tries : 1, --2.53.0