diff options
author | vishnu.ps <vishnu.ps@samsung.com> | 2014-10-09 18:30:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-09 22:26:04 -0400 |
commit | ec94fc3d59b54561da03a0e433d93217b08c1481 (patch) | |
tree | a1d6896521b13d496fc046e90d4f9db302eef246 /kernel/sys.c | |
parent | 067b722faf98adbe1e94581f39c06a7c82b58676 (diff) |
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>
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 265 |
1 files changed, 137 insertions, 128 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index df692fbf1e79..037fd76bdc76 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -62,28 +62,28 @@ | |||
62 | #include <asm/unistd.h> | 62 | #include <asm/unistd.h> |
63 | 63 | ||
64 | #ifndef SET_UNALIGN_CTL | 64 | #ifndef SET_UNALIGN_CTL |
65 | # define SET_UNALIGN_CTL(a,b) (-EINVAL) | 65 | # define SET_UNALIGN_CTL(a, b) (-EINVAL) |
66 | #endif | 66 | #endif |
67 | #ifndef GET_UNALIGN_CTL | 67 | #ifndef GET_UNALIGN_CTL |
68 | # define GET_UNALIGN_CTL(a,b) (-EINVAL) | 68 | # define GET_UNALIGN_CTL(a, b) (-EINVAL) |
69 | #endif | 69 | #endif |
70 | #ifndef SET_FPEMU_CTL | 70 | #ifndef SET_FPEMU_CTL |
71 | # define SET_FPEMU_CTL(a,b) (-EINVAL) | 71 | # define SET_FPEMU_CTL(a, b) (-EINVAL) |
72 | #endif | 72 | #endif |
73 | #ifndef GET_FPEMU_CTL | 73 | #ifndef GET_FPEMU_CTL |
74 | # define GET_FPEMU_CTL(a,b) (-EINVAL) | 74 | # define GET_FPEMU_CTL(a, b) (-EINVAL) |
75 | #endif | 75 | #endif |
76 | #ifndef SET_FPEXC_CTL | 76 | #ifndef SET_FPEXC_CTL |
77 | # define SET_FPEXC_CTL(a,b) (-EINVAL) | 77 | # define SET_FPEXC_CTL(a, b) (-EINVAL) |
78 | #endif | 78 | #endif |
79 | #ifndef GET_FPEXC_CTL | 79 | #ifndef GET_FPEXC_CTL |
80 | # define GET_FPEXC_CTL(a,b) (-EINVAL) | 80 | # define GET_FPEXC_CTL(a, b) (-EINVAL) |
81 | #endif | 81 | #endif |
82 | #ifndef GET_ENDIAN | 82 | #ifndef GET_ENDIAN |
83 | # define GET_ENDIAN(a,b) (-EINVAL) | 83 | # define GET_ENDIAN(a, b) (-EINVAL) |
84 | #endif | 84 | #endif |
85 | #ifndef SET_ENDIAN | 85 | #ifndef SET_ENDIAN |
86 | # define SET_ENDIAN(a,b) (-EINVAL) | 86 | # define SET_ENDIAN(a, b) (-EINVAL) |
87 | #endif | 87 | #endif |
88 | #ifndef GET_TSC_CTL | 88 | #ifndef GET_TSC_CTL |
89 | # define GET_TSC_CTL(a) (-EINVAL) | 89 | # define GET_TSC_CTL(a) (-EINVAL) |
@@ -182,39 +182,40 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) | |||
182 | rcu_read_lock(); | 182 | rcu_read_lock(); |
183 | read_lock(&tasklist_lock); | 183 | read_lock(&tasklist_lock); |
184 | switch (which) { | 184 | switch (which) { |
185 | case PRIO_PROCESS: | 185 | case PRIO_PROCESS: |
186 | if (who) | 186 | if (who) |
187 | p = find_task_by_vpid(who); | 187 | p = find_task_by_vpid(who); |
188 | else | 188 | else |
189 | p = current; | 189 | p = current; |
190 | if (p) | 190 | if (p) |
191 | error = set_one_prio(p, niceval, error); | 191 | error = set_one_prio(p, niceval, error); |
192 | break; | 192 | break; |
193 | case PRIO_PGRP: | 193 | case PRIO_PGRP: |
194 | if (who) | 194 | if (who) |
195 | pgrp = find_vpid(who); | 195 | pgrp = find_vpid(who); |
196 | else | 196 | else |
197 | pgrp = task_pgrp(current); | 197 | pgrp = task_pgrp(current); |
198 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { | 198 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { |
199 | error = set_one_prio(p, niceval, error); | 199 | error = set_one_prio(p, niceval, error); |
200 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | 200 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
201 | break; | 201 | break; |
202 | case PRIO_USER: | 202 | case PRIO_USER: |
203 | uid = make_kuid(cred->user_ns, who); | 203 | uid = make_kuid(cred->user_ns, who); |
204 | user = cred->user; | 204 | user = cred->user; |
205 | if (!who) | 205 | if (!who) |
206 | uid = cred->uid; | 206 | uid = cred->uid; |
207 | else if (!uid_eq(uid, cred->uid) && | 207 | else if (!uid_eq(uid, cred->uid)) { |
208 | !(user = find_user(uid))) | 208 | user = find_user(uid); |
209 | if (!user) | ||
209 | goto out_unlock; /* No processes for this user */ | 210 | goto out_unlock; /* No processes for this user */ |
210 | 211 | } | |
211 | do_each_thread(g, p) { | 212 | do_each_thread(g, p) { |
212 | if (uid_eq(task_uid(p), uid)) | 213 | if (uid_eq(task_uid(p), uid)) |
213 | error = set_one_prio(p, niceval, error); | 214 | error = set_one_prio(p, niceval, error); |
214 | } while_each_thread(g, p); | 215 | } while_each_thread(g, p); |
215 | if (!uid_eq(uid, cred->uid)) | 216 | if (!uid_eq(uid, cred->uid)) |
216 | free_uid(user); /* For find_user() */ | 217 | free_uid(user); /* For find_user() */ |
217 | break; | 218 | break; |
218 | } | 219 | } |
219 | out_unlock: | 220 | out_unlock: |
220 | read_unlock(&tasklist_lock); | 221 | read_unlock(&tasklist_lock); |
@@ -244,47 +245,48 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who) | |||
244 | rcu_read_lock(); | 245 | rcu_read_lock(); |
245 | read_lock(&tasklist_lock); | 246 | read_lock(&tasklist_lock); |
246 | switch (which) { | 247 | switch (which) { |
247 | case PRIO_PROCESS: | 248 | case PRIO_PROCESS: |
248 | if (who) | 249 | if (who) |
249 | p = find_task_by_vpid(who); | 250 | p = find_task_by_vpid(who); |
250 | else | 251 | else |
251 | p = current; | 252 | p = current; |
252 | if (p) { | 253 | if (p) { |
254 | niceval = nice_to_rlimit(task_nice(p)); | ||
255 | if (niceval > retval) | ||
256 | retval = niceval; | ||
257 | } | ||
258 | break; | ||
259 | case PRIO_PGRP: | ||
260 | if (who) | ||
261 | pgrp = find_vpid(who); | ||
262 | else | ||
263 | pgrp = task_pgrp(current); | ||
264 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { | ||
265 | niceval = nice_to_rlimit(task_nice(p)); | ||
266 | if (niceval > retval) | ||
267 | retval = niceval; | ||
268 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | ||
269 | break; | ||
270 | case PRIO_USER: | ||
271 | uid = make_kuid(cred->user_ns, who); | ||
272 | user = cred->user; | ||
273 | if (!who) | ||
274 | uid = cred->uid; | ||
275 | else if (!uid_eq(uid, cred->uid)) { | ||
276 | user = find_user(uid); | ||
277 | if (!user) | ||
278 | goto out_unlock; /* No processes for this user */ | ||
279 | } | ||
280 | do_each_thread(g, p) { | ||
281 | if (uid_eq(task_uid(p), uid)) { | ||
253 | niceval = nice_to_rlimit(task_nice(p)); | 282 | niceval = nice_to_rlimit(task_nice(p)); |
254 | if (niceval > retval) | 283 | if (niceval > retval) |
255 | retval = niceval; | 284 | retval = niceval; |
256 | } | 285 | } |
257 | break; | 286 | } while_each_thread(g, p); |
258 | case PRIO_PGRP: | 287 | if (!uid_eq(uid, cred->uid)) |
259 | if (who) | 288 | free_uid(user); /* for find_user() */ |
260 | pgrp = find_vpid(who); | 289 | break; |
261 | else | ||
262 | pgrp = task_pgrp(current); | ||
263 | do_each_pid_thread(pgrp, PIDTYPE_PGID, p) { | ||
264 | niceval = nice_to_rlimit(task_nice(p)); | ||
265 | if (niceval > retval) | ||
266 | retval = niceval; | ||
267 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | ||
268 | break; | ||
269 | case PRIO_USER: | ||
270 | uid = make_kuid(cred->user_ns, who); | ||
271 | user = cred->user; | ||
272 | if (!who) | ||
273 | uid = cred->uid; | ||
274 | else if (!uid_eq(uid, cred->uid) && | ||
275 | !(user = find_user(uid))) | ||
276 | goto out_unlock; /* No processes for this user */ | ||
277 | |||
278 | do_each_thread(g, p) { | ||
279 | if (uid_eq(task_uid(p), uid)) { | ||
280 | niceval = nice_to_rlimit(task_nice(p)); | ||
281 | if (niceval > retval) | ||
282 | retval = niceval; | ||
283 | } | ||
284 | } while_each_thread(g, p); | ||
285 | if (!uid_eq(uid, cred->uid)) | ||
286 | free_uid(user); /* for find_user() */ | ||
287 | break; | ||
288 | } | 290 | } |
289 | out_unlock: | 291 | out_unlock: |
290 | read_unlock(&tasklist_lock); | 292 | read_unlock(&tasklist_lock); |
@@ -306,7 +308,7 @@ out_unlock: | |||
306 | * | 308 | * |
307 | * The general idea is that a program which uses just setregid() will be | 309 | * The general idea is that a program which uses just setregid() will be |
308 | * 100% compatible with BSD. A program which uses just setgid() will be | 310 | * 100% compatible with BSD. A program which uses just setgid() will be |
309 | * 100% compatible with POSIX with saved IDs. | 311 | * 100% compatible with POSIX with saved IDs. |
310 | * | 312 | * |
311 | * SMP: There are not races, the GIDs are checked only by filesystem | 313 | * SMP: There are not races, the GIDs are checked only by filesystem |
312 | * operations (as far as semantic preservation is concerned). | 314 | * operations (as far as semantic preservation is concerned). |
@@ -364,7 +366,7 @@ error: | |||
364 | } | 366 | } |
365 | 367 | ||
366 | /* | 368 | /* |
367 | * setgid() is implemented like SysV w/ SAVED_IDS | 369 | * setgid() is implemented like SysV w/ SAVED_IDS |
368 | * | 370 | * |
369 | * SMP: Same implicit races as above. | 371 | * SMP: Same implicit races as above. |
370 | */ | 372 | */ |
@@ -442,7 +444,7 @@ static int set_user(struct cred *new) | |||
442 | * | 444 | * |
443 | * The general idea is that a program which uses just setreuid() will be | 445 | * The general idea is that a program which uses just setreuid() will be |
444 | * 100% compatible with BSD. A program which uses just setuid() will be | 446 | * 100% compatible with BSD. A program which uses just setuid() will be |
445 | * 100% compatible with POSIX with saved IDs. | 447 | * 100% compatible with POSIX with saved IDs. |
446 | */ | 448 | */ |
447 | SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) | 449 | SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) |
448 | { | 450 | { |
@@ -503,17 +505,17 @@ error: | |||
503 | abort_creds(new); | 505 | abort_creds(new); |
504 | return retval; | 506 | return retval; |
505 | } | 507 | } |
506 | 508 | ||
507 | /* | 509 | /* |
508 | * setuid() is implemented like SysV with SAVED_IDS | 510 | * setuid() is implemented like SysV with SAVED_IDS |
509 | * | 511 | * |
510 | * Note that SAVED_ID's is deficient in that a setuid root program | 512 | * Note that SAVED_ID's is deficient in that a setuid root program |
511 | * like sendmail, for example, cannot set its uid to be a normal | 513 | * like sendmail, for example, cannot set its uid to be a normal |
512 | * user and then switch back, because if you're root, setuid() sets | 514 | * user and then switch back, because if you're root, setuid() sets |
513 | * the saved uid too. If you don't like this, blame the bright people | 515 | * the saved uid too. If you don't like this, blame the bright people |
514 | * in the POSIX committee and/or USG. Note that the BSD-style setreuid() | 516 | * in the POSIX committee and/or USG. Note that the BSD-style setreuid() |
515 | * will allow a root program to temporarily drop privileges and be able to | 517 | * will allow a root program to temporarily drop privileges and be able to |
516 | * regain them by swapping the real and effective uid. | 518 | * regain them by swapping the real and effective uid. |
517 | */ | 519 | */ |
518 | SYSCALL_DEFINE1(setuid, uid_t, uid) | 520 | SYSCALL_DEFINE1(setuid, uid_t, uid) |
519 | { | 521 | { |
@@ -637,10 +639,12 @@ SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t _ | |||
637 | euid = from_kuid_munged(cred->user_ns, cred->euid); | 639 | euid = from_kuid_munged(cred->user_ns, cred->euid); |
638 | suid = from_kuid_munged(cred->user_ns, cred->suid); | 640 | suid = from_kuid_munged(cred->user_ns, cred->suid); |
639 | 641 | ||
640 | if (!(retval = put_user(ruid, ruidp)) && | 642 | retval = put_user(ruid, ruidp); |
641 | !(retval = put_user(euid, euidp))) | 643 | if (!retval) { |
642 | retval = put_user(suid, suidp); | 644 | retval = put_user(euid, euidp); |
643 | 645 | if (!retval) | |
646 | return put_user(suid, suidp); | ||
647 | } | ||
644 | return retval; | 648 | return retval; |
645 | } | 649 | } |
646 | 650 | ||
@@ -709,9 +713,12 @@ SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t _ | |||
709 | egid = from_kgid_munged(cred->user_ns, cred->egid); | 713 | egid = from_kgid_munged(cred->user_ns, cred->egid); |
710 | sgid = from_kgid_munged(cred->user_ns, cred->sgid); | 714 | sgid = from_kgid_munged(cred->user_ns, cred->sgid); |
711 | 715 | ||
712 | if (!(retval = put_user(rgid, rgidp)) && | 716 | retval = put_user(rgid, rgidp); |
713 | !(retval = put_user(egid, egidp))) | 717 | if (!retval) { |
714 | retval = put_user(sgid, sgidp); | 718 | retval = put_user(egid, egidp); |
719 | if (!retval) | ||
720 | retval = put_user(sgid, sgidp); | ||
721 | } | ||
715 | 722 | ||
716 | return retval; | 723 | return retval; |
717 | } | 724 | } |
@@ -1284,7 +1291,6 @@ SYSCALL_DEFINE2(getrlimit, unsigned int, resource, struct rlimit __user *, rlim) | |||
1284 | /* | 1291 | /* |
1285 | * Back compatibility for getrlimit. Needed for some apps. | 1292 | * Back compatibility for getrlimit. Needed for some apps. |
1286 | */ | 1293 | */ |
1287 | |||
1288 | SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource, | 1294 | SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource, |
1289 | struct rlimit __user *, rlim) | 1295 | struct rlimit __user *, rlim) |
1290 | { | 1296 | { |
@@ -1299,7 +1305,7 @@ SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource, | |||
1299 | x.rlim_cur = 0x7FFFFFFF; | 1305 | x.rlim_cur = 0x7FFFFFFF; |
1300 | if (x.rlim_max > 0x7FFFFFFF) | 1306 | if (x.rlim_max > 0x7FFFFFFF) |
1301 | x.rlim_max = 0x7FFFFFFF; | 1307 | x.rlim_max = 0x7FFFFFFF; |
1302 | return copy_to_user(rlim, &x, sizeof(x))?-EFAULT:0; | 1308 | return copy_to_user(rlim, &x, sizeof(x)) ? -EFAULT : 0; |
1303 | } | 1309 | } |
1304 | 1310 | ||
1305 | #endif | 1311 | #endif |
@@ -1527,7 +1533,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1527 | cputime_t tgutime, tgstime, utime, stime; | 1533 | cputime_t tgutime, tgstime, utime, stime; |
1528 | unsigned long maxrss = 0; | 1534 | unsigned long maxrss = 0; |
1529 | 1535 | ||
1530 | memset((char *) r, 0, sizeof *r); | 1536 | memset((char *)r, 0, sizeof (*r)); |
1531 | utime = stime = 0; | 1537 | utime = stime = 0; |
1532 | 1538 | ||
1533 | if (who == RUSAGE_THREAD) { | 1539 | if (who == RUSAGE_THREAD) { |
@@ -1541,41 +1547,41 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1541 | return; | 1547 | return; |
1542 | 1548 | ||
1543 | switch (who) { | 1549 | switch (who) { |
1544 | case RUSAGE_BOTH: | 1550 | case RUSAGE_BOTH: |
1545 | case RUSAGE_CHILDREN: | 1551 | case RUSAGE_CHILDREN: |
1546 | utime = p->signal->cutime; | 1552 | utime = p->signal->cutime; |
1547 | stime = p->signal->cstime; | 1553 | stime = p->signal->cstime; |
1548 | r->ru_nvcsw = p->signal->cnvcsw; | 1554 | r->ru_nvcsw = p->signal->cnvcsw; |
1549 | r->ru_nivcsw = p->signal->cnivcsw; | 1555 | r->ru_nivcsw = p->signal->cnivcsw; |
1550 | r->ru_minflt = p->signal->cmin_flt; | 1556 | r->ru_minflt = p->signal->cmin_flt; |
1551 | r->ru_majflt = p->signal->cmaj_flt; | 1557 | r->ru_majflt = p->signal->cmaj_flt; |
1552 | r->ru_inblock = p->signal->cinblock; | 1558 | r->ru_inblock = p->signal->cinblock; |
1553 | r->ru_oublock = p->signal->coublock; | 1559 | r->ru_oublock = p->signal->coublock; |
1554 | maxrss = p->signal->cmaxrss; | 1560 | maxrss = p->signal->cmaxrss; |
1555 | 1561 | ||
1556 | if (who == RUSAGE_CHILDREN) | 1562 | if (who == RUSAGE_CHILDREN) |
1557 | break; | ||
1558 | |||
1559 | case RUSAGE_SELF: | ||
1560 | thread_group_cputime_adjusted(p, &tgutime, &tgstime); | ||
1561 | utime += tgutime; | ||
1562 | stime += tgstime; | ||
1563 | r->ru_nvcsw += p->signal->nvcsw; | ||
1564 | r->ru_nivcsw += p->signal->nivcsw; | ||
1565 | r->ru_minflt += p->signal->min_flt; | ||
1566 | r->ru_majflt += p->signal->maj_flt; | ||
1567 | r->ru_inblock += p->signal->inblock; | ||
1568 | r->ru_oublock += p->signal->oublock; | ||
1569 | if (maxrss < p->signal->maxrss) | ||
1570 | maxrss = p->signal->maxrss; | ||
1571 | t = p; | ||
1572 | do { | ||
1573 | accumulate_thread_rusage(t, r); | ||
1574 | } while_each_thread(p, t); | ||
1575 | break; | 1563 | break; |
1576 | 1564 | ||
1577 | default: | 1565 | case RUSAGE_SELF: |
1578 | BUG(); | 1566 | thread_group_cputime_adjusted(p, &tgutime, &tgstime); |
1567 | utime += tgutime; | ||
1568 | stime += tgstime; | ||
1569 | r->ru_nvcsw += p->signal->nvcsw; | ||
1570 | r->ru_nivcsw += p->signal->nivcsw; | ||
1571 | r->ru_minflt += p->signal->min_flt; | ||
1572 | r->ru_majflt += p->signal->maj_flt; | ||
1573 | r->ru_inblock += p->signal->inblock; | ||
1574 | r->ru_oublock += p->signal->oublock; | ||
1575 | if (maxrss < p->signal->maxrss) | ||
1576 | maxrss = p->signal->maxrss; | ||
1577 | t = p; | ||
1578 | do { | ||
1579 | accumulate_thread_rusage(t, r); | ||
1580 | } while_each_thread(p, t); | ||
1581 | break; | ||
1582 | |||
1583 | default: | ||
1584 | BUG(); | ||
1579 | } | 1585 | } |
1580 | unlock_task_sighand(p, &flags); | 1586 | unlock_task_sighand(p, &flags); |
1581 | 1587 | ||
@@ -1585,6 +1591,7 @@ out: | |||
1585 | 1591 | ||
1586 | if (who != RUSAGE_CHILDREN) { | 1592 | if (who != RUSAGE_CHILDREN) { |
1587 | struct mm_struct *mm = get_task_mm(p); | 1593 | struct mm_struct *mm = get_task_mm(p); |
1594 | |||
1588 | if (mm) { | 1595 | if (mm) { |
1589 | setmax_mm_hiwater_rss(&maxrss, mm); | 1596 | setmax_mm_hiwater_rss(&maxrss, mm); |
1590 | mmput(mm); | 1597 | mmput(mm); |
@@ -1596,6 +1603,7 @@ out: | |||
1596 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) | 1603 | int getrusage(struct task_struct *p, int who, struct rusage __user *ru) |
1597 | { | 1604 | { |
1598 | struct rusage r; | 1605 | struct rusage r; |
1606 | |||
1599 | k_getrusage(p, who, &r); | 1607 | k_getrusage(p, who, &r); |
1600 | return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0; | 1608 | return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0; |
1601 | } | 1609 | } |
@@ -2209,6 +2217,7 @@ SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep, | |||
2209 | { | 2217 | { |
2210 | int err = 0; | 2218 | int err = 0; |
2211 | int cpu = raw_smp_processor_id(); | 2219 | int cpu = raw_smp_processor_id(); |
2220 | |||
2212 | if (cpup) | 2221 | if (cpup) |
2213 | err |= put_user(cpu, cpup); | 2222 | err |= put_user(cpu, cpup); |
2214 | if (nodep) | 2223 | if (nodep) |