Skip to content

Commit 3a2e519

Browse files
dubeykoidryomov
authored andcommitted
crush: cleanup in crush_do_rule() method
Commit 41ebcc0 ("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 41ebcc0 ("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 removes the dead code. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Reviewed-by: Alex Markuze <amarkuze@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent cc56430 commit 3a2e519

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

net/ceph/crush/mapper.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ int crush_do_rule(const struct crush_map *map,
911911
int osize;
912912
const struct crush_rule *rule;
913913
__u32 step;
914-
int i, j;
914+
int i;
915915
int numrep;
916916
int out_size;
917917
/*
@@ -1012,7 +1012,6 @@ int crush_do_rule(const struct crush_map *map,
10121012
if (numrep <= 0)
10131013
continue;
10141014
}
1015-
j = 0;
10161015
/* make sure bucket id is valid */
10171016
bno = -1 - w[i];
10181017
if (bno < 0 || bno >= map->max_buckets) {
@@ -1036,7 +1035,7 @@ int crush_do_rule(const struct crush_map *map,
10361035
weight, weight_max,
10371036
x, numrep,
10381037
curstep->arg2,
1039-
o+osize, j,
1038+
o+osize, 0,
10401039
result_max-osize,
10411040
choose_tries,
10421041
recurse_tries,
@@ -1058,7 +1057,7 @@ int crush_do_rule(const struct crush_map *map,
10581057
weight, weight_max,
10591058
x, out_size, numrep,
10601059
curstep->arg2,
1061-
o+osize, j,
1060+
o+osize, 0,
10621061
choose_tries,
10631062
choose_leaf_tries ?
10641063
choose_leaf_tries : 1,

0 commit comments

Comments
 (0)