All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Utkin <andrey_utkin@fastmail.com>
To: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-media@vger.kernel.org,
	"Hans Verkuil" <hans.verkuil@cisco.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Rafael Lourenço de Lima Chehab" <chehabrafael@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Wolfram Sang" <wsa-dev@sang-engineering.com>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()
Date: Tue, 25 Oct 2016 13:46:17 +0100	[thread overview]
Message-ID: <20161025124617.GB6567@stationary.pb.com> (raw)
In-Reply-To: <20161024221115.3632aa5c@vento.lan>

On Mon, Oct 24, 2016 at 10:11:15PM -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 23:28:44 +0100
> Andrey Utkin <andrey_utkin@fastmail.com> escreveu:
> 
> > On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Mon, 24 Oct 2016 22:08:47 +0200
> > > 
> > > * Multiplications for the size determination of memory allocations
> > >   indicated that array data structures should be processed.
> > >   Thus use the corresponding function "kcalloc".
> > > 
> > >   This issue was detected by using the Coccinelle software.
> > > 
> > > * Replace the specification of data types by pointer dereferences
> > >   to make the corresponding size determination a bit safer according to
> > >   the Linux coding style convention.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > ---
> > >  drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> > >  1 file changed, 7 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > > index 85dd9a8..85b13c1 100644
> > > --- a/drivers/media/usb/au0828/au0828-video.c
> > > +++ b/drivers/media/usb/au0828/au0828-video.c
> > > @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> > >  
> > >  	dev->isoc_ctl.isoc_copy = isoc_copy;
> > >  	dev->isoc_ctl.num_bufs = num_bufs;
> > > -  
> > 
> > > -	dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
> > > +	dev->isoc_ctl.urb = kcalloc(num_bufs,
> > > +				    sizeof(*dev->isoc_ctl.urb),
> > > +				    GFP_KERNEL);  
> > 
> > What about this (for both hunks)?
> > 
> > -	dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
> > +	dev->isoc_ctl.urb =
> > +		kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);

Now i see that also this should suit style better than original variant:

	dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb),
				    GFP_KERNEL);

That's what vim with github.com/vivien/vim-linux-coding-style plugin
proposes.

> That's worse :)

I was about to send long emotional noobish bikeshedding rant arguing
with this point, but restrained from that keeping in mind that I want to
proceed contributing to the codebase successfully :) I'll keep my coding
style preferences for myself for a while.

WARNING: multiple messages have this Message-ID (diff)
From: Andrey Utkin <andrey_utkin@fastmail.com>
To: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Cc: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	linux-media@vger.kernel.org,
	"Hans Verkuil" <hans.verkuil@cisco.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Rafael Lourenço de Lima Chehab" <chehabrafael@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Wolfram Sang" <wsa-dev@sang-engineering.com>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()
Date: Tue, 25 Oct 2016 12:46:17 +0000	[thread overview]
Message-ID: <20161025124617.GB6567@stationary.pb.com> (raw)
In-Reply-To: <20161024221115.3632aa5c@vento.lan>

On Mon, Oct 24, 2016 at 10:11:15PM -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 23:28:44 +0100
> Andrey Utkin <andrey_utkin@fastmail.com> escreveu:
> 
> > On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Mon, 24 Oct 2016 22:08:47 +0200
> > > 
> > > * Multiplications for the size determination of memory allocations
> > >   indicated that array data structures should be processed.
> > >   Thus use the corresponding function "kcalloc".
> > > 
> > >   This issue was detected by using the Coccinelle software.
> > > 
> > > * Replace the specification of data types by pointer dereferences
> > >   to make the corresponding size determination a bit safer according to
> > >   the Linux coding style convention.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > ---
> > >  drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> > >  1 file changed, 7 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > > index 85dd9a8..85b13c1 100644
> > > --- a/drivers/media/usb/au0828/au0828-video.c
> > > +++ b/drivers/media/usb/au0828/au0828-video.c
> > > @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> > >  
> > >  	dev->isoc_ctl.isoc_copy = isoc_copy;
> > >  	dev->isoc_ctl.num_bufs = num_bufs;
> > > -  
> > 
> > > -	dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
> > > +	dev->isoc_ctl.urb = kcalloc(num_bufs,
> > > +				    sizeof(*dev->isoc_ctl.urb),
> > > +				    GFP_KERNEL);  
> > 
> > What about this (for both hunks)?
> > 
> > -	dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
> > +	dev->isoc_ctl.urb > > +		kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);

Now i see that also this should suit style better than original variant:

	dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb),
				    GFP_KERNEL);

That's what vim with github.com/vivien/vim-linux-coding-style plugin
proposes.

> That's worse :)

I was about to send long emotional noobish bikeshedding rant arguing
with this point, but restrained from that keeping in mind that I want to
proceed contributing to the codebase successfully :) I'll keep my coding
style preferences for myself for a while.

  parent reply	other threads:[~2016-10-25 12:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 20:58 [PATCH 0/3] [media] au0828-video: Fine-tuning for au0828_init_isoc() SF Markus Elfring
2016-10-24 20:58 ` SF Markus Elfring
2016-10-24 20:59 ` [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() SF Markus Elfring
2016-10-24 20:59   ` SF Markus Elfring
2016-10-24 22:28   ` Andrey Utkin
2016-10-24 22:28     ` Andrey Utkin
2016-10-25  0:11     ` Mauro Carvalho Chehab
2016-10-25  0:11       ` Mauro Carvalho Chehab
2016-10-25  5:51       ` Julia Lawall
2016-10-25  5:51         ` Julia Lawall
2016-10-25 12:46       ` Andrey Utkin [this message]
2016-10-25 12:46         ` Andrey Utkin
2016-10-25  8:40   ` Dan Carpenter
2016-10-25  8:40     ` Dan Carpenter
2016-10-24 21:00 ` [PATCH 2/3] [media] au0828-video: Delete three error messages for a failed memory allocation SF Markus Elfring
2016-10-24 21:00   ` SF Markus Elfring
2016-10-24 21:01 ` [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() SF Markus Elfring
2016-10-24 21:01   ` SF Markus Elfring
2016-10-25  9:06   ` Dan Carpenter
2016-10-25  9:06     ` Dan Carpenter
2016-11-03 12:41   ` Hans Verkuil
2016-11-03 12:41     ` Hans Verkuil
2016-11-03 19:56     ` SF Markus Elfring
2016-11-03 19:56       ` SF Markus Elfring
2016-11-04  8:09       ` Hans Verkuil
2016-11-04  8:09         ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161025124617.GB6567@stationary.pb.com \
    --to=andrey_utkin@fastmail.com \
    --cc=chehabrafael@gmail.com \
    --cc=elfring@users.sourceforge.net \
    --cc=hans.verkuil@cisco.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mchehab@s-opensource.com \
    --cc=shuah@kernel.org \
    --cc=wsa-dev@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.