diff mbox

[25/27] staging: wilc1000: fix coding style of kmalloc usage

Message ID 1453339230-1377-25-git-send-email-chaehyun.lim@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show

Commit Message

Chaehyun Lim Jan. 21, 2016, 1:20 a.m. UTC
This patch fixes coding style of kmalloc usage found by checkpatch.
CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
---
 drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sudip Mukherjee Jan. 21, 2016, 8:18 a.m. UTC | #1
On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> This patch fixes coding style of kmalloc usage found by checkpatch.
> CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)
> 
> Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> ---
>  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
> index 7107715..c7a60f4 100644
> --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>  	}
>  
>  	/* construct a new message */
> -	new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> +	new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);

This checkpatch error was introduced by 1/27 patch of this series. Maybe
it will be better to fix it in that one.

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter Jan. 21, 2016, 8:55 a.m. UTC | #2
On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> > This patch fixes coding style of kmalloc usage found by checkpatch.
> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)
> > 
> > Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> > ---
> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
> > index 7107715..c7a60f4 100644
> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
> >  	}
> >  
> >  	/* construct a new message */
> > -	new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> > +	new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
> 
> This checkpatch error was introduced by 1/27 patch of this series. Maybe
> it will be better to fix it in that one.

The warning was introduced there but the issue went back further it's
just that checkpatch didn't detect it because of other issues.  This
seems fine.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chaehyun Lim Jan. 21, 2016, 10:01 a.m. UTC | #3
On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
>> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
>> > This patch fixes coding style of kmalloc usage found by checkpatch.
>> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)
>> >
>> > Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
>> > ---
>> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
>> > index 7107715..c7a60f4 100644
>> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
>> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
>> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>> >     }
>> >
>> >     /* construct a new message */
>> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
>> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
>>
>> This checkpatch error was introduced by 1/27 patch of this series. Maybe
>> it will be better to fix it in that one.
>
> The warning was introduced there but the issue went back further it's
> just that checkpatch didn't detect it because of other issues.  This
> seems fine.

I appreciate for all comment. I will resend it after applying Sudip's review.

regards,
Chaehyun Lim

>
> regards,
> dan carpenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter Jan. 21, 2016, 10:04 a.m. UTC | #4
On Thu, Jan 21, 2016 at 07:01:45PM +0900, Chaehyun Lim wrote:
> On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
> >> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
> >> > This patch fixes coding style of kmalloc usage found by checkpatch.
> >> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)
> >> >
> >> > Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
> >> > ---
> >> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > index 7107715..c7a60f4 100644
> >> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
> >> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
> >> >     }
> >> >
> >> >     /* construct a new message */
> >> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
> >> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
> >>
> >> This checkpatch error was introduced by 1/27 patch of this series. Maybe
> >> it will be better to fix it in that one.
> >
> > The warning was introduced there but the issue went back further it's
> > just that checkpatch didn't detect it because of other issues.  This
> > seems fine.
> 
> I appreciate for all comment. I will resend it after applying Sudip's review.
> 

That's fine too, but the original way is more correct because it only
fixes one thing at a time and is easier to review.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chaehyun Lim Jan. 21, 2016, 11:11 a.m. UTC | #5
On Thu, Jan 21, 2016 at 7:04 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Thu, Jan 21, 2016 at 07:01:45PM +0900, Chaehyun Lim wrote:
>> On Thu, Jan 21, 2016 at 5:55 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>> > On Thu, Jan 21, 2016 at 01:48:16PM +0530, Sudip Mukherjee wrote:
>> >> On Thu, Jan 21, 2016 at 10:20:28AM +0900, Chaehyun Lim wrote:
>> >> > This patch fixes coding style of kmalloc usage found by checkpatch.
>> >> > CHECK: Prefer kmalloc(sizeof(*new_msg)...) over kmalloc(sizeof(struct message)...)
>> >> >
>> >> > Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
>> >> > ---
>> >> >  drivers/staging/wilc1000/wilc_msgqueue.c | 2 +-
>> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >> >
>> >> > diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > index 7107715..c7a60f4 100644
>> >> > --- a/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > +++ b/drivers/staging/wilc1000/wilc_msgqueue.c
>> >> > @@ -70,7 +70,7 @@ int wilc_mq_send(struct message_queue *mq,
>> >> >     }
>> >> >
>> >> >     /* construct a new message */
>> >> > -   new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
>> >> > +   new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
>> >>
>> >> This checkpatch error was introduced by 1/27 patch of this series. Maybe
>> >> it will be better to fix it in that one.
>> >
>> > The warning was introduced there but the issue went back further it's
>> > just that checkpatch didn't detect it because of other issues.  This
>> > seems fine.
>>
>> I appreciate for all comment. I will resend it after applying Sudip's review.
>>
>
> That's fine too, but the original way is more correct because it only
> fixes one thing at a time and is easier to review.
>
I will keep the original way, even 1/27 patch was introduced a new
checkpatch warning.
I agree that one patch should be changed one thing.

But I need to resend again because I find a wrong variable name at commit title.

regards
Chaehyun Lim

> regards,
> dan carpenter
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
index 7107715..c7a60f4 100644
--- a/drivers/staging/wilc1000/wilc_msgqueue.c
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -70,7 +70,7 @@  int wilc_mq_send(struct message_queue *mq,
 	}
 
 	/* construct a new message */
-	new_msg = kmalloc(sizeof(struct message), GFP_ATOMIC);
+	new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC);
 	if (!new_msg)
 		return -ENOMEM;