* [patch] staging: panel: pass correct lengths to keypad_send_key()
@ 2012-11-29 14:38 Dan Carpenter
2012-11-30 9:19 ` walter harms
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Dan Carpenter @ 2012-11-29 14:38 UTC (permalink / raw)
To: kernel-janitors
We changed the sizeof() statements in 429ccf058b "staging:panel: Fixed
coding conventions." so that they could fit inside the 80 character
line limit. Unfortunately, the new sizeof() statements are a smaller
size. This reverts it.
There isn't a nice way to stay within the 80 character limit without
a re-work so I've gone over.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Untested. The ->u.kbd.press_str and friends are funny data types. I'm
not sure how this code, works but the stuff we have is wrong and I've
reverted it back to the original.
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index d9fec5b..dca42ce 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -1758,7 +1758,7 @@ static inline int input_state_high(struct logical_input *input)
char *press_str = input->u.kbd.press_str;
if (press_str[0])
keypad_send_key(press_str,
- sizeof(press_str));
+ sizeof(input->u.kbd.press_str));
}
if (input->u.kbd.repeat_str[0]) {
@@ -1766,7 +1766,7 @@ static inline int input_state_high(struct logical_input *input)
if (input->high_timer >= KEYPAD_REP_START) {
input->high_timer -= KEYPAD_REP_DELAY;
keypad_send_key(repeat_str,
- sizeof(repeat_str));
+ sizeof(input->u.kbd.repeat_str));
}
/* we will need to come back here soon */
inputs_stable = 0;
@@ -1805,7 +1805,7 @@ static inline void input_state_falling(struct logical_input *input)
if (input->high_timer >= KEYPAD_REP_START)
input->high_timer -= KEYPAD_REP_DELAY;
keypad_send_key(repeat_str,
- sizeof(repeat_str));
+ sizeof(input->u.kbd.repeat_str));
/* we will need to come back here soon */
inputs_stable = 0;
}
@@ -1824,7 +1824,7 @@ static inline void input_state_falling(struct logical_input *input)
char *release_str = input->u.kbd.release_str;
if (release_str[0])
keypad_send_key(release_str,
- sizeof(release_str));
+ sizeof(input->u.kbd.release_str));
}
input->state = INPUT_ST_LOW;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
@ 2012-11-30 9:19 ` walter harms
2012-12-01 8:08 ` Willy Tarreau
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: walter harms @ 2012-11-30 9:19 UTC (permalink / raw)
To: kernel-janitors
Am 29.11.2012 15:38, schrieb Dan Carpenter:
> We changed the sizeof() statements in 429ccf058b "staging:panel: Fixed
> coding conventions." so that they could fit inside the 80 character
> line limit. Unfortunately, the new sizeof() statements are a smaller
> size. This reverts it.
>
> There isn't a nice way to stay within the 80 character limit without
> a re-work so I've gone over.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Untested. The ->u.kbd.press_str and friends are funny data types. I'm
> not sure how this code, works but the stuff we have is wrong and I've
> reverted it back to the original.
>
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index d9fec5b..dca42ce 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -1758,7 +1758,7 @@ static inline int input_state_high(struct logical_input *input)
> char *press_str = input->u.kbd.press_str;
> if (press_str[0])
> keypad_send_key(press_str,
> - sizeof(press_str));
> + sizeof(input->u.kbd.press_str));
> }
yep, this looks like the original intention.
NTL i would like to question the use of press_str and friends.
Moving the if (press_str[0]) into keypad_send_key() seems
more sensible.
just my two cents,
re,
wh
>
> if (input->u.kbd.repeat_str[0]) {
> @@ -1766,7 +1766,7 @@ static inline int input_state_high(struct logical_input *input)
> if (input->high_timer >= KEYPAD_REP_START) {
> input->high_timer -= KEYPAD_REP_DELAY;
> keypad_send_key(repeat_str,
> - sizeof(repeat_str));
> + sizeof(input->u.kbd.repeat_str));
> }
> /* we will need to come back here soon */
> inputs_stable = 0;
> @@ -1805,7 +1805,7 @@ static inline void input_state_falling(struct logical_input *input)
> if (input->high_timer >= KEYPAD_REP_START)
> input->high_timer -= KEYPAD_REP_DELAY;
> keypad_send_key(repeat_str,
> - sizeof(repeat_str));
> + sizeof(input->u.kbd.repeat_str));
> /* we will need to come back here soon */
> inputs_stable = 0;
> }
> @@ -1824,7 +1824,7 @@ static inline void input_state_falling(struct logical_input *input)
> char *release_str = input->u.kbd.release_str;
> if (release_str[0])
> keypad_send_key(release_str,
> - sizeof(release_str));
> + sizeof(input->u.kbd.release_str));
> }
>
> input->state = INPUT_ST_LOW;
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
2012-11-30 9:19 ` walter harms
@ 2012-12-01 8:08 ` Willy Tarreau
2012-12-01 8:13 ` Willy Tarreau
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Willy Tarreau @ 2012-12-01 8:08 UTC (permalink / raw)
To: kernel-janitors
Hi Dan,
On Thu, Nov 29, 2012 at 05:38:35PM +0300, Dan Carpenter wrote:
> We changed the sizeof() statements in 429ccf058b "staging:panel: Fixed
> coding conventions." so that they could fit inside the 80 character
> line limit. Unfortunately, the new sizeof() statements are a smaller
> size. This reverts it.
>
> There isn't a nice way to stay within the 80 character limit without
> a re-work so I've gone over.
Don't bother too much about the limit anyway, it's more of a guideline,
and the first time the code was adapted to fit, it became totally unreadable.
And BTW, I think that the only reason for the bug you found precisely is
the introduction of these repeat_str/release_str local variables that seem
to be there just to reduce line length...
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Untested. The ->u.kbd.press_str and friends are funny data types.
I agree, it looks like the initial intent was to have the strings
fit well within the union, but this is all but obvious.
> I'm
> not sure how this code, works but the stuff we have is wrong and I've
> reverted it back to the original.
Acked-by: Willy Tarreau <w@1wt.eu>
Willy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
2012-11-30 9:19 ` walter harms
2012-12-01 8:08 ` Willy Tarreau
@ 2012-12-01 8:13 ` Willy Tarreau
2012-12-02 11:22 ` Dan Carpenter
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Willy Tarreau @ 2012-12-01 8:13 UTC (permalink / raw)
To: kernel-janitors
On Fri, Nov 30, 2012 at 10:19:06AM +0100, walter harms wrote:
>
>
> Am 29.11.2012 15:38, schrieb Dan Carpenter:
> > We changed the sizeof() statements in 429ccf058b "staging:panel: Fixed
> > coding conventions." so that they could fit inside the 80 character
> > line limit. Unfortunately, the new sizeof() statements are a smaller
> > size. This reverts it.
> >
> > There isn't a nice way to stay within the 80 character limit without
> > a re-work so I've gone over.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Untested. The ->u.kbd.press_str and friends are funny data types. I'm
> > not sure how this code, works but the stuff we have is wrong and I've
> > reverted it back to the original.
> >
> > diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> > index d9fec5b..dca42ce 100644
> > --- a/drivers/staging/panel/panel.c
> > +++ b/drivers/staging/panel/panel.c
> > @@ -1758,7 +1758,7 @@ static inline int input_state_high(struct logical_input *input)
> > char *press_str = input->u.kbd.press_str;
> > if (press_str[0])
> > keypad_send_key(press_str,
> > - sizeof(press_str));
> > + sizeof(input->u.kbd.press_str));
> > }
> yep, this looks like the original intention.
> NTL i would like to question the use of press_str and friends.
> Moving the if (press_str[0]) into keypad_send_key() seems
> more sensible.
Good point, I agree with you.
Willy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
` (2 preceding siblings ...)
2012-12-01 8:13 ` Willy Tarreau
@ 2012-12-02 11:22 ` Dan Carpenter
2012-12-02 11:53 ` Willy Tarreau
2012-12-02 15:44 ` walter harms
5 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2012-12-02 11:22 UTC (permalink / raw)
To: kernel-janitors
On Fri, Nov 30, 2012 at 10:19:06AM +0100, walter harms wrote:
> > if (press_str[0])
> > keypad_send_key(press_str,
> > - sizeof(press_str));
> > + sizeof(input->u.kbd.press_str));
> > }
> yep, this looks like the original intention.
> NTL i would like to question the use of press_str and friends.
> Moving the if (press_str[0]) into keypad_send_key() seems
> more sensible.
>
> just my two cents,
>
Greg had already applied my patch by the you sent this email.
What you're saying sounds like it should be a good cleanup, but when
I actually look at it, the callers still have to test repeat_str[0]
so it's not as useful as one would hope.
Really this stuff is really confusing. I'm not sure what is
actually stored in press_str. Is it a pointer or just chars? If
it's a pointer then why are we only checking the first bit instead
of checking the pointer? I think it's characters but why is it
declared as "char press_str[sizeof(void *) + sizeof(int)];"?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
` (3 preceding siblings ...)
2012-12-02 11:22 ` Dan Carpenter
@ 2012-12-02 11:53 ` Willy Tarreau
2012-12-02 15:44 ` walter harms
5 siblings, 0 replies; 7+ messages in thread
From: Willy Tarreau @ 2012-12-02 11:53 UTC (permalink / raw)
To: kernel-janitors
Hi Dan,
On Sun, Dec 02, 2012 at 02:22:13PM +0300, Dan Carpenter wrote:
> On Fri, Nov 30, 2012 at 10:19:06AM +0100, walter harms wrote:
> > > if (press_str[0])
> > > keypad_send_key(press_str,
> > > - sizeof(press_str));
> > > + sizeof(input->u.kbd.press_str));
> > > }
> > yep, this looks like the original intention.
> > NTL i would like to question the use of press_str and friends.
> > Moving the if (press_str[0]) into keypad_send_key() seems
> > more sensible.
> >
> > just my two cents,
> >
>
> Greg had already applied my patch by the you sent this email.
>
> What you're saying sounds like it should be a good cleanup, but when
> I actually look at it, the callers still have to test repeat_str[0]
> so it's not as useful as one would hope.
>
> Really this stuff is really confusing. I'm not sure what is
> actually stored in press_str. Is it a pointer or just chars? If
> it's a pointer then why are we only checking the first bit instead
> of checking the pointer? I think it's characters but why is it
> declared as "char press_str[sizeof(void *) + sizeof(int)];"?
It's just chars. It was declared this way so that it did not
inflate the union it's declared in. This is totally ugly and
should be cleaned. But it dates 13 years ago when we were trying
to shrink everything to have full-featured kernels in less than
500kB to boot from floppies...
Regards,
Willy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [patch] staging: panel: pass correct lengths to keypad_send_key()
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
` (4 preceding siblings ...)
2012-12-02 11:53 ` Willy Tarreau
@ 2012-12-02 15:44 ` walter harms
5 siblings, 0 replies; 7+ messages in thread
From: walter harms @ 2012-12-02 15:44 UTC (permalink / raw)
To: kernel-janitors
Am 02.12.2012 12:53, schrieb Willy Tarreau:
> Hi Dan,
>
> On Sun, Dec 02, 2012 at 02:22:13PM +0300, Dan Carpenter wrote:
>> On Fri, Nov 30, 2012 at 10:19:06AM +0100, walter harms wrote:
>>>> if (press_str[0])
>>>> keypad_send_key(press_str,
>>>> - sizeof(press_str));
>>>> + sizeof(input->u.kbd.press_str));
>>>> }
>>> yep, this looks like the original intention.
>>> NTL i would like to question the use of press_str and friends.
>>> Moving the if (press_str[0]) into keypad_send_key() seems
>>> more sensible.
>>>
>>> just my two cents,
>>>
>>
>> Greg had already applied my patch by the you sent this email.
>>
>> What you're saying sounds like it should be a good cleanup, but when
>> I actually look at it, the callers still have to test repeat_str[0]
>> so it's not as useful as one would hope.
>>
>> Really this stuff is really confusing. I'm not sure what is
>> actually stored in press_str. Is it a pointer or just chars? If
>> it's a pointer then why are we only checking the first bit instead
>> of checking the pointer? I think it's characters but why is it
>> declared as "char press_str[sizeof(void *) + sizeof(int)];"?
>
> It's just chars. It was declared this way so that it did not
> inflate the union it's declared in. This is totally ugly and
> should be cleaned. But it dates 13 years ago when we were trying
> to shrink everything to have full-featured kernels in less than
> 500kB to boot from floppies...
>
It is not a bad think to save space.
The question is about readability.
re,
wh
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-12-02 15:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29 14:38 [patch] staging: panel: pass correct lengths to keypad_send_key() Dan Carpenter
2012-11-30 9:19 ` walter harms
2012-12-01 8:08 ` Willy Tarreau
2012-12-01 8:13 ` Willy Tarreau
2012-12-02 11:22 ` Dan Carpenter
2012-12-02 11:53 ` Willy Tarreau
2012-12-02 15:44 ` walter harms
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).