]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kernel-pidc-improve-flow-of-a-loop-inside-alloc_pidmap-fix
authorAndrew Morton <akpm@linux-foundation.org>
Tue, 26 Mar 2013 23:26:04 +0000 (10:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 4 Apr 2013 06:26:28 +0000 (17:26 +1100)
simplify code

Cc: Raphael S. Carvalho <raphael.scarv@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/pid.c

index 53a78d41331c7e16b0d8ec42eb97ac531f364332..8147bdf22f36a498f0ed108be8e50b20d5f02ed5 100644 (file)
@@ -183,15 +183,19 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
                                break;
                }
                if (likely(atomic_read(&map->nr_free))) {
-                       do {
+                       for ( ; ; ) {
                                if (!test_and_set_bit(offset, map->page)) {
                                        atomic_dec(&map->nr_free);
                                        set_last_pid(pid_ns, last, pid);
                                        return pid;
                                }
                                offset = find_next_offset(map, offset);
-                       } while (offset < BITS_PER_PAGE &&
-                               (pid = mk_pid(pid_ns, map, offset)) < pid_max);
+                               if (offset >= BITS_PER_PAGE)
+                                       break;
+                               pid = mk_pid(pid_ns, map, offset);
+                               if (pid >= pid_max)
+                                       break;
+                       }
                }
                if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
                        ++map;