linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Andrey Utkin <andrey_utkin@fastmail.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: Mon, 24 Oct 2016 22:11:15 -0200	[thread overview]
Message-ID: <20161024221115.3632aa5c@vento.lan> (raw)
In-Reply-To: <20161024222844.GD25320@dell-m4800.home>

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);


That's worse :)

The usual Kernel style is:

		var = foo(bar1,
		          bar2,
		          bar3);

instead of something like:

		var =
		    foo(bar1,
			bar2,
			bar3);

The places where it is different than that is because people ran
./scripts/Lindent to try to follow the Kernel coding style.

On my experiences, at the end, using it caused more harm than
good, IMHO, and cause very weird indentation on lines with
more than 80 columns like the above.

Thanks,
Mauro

  reply	other threads:[~2016-10-25  0:11 UTC|newest]

Thread overview: 13+ 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:59 ` [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() SF Markus Elfring
2016-10-24 22:28   ` Andrey Utkin
2016-10-25  0:11     ` Mauro Carvalho Chehab [this message]
2016-10-25  5:51       ` Julia Lawall
2016-10-25 12:46       ` Andrey Utkin
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:01 ` [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() SF Markus Elfring
2016-10-25  9:06   ` Dan Carpenter
2016-11-03 12:41   ` Hans Verkuil
2016-11-03 19:56     ` SF Markus Elfring
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=20161024221115.3632aa5c@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=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=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 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).