]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
crush: cleanup in crush_do_rule() method
authorViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Mon, 30 Mar 2026 20:46:53 +0000 (13:46 -0700)
committerViacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Thu, 2 Apr 2026 18:26:22 +0000 (11:26 -0700)
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>
Fixes: 41ebcc0907c5 ("crush: remove forcefeed functionality")
cc: Alex Markuze <amarkuze@redhat.com>
cc: Ilya Dryomov <idryomov@gmail.com>
cc: Patrick Donnelly <pdonnell@redhat.com>
cc: Ceph Development <ceph-devel@vger.kernel.org>
Reviewed-by: Alex Markuze <amarkuze@redhat.com>
Signed-off-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
net/ceph/crush/mapper.c

index 3a5bd1cd1e99f44c9fc688c2912618b1b0634c0c..17b041779fb9da2deb8cdbf58439392d7fa2e8ef 100644 (file)
@@ -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,