* [PATCH 1/1] kernel: futex: fixed to else and initcall
@ 2016-12-19 20:53 Ozgur Karatas
2016-12-20 9:18 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Ozgur Karatas @ 2016-12-19 20:53 UTC (permalink / raw)
To: tglx, dave, dvhart, bigeasy, mgorman, dingel, kirill.shutemov
Cc: linux-kernel, Linus Torvalds, akpm
The include/linux/init.h file have to content; to not used __initcall functions.
I think, needs to be replaced to device_initcall.
device_initcall() or more appropriate function instead of __initcall.
else doesn't need to be used, if should be enclosed in parentheses.
Also, I used checkpatch scripts and fixed to errors.
ERROR: "(foo*)" should be "(foo *)"
ERROR: "foo * bar" should be "foo *bar"
ERROR: "foo * bar" should be "foo *bar"
Signed-off-by: Ozgur Karatas <okaratas@member.fsf.org>
---
kernel/futex.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/kernel/futex.c b/kernel/futex.c
index 2c4be46..fd8a451 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -390,7 +390,7 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb)
*/
static struct futex_hash_bucket *hash_futex(union futex_key *key)
{
- u32 hash = jhash2((u32*)&key->both.word,
+ u32 hash = jhash2((u32 *)&key->both.word,
(sizeof(key->both.word)+sizeof(key->both.ptr))/4,
key->both.offset);
return &futex_queues[hash & (futex_hashsize - 1)];
@@ -545,10 +545,10 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
err = get_user_pages_fast(address, 1, 0, &page);
ro = 1;
}
- if (err < 0)
+ if (err < 0) {
return err;
- else
err = 0;
+ }
/*
* The treatment of mapping from this point on is critical. The page
@@ -800,7 +800,7 @@ static int refill_pi_state_cache(void)
return 0;
}
-static struct futex_pi_state * alloc_pi_state(void)
+static struct futex_pi_state *alloc_pi_state(void)
{
struct futex_pi_state *pi_state = current->pi_state_cache;
@@ -854,7 +854,7 @@ static void put_pi_state(struct futex_pi_state *pi_state)
* Look up the task based on what TID userspace gave us.
* We dont trust it.
*/
-static struct task_struct * futex_find_get_task(pid_t pid)
+static struct task_struct *futex_find_get_task(pid_t pid)
{
struct task_struct *p;
@@ -3323,4 +3323,4 @@ static int __init futex_init(void)
return 0;
}
-__initcall(futex_init);
+device_initcall(futex_init);
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] kernel: futex: fixed to else and initcall
2016-12-19 20:53 [PATCH 1/1] kernel: futex: fixed to else and initcall Ozgur Karatas
@ 2016-12-20 9:18 ` Thomas Gleixner
2016-12-20 9:39 ` Ozgur Karatas
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-20 9:18 UTC (permalink / raw)
To: Ozgur Karatas
Cc: dave, dvhart, bigeasy, mgorman, dingel, kirill.shutemov,
linux-kernel, Linus Torvalds, akpm
On Mon, 19 Dec 2016, Ozgur Karatas wrote:
> else doesn't need to be used, if should be enclosed in parentheses.
Really?
> - if (err < 0)
> + if (err < 0) {
> return err;
> - else
> err = 0;
> + }
So you change the code from
if (err < 0)
return err;
else
err = 0;
to
if (err < 0) {
return err;
err = 0;
}
How on earth is that equivivalent and how would that 'err = 0;' statement
be ever executed?
You clearly ran checkpatch.pl on this file and the output for this
construct is:
WARNING: else is not generally useful after a break or return
#550: FILE: kernel/futex.c:550:
+ return err;
+ else
So the proper change would have been:
if (err < 0)
return err;
err = 0;
and not the trainwreck you created.
checkpatch.pl does not substitute basic knowlegde of C.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] kernel: futex: fixed to else and initcall
2016-12-20 9:18 ` Thomas Gleixner
@ 2016-12-20 9:39 ` Ozgur Karatas
2016-12-20 10:36 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Ozgur Karatas @ 2016-12-20 9:39 UTC (permalink / raw)
To: Thomas Gleixner
Cc: dave, dvhart, bigeasy, mgorman, dingel, kirill.shutemov,
linux-kernel, Linus Torvalds, akpm
20.12.2016, 11:21, "Thomas Gleixner" <tglx@linutronix.de>:
> On Mon, 19 Dec 2016, Ozgur Karatas wrote:
>
>> else doesn't need to be used, if should be enclosed in parentheses.
>
> Really?
>
>
> So you change the code from
>
> if (err < 0)
> return err;
> else
> err = 0;
>
> to
>
> if (err < 0) {
> return err;
> err = 0;
> }
>
> How on earth is that equivivalent and how would that 'err = 0;' statement
> be ever executed?
Oh my god, I missed this point, sorry!
Thank you so much for correct me.
This "return err;" will give to "err" and err defined to err = "0".
Then removed to "else" and return = err; and should it be like this?
#define err = 0;
if (err < 0) {
return err;
}
Regards,
Ozgur
> You clearly ran checkpatch.pl on this file and the output for this
> construct is:
>
> WARNING: else is not generally useful after a break or return
> #550: FILE: kernel/futex.c:550:
> + return err;
> + else
>
> So the proper change would have been:
>
> if (err < 0)
> return err;
>
> err = 0;
>
> and not the trainwreck you created.
>
> checkpatch.pl does not substitute basic knowlegde of C.
>
> Thanks,
>
> tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] kernel: futex: fixed to else and initcall
2016-12-20 9:39 ` Ozgur Karatas
@ 2016-12-20 10:36 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2016-12-20 10:36 UTC (permalink / raw)
To: Ozgur Karatas
Cc: dave, dvhart, bigeasy, mgorman, dingel, kirill.shutemov,
linux-kernel, Linus Torvalds, akpm
[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]
On Tue, 20 Dec 2016, Ozgur Karatas wrote:
> 20.12.2016, 11:21, "Thomas Gleixner" <tglx@linutronix.de>:
> > On Mon, 19 Dec 2016, Ozgur Karatas wrote:
> >
> >> else doesn't need to be used, if should be enclosed in parentheses.
> >
> > Really?
> >
> >
> > So you change the code from
> >
> > if (err < 0)
> > return err;
> > else
> > err = 0;
> >
> > to
> >
> > if (err < 0) {
> > return err;
> > err = 0;
> > }
> >
> > How on earth is that equivivalent and how would that 'err = 0;' statement
> > be ever executed?
>
> Oh my god, I missed this point, sorry!
> Thank you so much for correct me.
>
> This "return err;" will give to "err" and err defined to err = "0".
> Then removed to "else" and return = err; and should it be like this?
>
> #define err = 0;
>
> if (err < 0) {
> return err;
> }
I seriously recommend to take a basic C course first before trying to
change code in the kernel.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-20 11:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 20:53 [PATCH 1/1] kernel: futex: fixed to else and initcall Ozgur Karatas
2016-12-20 9:18 ` Thomas Gleixner
2016-12-20 9:39 ` Ozgur Karatas
2016-12-20 10:36 ` Thomas Gleixner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.