acct: eliminate compile warning
authorYing Xue <ying.xue@windriver.com>
Thu, 9 Oct 2014 22:30:21 +0000 (15:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 10 Oct 2014 02:26:04 +0000 (22:26 -0400)
If ACCT_VERSION is not defined to 3, below warning appears:
  CC      kernel/acct.o
  kernel/acct.c: In function `do_acct_process':
  kernel/acct.c:475:24: warning: unused variable `ns' [-Wunused-variable]

[akpm@linux-foundation.org: retain the local for code size improvements
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/acct.c

index b4c667d..33738ef 100644 (file)
@@ -472,7 +472,6 @@ static void do_acct_process(struct bsd_acct_struct *acct)
        acct_t ac;
        unsigned long flim;
        const struct cred *orig_cred;
-       struct pid_namespace *ns = acct->ns;
        struct file *file = acct->file;
 
        /*
@@ -500,10 +499,15 @@ static void do_acct_process(struct bsd_acct_struct *acct)
        ac.ac_gid16 = ac.ac_gid;
 #endif
 #if ACCT_VERSION == 3
-       ac.ac_pid = task_tgid_nr_ns(current, ns);
-       rcu_read_lock();
-       ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns);
-       rcu_read_unlock();
+       {
+               struct pid_namespace *ns = acct->ns;
+
+               ac.ac_pid = task_tgid_nr_ns(current, ns);
+               rcu_read_lock();
+               ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent),
+                                            ns);
+               rcu_read_unlock();
+       }
 #endif
        /*
         * Get freeze protection. If the fs is frozen, just skip the write