Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crush: cleanup in crush_do_rule() method

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 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>

authored by

Viacheslav Dubeyko and committed by
Ilya Dryomov
3a2e519c cc564309

+3 -4
+3 -4
net/ceph/crush/mapper.c
··· 911 911 int osize; 912 912 const struct crush_rule *rule; 913 913 __u32 step; 914 - int i, j; 914 + int i; 915 915 int numrep; 916 916 int out_size; 917 917 /* ··· 1012 1012 if (numrep <= 0) 1013 1013 continue; 1014 1014 } 1015 - j = 0; 1016 1015 /* make sure bucket id is valid */ 1017 1016 bno = -1 - w[i]; 1018 1017 if (bno < 0 || bno >= map->max_buckets) { ··· 1035 1036 weight, weight_max, 1036 1037 x, numrep, 1037 1038 curstep->arg2, 1038 - o+osize, j, 1039 + o+osize, 0, 1039 1040 result_max-osize, 1040 1041 choose_tries, 1041 1042 recurse_tries, ··· 1057 1058 weight, weight_max, 1058 1059 x, out_size, numrep, 1059 1060 curstep->arg2, 1060 - o+osize, j, 1061 + o+osize, 0, 1061 1062 choose_tries, 1062 1063 choose_leaf_tries ? 1063 1064 choose_leaf_tries : 1,