]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
kernel-pidc-improve-flow-of-a-loop-inside-alloc_pidmap-fix
authorAndrew Morton <akpm@linux-foundation.org>
Sat, 23 Mar 2013 02:32:56 +0000 (13:32 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Mar 2013 05:11:38 +0000 (16:11 +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;