kernel/sys.c: whitespace fixes
Fix minor errors and warning messages in kernel/sys.c. These errors were reported by checkpatch while working with some modifications in sys.c file. Fixing this first will help me to improve my further patches. ERROR: trailing whitespace - 9 ERROR: do not use assignment in if condition - 4 ERROR: spaces required around that '?' (ctx:VxO) - 10 ERROR: switch and case should be at the same indent - 3 total 26 errors & 3 warnings fixed. Signed-off-by: vishnu.ps <vishnu.ps@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
067b722faf
commit
ec94fc3d59
263
kernel/sys.c
263
kernel/sys.c
@ -62,28 +62,28 @@
|
|||||||
#include <asm/unistd.h>
|
#include <asm/unistd.h>
|
||||||
|
|
||||||
#ifndef SET_UNALIGN_CTL
|
#ifndef SET_UNALIGN_CTL
|
||||||
# define SET_UNALIGN_CTL(a,b) (-EINVAL)
|
# define SET_UNALIGN_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_UNALIGN_CTL
|
#ifndef GET_UNALIGN_CTL
|
||||||
# define GET_UNALIGN_CTL(a,b) (-EINVAL)
|
# define GET_UNALIGN_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef SET_FPEMU_CTL
|
#ifndef SET_FPEMU_CTL
|
||||||
# define SET_FPEMU_CTL(a,b) (-EINVAL)
|
# define SET_FPEMU_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_FPEMU_CTL
|
#ifndef GET_FPEMU_CTL
|
||||||
# define GET_FPEMU_CTL(a,b) (-EINVAL)
|
# define GET_FPEMU_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef SET_FPEXC_CTL
|
#ifndef SET_FPEXC_CTL
|
||||||
# define SET_FPEXC_CTL(a,b) (-EINVAL)
|
# define SET_FPEXC_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_FPEXC_CTL
|
#ifndef GET_FPEXC_CTL
|
||||||
# define GET_FPEXC_CTL(a,b) (-EINVAL)
|
# define GET_FPEXC_CTL(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_ENDIAN
|
#ifndef GET_ENDIAN
|
||||||
# define GET_ENDIAN(a,b) (-EINVAL)
|
# define GET_ENDIAN(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef SET_ENDIAN
|
#ifndef SET_ENDIAN
|
||||||
# define SET_ENDIAN(a,b) (-EINVAL)
|
# define SET_ENDIAN(a, b) (-EINVAL)
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_TSC_CTL
|
#ifndef GET_TSC_CTL
|
||||||
# define GET_TSC_CTL(a) (-EINVAL)
|
# define GET_TSC_CTL(a) (-EINVAL)
|
||||||
@ -182,39 +182,40 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
read_lock(&tasklist_lock);
|
read_lock(&tasklist_lock);
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case PRIO_PROCESS:
|
case PRIO_PROCESS:
|
||||||
if (who)
|
if (who)
|
||||||
p = find_task_by_vpid(who);
|
p = find_task_by_vpid(who);
|
||||||
else
|
else
|
||||||
p = current;
|
p = current;
|
||||||
if (p)
|
if (p)
|
||||||
error = set_one_prio(p, niceval, error);
|
error = set_one_prio(p, niceval, error);
|
||||||
break;
|
break;
|
||||||
case PRIO_PGRP:
|
case PRIO_PGRP:
|
||||||
if (who)
|
if (who)
|
||||||
pgrp = find_vpid(who);
|
pgrp = find_vpid(who);
|
||||||
else
|
else
|
||||||
pgrp = task_pgrp(current);
|
pgrp = task_pgrp(current);
|
||||||
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
||||||
error = set_one_prio(p, niceval, error);
|
error = set_one_prio(p, niceval, error);
|
||||||
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
||||||
break;
|
break;
|
||||||
case PRIO_USER:
|
case PRIO_USER:
|
||||||
uid = make_kuid(cred->user_ns, who);
|
uid = make_kuid(cred->user_ns, who);
|
||||||
user = cred->user;
|
user = cred->user;
|
||||||
if (!who)
|
if (!who)
|
||||||
uid = cred->uid;
|
uid = cred->uid;
|
||||||
else if (!uid_eq(uid, cred->uid) &&
|
else if (!uid_eq(uid, cred->uid)) {
|
||||||
!(user = find_user(uid)))
|
user = find_user(uid);
|
||||||
|
if (!user)
|
||||||
goto out_unlock; /* No processes for this user */
|
goto out_unlock; /* No processes for this user */
|
||||||
|
}
|
||||||
do_each_thread(g, p) {
|
do_each_thread(g, p) {
|
||||||
if (uid_eq(task_uid(p), uid))
|
if (uid_eq(task_uid(p), uid))
|
||||||
error = set_one_prio(p, niceval, error);
|
error = set_one_prio(p, niceval, error);
|
||||||
} while_each_thread(g, p);
|
} while_each_thread(g, p);
|
||||||
if (!uid_eq(uid, cred->uid))
|
if (!uid_eq(uid, cred->uid))
|
||||||
free_uid(user); /* For find_user() */
|
free_uid(user); /* For find_user() */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out_unlock:
|
out_unlock:
|
||||||
read_unlock(&tasklist_lock);
|
read_unlock(&tasklist_lock);
|
||||||
@ -244,47 +245,48 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
|
|||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
read_lock(&tasklist_lock);
|
read_lock(&tasklist_lock);
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case PRIO_PROCESS:
|
case PRIO_PROCESS:
|
||||||
if (who)
|
if (who)
|
||||||
p = find_task_by_vpid(who);
|
p = find_task_by_vpid(who);
|
||||||
else
|
else
|
||||||
p = current;
|
p = current;
|
||||||
if (p) {
|
if (p) {
|
||||||
|
niceval = nice_to_rlimit(task_nice(p));
|
||||||
|
if (niceval > retval)
|
||||||
|
retval = niceval;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PRIO_PGRP:
|
||||||
|
if (who)
|
||||||
|
pgrp = find_vpid(who);
|
||||||
|
else
|
||||||
|
pgrp = task_pgrp(current);
|
||||||
|
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
||||||
|
niceval = nice_to_rlimit(task_nice(p));
|
||||||
|
if (niceval > retval)
|
||||||
|
retval = niceval;
|
||||||
|
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
||||||
|
break;
|
||||||
|
case PRIO_USER:
|
||||||
|
uid = make_kuid(cred->user_ns, who);
|
||||||
|
user = cred->user;
|
||||||
|
if (!who)
|
||||||
|
uid = cred->uid;
|
||||||
|
else if (!uid_eq(uid, cred->uid)) {
|
||||||
|
user = find_user(uid);
|
||||||
|
if (!user)
|
||||||
|
goto out_unlock; /* No processes for this user */
|
||||||
|
}
|
||||||
|
do_each_thread(g, p) {
|
||||||
|
if (uid_eq(task_uid(p), uid)) {
|
||||||
niceval = nice_to_rlimit(task_nice(p));
|
niceval = nice_to_rlimit(task_nice(p));
|
||||||
if (niceval > retval)
|
if (niceval > retval)
|
||||||
retval = niceval;
|
retval = niceval;
|
||||||
}
|
}
|
||||||
break;
|
} while_each_thread(g, p);
|
||||||
case PRIO_PGRP:
|
if (!uid_eq(uid, cred->uid))
|
||||||
if (who)
|
free_uid(user); /* for find_user() */
|
||||||
pgrp = find_vpid(who);
|
break;
|
||||||
else
|
|
||||||
pgrp = task_pgrp(current);
|
|
||||||
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
|
|
||||||
niceval = nice_to_rlimit(task_nice(p));
|
|
||||||
if (niceval > retval)
|
|
||||||
retval = niceval;
|
|
||||||
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
|
|
||||||
break;
|
|
||||||
case PRIO_USER:
|
|
||||||
uid = make_kuid(cred->user_ns, who);
|
|
||||||
user = cred->user;
|
|
||||||
if (!who)
|
|
||||||
uid = cred->uid;
|
|
||||||
else if (!uid_eq(uid, cred->uid) &&
|
|
||||||
!(user = find_user(uid)))
|
|
||||||
goto out_unlock; /* No processes for this user */
|
|
||||||
|
|
||||||
do_each_thread(g, p) {
|
|
||||||
if (uid_eq(task_uid(p), uid)) {
|
|
||||||
niceval = nice_to_rlimit(task_nice(p));
|
|
||||||
if (niceval > retval)
|
|
||||||
retval = niceval;
|
|
||||||
}
|
|
||||||
} while_each_thread(g, p);
|
|
||||||
if (!uid_eq(uid, cred->uid))
|
|
||||||
free_uid(user); /* for find_user() */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
out_unlock:
|
out_unlock:
|
||||||
read_unlock(&tasklist_lock);
|
read_unlock(&tasklist_lock);
|
||||||
@ -306,7 +308,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
|
|||||||
*
|
*
|
||||||
* The general idea is that a program which uses just setregid() will be
|
* The general idea is that a program which uses just setregid() will be
|
||||||
* 100% compatible with BSD. A program which uses just setgid() will be
|
* 100% compatible with BSD. A program which uses just setgid() will be
|
||||||
* 100% compatible with POSIX with saved IDs.
|
* 100% compatible with POSIX with saved IDs.
|
||||||
*
|
*
|
||||||
* SMP: There are not races, the GIDs are checked only by filesystem
|
* SMP: There are not races, the GIDs are checked only by filesystem
|
||||||
* operations (as far as semantic preservation is concerned).
|
* operations (as far as semantic preservation is concerned).
|
||||||
@ -364,7 +366,7 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setgid() is implemented like SysV w/ SAVED_IDS
|
* setgid() is implemented like SysV w/ SAVED_IDS
|
||||||
*
|
*
|
||||||
* SMP: Same implicit races as above.
|
* SMP: Same implicit races as above.
|
||||||
*/
|
*/
|
||||||
@ -442,7 +444,7 @@ static int set_user(struct cred *new)
|
|||||||
*
|
*
|
||||||
* The general idea is that a program which uses just setreuid() will be
|
* The general idea is that a program which uses just setreuid() will be
|
||||||
* 100% compatible with BSD. A program which uses just setuid() will be
|
* 100% compatible with BSD. A program which uses just setuid() will be
|
||||||
* 100% compatible with POSIX with saved IDs.
|
* 100% compatible with POSIX with saved IDs.
|
||||||
*/
|
*/
|
||||||
SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
|
SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
|
||||||
{
|
{
|
||||||
@ -503,17 +505,17 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
|
|||||||
abort_creds(new);
|
abort_creds(new);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setuid() is implemented like SysV with SAVED_IDS
|
* setuid() is implemented like SysV with SAVED_IDS
|
||||||
*
|
*
|
||||||
* Note that SAVED_ID's is deficient in that a setuid root program
|
* Note that SAVED_ID's is deficient in that a setuid root program
|
||||||
* like sendmail, for example, cannot set its uid to be a normal
|
* like sendmail, for example, cannot set its uid to be a normal
|
||||||
* user and then switch back, because if you're root, setuid() sets
|
* user and then switch back, because if you're root, setuid() sets
|
||||||
* the saved uid too. If you don't like this, blame the bright people
|
* the saved uid too. If you don't like this, blame the bright people
|
||||||
* in the POSIX committee and/or USG. Note that the BSD-style setreuid()
|
* in the POSIX committee and/or USG. Note that the BSD-style setreuid()
|
||||||
* will allow a root program to temporarily drop privileges and be able to
|
* will allow a root program to temporarily drop privileges and be able to
|
||||||
* regain them by swapping the real and effective uid.
|
* regain them by swapping the real and effective uid.
|
||||||
*/
|
*/
|
||||||
SYSCALL_DEFINE1(setuid, uid_t, uid)
|
SYSCALL_DEFINE1(setuid, uid_t, uid)
|
||||||
{
|
{
|
||||||
@ -637,10 +639,12 @@ SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t _
|
|||||||
euid = from_kuid_munged(cred->user_ns, cred->euid);
|
euid = from_kuid_munged(cred->user_ns, cred->euid);
|
||||||
suid = from_kuid_munged(cred->user_ns, cred->suid);
|
suid = from_kuid_munged(cred->user_ns, cred->suid);
|
||||||
|
|
||||||
if (!(retval = put_user(ruid, ruidp)) &&
|
retval = put_user(ruid, ruidp);
|
||||||
!(retval = put_user(euid, euidp)))
|
if (!retval) {
|
||||||
retval = put_user(suid, suidp);
|
retval = put_user(euid, euidp);
|
||||||
|
if (!retval)
|
||||||
|
return put_user(suid, suidp);
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,9 +713,12 @@ SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t _
|
|||||||
egid = from_kgid_munged(cred->user_ns, cred->egid);
|
egid = from_kgid_munged(cred->user_ns, cred->egid);
|
||||||
sgid = from_kgid_munged(cred->user_ns, cred->sgid);
|
sgid = from_kgid_munged(cred->user_ns, cred->sgid);
|
||||||
|
|
||||||
if (!(retval = put_user(rgid, rgidp)) &&
|
retval = put_user(rgid, rgidp);
|
||||||
!(retval = put_user(egid, egidp)))
|
if (!retval) {
|
||||||
retval = put_user(sgid, sgidp);
|
retval = put_user(egid, egidp);
|
||||||
|
if (!retval)
|
||||||
|
retval = put_user(sgid, sgidp);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -1284,7 +1291,6 @@ SYSCALL_DEFINE2(getrlimit, unsigned int, resource, struct rlimit __user *, rlim)
|
|||||||
/*
|
/*
|
||||||
* Back compatibility for getrlimit. Needed for some apps.
|
* Back compatibility for getrlimit. Needed for some apps.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
|
SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
|
||||||
struct rlimit __user *, rlim)
|
struct rlimit __user *, rlim)
|
||||||
{
|
{
|
||||||
@ -1299,7 +1305,7 @@ SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
|
|||||||
x.rlim_cur = 0x7FFFFFFF;
|
x.rlim_cur = 0x7FFFFFFF;
|
||||||
if (x.rlim_max > 0x7FFFFFFF)
|
if (x.rlim_max > 0x7FFFFFFF)
|
||||||
x.rlim_max = 0x7FFFFFFF;
|
x.rlim_max = 0x7FFFFFFF;
|
||||||
return copy_to_user(rlim, &x, sizeof(x))?-EFAULT:0;
|
return copy_to_user(rlim, &x, sizeof(x)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -1527,7 +1533,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
|
|||||||
cputime_t tgutime, tgstime, utime, stime;
|
cputime_t tgutime, tgstime, utime, stime;
|
||||||
unsigned long maxrss = 0;
|
unsigned long maxrss = 0;
|
||||||
|
|
||||||
memset((char *) r, 0, sizeof *r);
|
memset((char *)r, 0, sizeof (*r));
|
||||||
utime = stime = 0;
|
utime = stime = 0;
|
||||||
|
|
||||||
if (who == RUSAGE_THREAD) {
|
if (who == RUSAGE_THREAD) {
|
||||||
@ -1541,41 +1547,41 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (who) {
|
switch (who) {
|
||||||
case RUSAGE_BOTH:
|
case RUSAGE_BOTH:
|
||||||
case RUSAGE_CHILDREN:
|
case RUSAGE_CHILDREN:
|
||||||
utime = p->signal->cutime;
|
utime = p->signal->cutime;
|
||||||
stime = p->signal->cstime;
|
stime = p->signal->cstime;
|
||||||
r->ru_nvcsw = p->signal->cnvcsw;
|
r->ru_nvcsw = p->signal->cnvcsw;
|
||||||
r->ru_nivcsw = p->signal->cnivcsw;
|
r->ru_nivcsw = p->signal->cnivcsw;
|
||||||
r->ru_minflt = p->signal->cmin_flt;
|
r->ru_minflt = p->signal->cmin_flt;
|
||||||
r->ru_majflt = p->signal->cmaj_flt;
|
r->ru_majflt = p->signal->cmaj_flt;
|
||||||
r->ru_inblock = p->signal->cinblock;
|
r->ru_inblock = p->signal->cinblock;
|
||||||
r->ru_oublock = p->signal->coublock;
|
r->ru_oublock = p->signal->coublock;
|
||||||
maxrss = p->signal->cmaxrss;
|
maxrss = p->signal->cmaxrss;
|
||||||
|
|
||||||
if (who == RUSAGE_CHILDREN)
|
if (who == RUSAGE_CHILDREN)
|
||||||
break;
|
|
||||||
|
|
||||||
case RUSAGE_SELF:
|
|
||||||
thread_group_cputime_adjusted(p, &tgutime, &tgstime);
|
|
||||||
utime += tgutime;
|
|
||||||
stime += tgstime;
|
|
||||||
r->ru_nvcsw += p->signal->nvcsw;
|
|
||||||
r->ru_nivcsw += p->signal->nivcsw;
|
|
||||||
r->ru_minflt += p->signal->min_flt;
|
|
||||||
r->ru_majflt += p->signal->maj_flt;
|
|
||||||
r->ru_inblock += p->signal->inblock;
|
|
||||||
r->ru_oublock += p->signal->oublock;
|
|
||||||
if (maxrss < p->signal->maxrss)
|
|
||||||
maxrss = p->signal->maxrss;
|
|
||||||
t = p;
|
|
||||||
do {
|
|
||||||
accumulate_thread_rusage(t, r);
|
|
||||||
} while_each_thread(p, t);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case RUSAGE_SELF:
|
||||||
BUG();
|
thread_group_cputime_adjusted(p, &tgutime, &tgstime);
|
||||||
|
utime += tgutime;
|
||||||
|
stime += tgstime;
|
||||||
|
r->ru_nvcsw += p->signal->nvcsw;
|
||||||
|
r->ru_nivcsw += p->signal->nivcsw;
|
||||||
|
r->ru_minflt += p->signal->min_flt;
|
||||||
|
r->ru_majflt += p->signal->maj_flt;
|
||||||
|
r->ru_inblock += p->signal->inblock;
|
||||||
|
r->ru_oublock += p->signal->oublock;
|
||||||
|
if (maxrss < p->signal->maxrss)
|
||||||
|
maxrss = p->signal->maxrss;
|
||||||
|
t = p;
|
||||||
|
do {
|
||||||
|
accumulate_thread_rusage(t, r);
|
||||||
|
} while_each_thread(p, t);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BUG();
|
||||||
}
|
}
|
||||||
unlock_task_sighand(p, &flags);
|
unlock_task_sighand(p, &flags);
|
||||||
|
|
||||||
@ -1585,6 +1591,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
|
|||||||
|
|
||||||
if (who != RUSAGE_CHILDREN) {
|
if (who != RUSAGE_CHILDREN) {
|
||||||
struct mm_struct *mm = get_task_mm(p);
|
struct mm_struct *mm = get_task_mm(p);
|
||||||
|
|
||||||
if (mm) {
|
if (mm) {
|
||||||
setmax_mm_hiwater_rss(&maxrss, mm);
|
setmax_mm_hiwater_rss(&maxrss, mm);
|
||||||
mmput(mm);
|
mmput(mm);
|
||||||
@ -1596,6 +1603,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
|
|||||||
int getrusage(struct task_struct *p, int who, struct rusage __user *ru)
|
int getrusage(struct task_struct *p, int who, struct rusage __user *ru)
|
||||||
{
|
{
|
||||||
struct rusage r;
|
struct rusage r;
|
||||||
|
|
||||||
k_getrusage(p, who, &r);
|
k_getrusage(p, who, &r);
|
||||||
return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
|
return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
@ -2209,6 +2217,7 @@ SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,
|
|||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int cpu = raw_smp_processor_id();
|
int cpu = raw_smp_processor_id();
|
||||||
|
|
||||||
if (cpup)
|
if (cpup)
|
||||||
err |= put_user(cpu, cpup);
|
err |= put_user(cpu, cpup);
|
||||||
if (nodep)
|
if (nodep)
|
||||||
|
Loading…
Reference in New Issue
Block a user