* [PATCH 0/3] [media] au0828-video: Fine-tuning for au0828_init_isoc() @ 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 ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: SF Markus Elfring @ 2016-10-24 20:58 UTC (permalink / raw) To: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Mon, 24 Oct 2016 22:52:10 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (3): Use kcalloc() Delete three error messages for a failed memory allocation Move two assignments drivers/media/usb/au0828/au0828-video.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) -- 2.10.1 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 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 ` SF Markus Elfring 2016-10-24 22:28 ` 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 2 siblings, 2 replies; 13+ messages in thread From: SF Markus Elfring @ 2016-10-24 20:59 UTC (permalink / raw) To: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang Cc: LKML, kernel-janitors 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); if (!dev->isoc_ctl.urb) { au0828_isocdbg("cannot alloc memory for usb buffers\n"); return -ENOMEM; } - dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, - GFP_KERNEL); + dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, + sizeof(*dev->isoc_ctl + .transfer_buffer), + GFP_KERNEL); if (!dev->isoc_ctl.transfer_buffer) { au0828_isocdbg("cannot allocate memory for usb transfer\n"); kfree(dev->isoc_ctl.urb); -- 2.10.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 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 2016-10-25 8:40 ` Dan Carpenter 1 sibling, 1 reply; 13+ messages in thread From: Andrey Utkin @ 2016-10-24 22:28 UTC (permalink / raw) To: SF Markus Elfring Cc: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors 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); ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 2016-10-24 22:28 ` Andrey Utkin @ 2016-10-25 0:11 ` Mauro Carvalho Chehab 2016-10-25 5:51 ` Julia Lawall 2016-10-25 12:46 ` Andrey Utkin 0 siblings, 2 replies; 13+ messages in thread From: Mauro Carvalho Chehab @ 2016-10-25 0:11 UTC (permalink / raw) To: Andrey Utkin Cc: SF Markus Elfring, linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors 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 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 2016-10-25 0:11 ` Mauro Carvalho Chehab @ 2016-10-25 5:51 ` Julia Lawall 2016-10-25 12:46 ` Andrey Utkin 1 sibling, 0 replies; 13+ messages in thread From: Julia Lawall @ 2016-10-25 5:51 UTC (permalink / raw) To: Mauro Carvalho Chehab Cc: Andrey Utkin, SF Markus Elfring, linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors On Mon, 24 Oct 2016, 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); > > > That's worse :) > > The usual Kernel style is: > > var = foo(bar1, > bar2, > bar3); Isn't it more like var = foo(bar1, bar2, bar3) Otherwise, Markus is going to send millions of patches to put every function argument on its own line... julia > > 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 > -- > 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] 13+ messages in thread
* Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 2016-10-25 0:11 ` Mauro Carvalho Chehab 2016-10-25 5:51 ` Julia Lawall @ 2016-10-25 12:46 ` Andrey Utkin 1 sibling, 0 replies; 13+ messages in thread From: Andrey Utkin @ 2016-10-25 12:46 UTC (permalink / raw) To: Mauro Carvalho Chehab Cc: SF Markus Elfring, linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors 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. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc() 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 8:40 ` Dan Carpenter 1 sibling, 0 replies; 13+ messages in thread From: Dan Carpenter @ 2016-10-25 8:40 UTC (permalink / raw) To: SF Markus Elfring Cc: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote: > + dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, > + sizeof(*dev->isoc_ctl > + .transfer_buffer), This is ugly. regards, dan carpenter ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/3] [media] au0828-video: Delete three error messages for a failed memory allocation 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 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 2 siblings, 0 replies; 13+ messages in thread From: SF Markus Elfring @ 2016-10-24 21:00 UTC (permalink / raw) To: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Mon, 24 Oct 2016 22:28:03 +0200 Omit extra messages for a memory allocation failure in this function. Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/media/usb/au0828/au0828-video.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 85b13c1..b5c88a7 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -224,17 +224,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL); - if (!dev->isoc_ctl.urb) { - au0828_isocdbg("cannot alloc memory for usb buffers\n"); + if (!dev->isoc_ctl.urb) return -ENOMEM; - } dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(*dev->isoc_ctl .transfer_buffer), GFP_KERNEL); if (!dev->isoc_ctl.transfer_buffer) { - au0828_isocdbg("cannot allocate memory for usb transfer\n"); kfree(dev->isoc_ctl.urb); return -ENOMEM; } @@ -256,10 +253,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->usbdev, sb_size, GFP_KERNEL, &urb->transfer_dma); if (!dev->isoc_ctl.transfer_buffer[i]) { - printk("unable to allocate %i bytes for transfer" - " buffer %i%s\n", - sb_size, i, - in_interrupt() ? " while in int" : ""); au0828_uninit_isoc(dev); return -ENOMEM; } -- 2.10.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() 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 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 ` SF Markus Elfring 2016-10-25 9:06 ` Dan Carpenter 2016-11-03 12:41 ` Hans Verkuil 2 siblings, 2 replies; 13+ messages in thread From: SF Markus Elfring @ 2016-10-24 21:01 UTC (permalink / raw) To: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang Cc: LKML, kernel-janitors From: Markus Elfring <elfring@users.sourceforge.net> Date: Mon, 24 Oct 2016 22:44:02 +0200 Move the assignment for the data structure members "isoc_copy" and "num_bufs" behind the source code for memory allocations by this function. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/media/usb/au0828/au0828-video.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index b5c88a7..5ebda64 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, int rc; au0828_isocdbg("au0828: called au0828_prepare_isoc\n"); - - dev->isoc_ctl.isoc_copy = isoc_copy; - dev->isoc_ctl.num_bufs = num_bufs; dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL); @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, dev->isoc_ctl.buf = NULL; sb_size = max_packets * dev->isoc_ctl.max_pkt_size; + dev->isoc_ctl.num_bufs = num_bufs; /* allocate urbs and transfer buffers */ for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, k += dev->isoc_ctl.max_pkt_size; } } + dev->isoc_ctl.isoc_copy = isoc_copy; /* submit urbs and enables IRQ */ for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { -- 2.10.1 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() 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 1 sibling, 0 replies; 13+ messages in thread From: Dan Carpenter @ 2016-10-25 9:06 UTC (permalink / raw) To: SF Markus Elfring Cc: linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors This patch introduces bugs. It's my policy to not explain the Markus's bugs because otherwise he will just resend the patchset and I have asked him many times to stop. I will happily review bug fix patches but I really think he should stop sending these cleanup patches. regards, dan carpenter ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() 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 1 sibling, 1 reply; 13+ messages in thread From: Hans Verkuil @ 2016-11-03 12:41 UTC (permalink / raw) To: SF Markus Elfring, linux-media, Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang Cc: LKML, kernel-janitors On 24/10/16 23:01, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Mon, 24 Oct 2016 22:44:02 +0200 > > Move the assignment for the data structure members "isoc_copy" > and "num_bufs" behind the source code for memory allocations > by this function. I don't see the point, dropping this patch. Hans > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/media/usb/au0828/au0828-video.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c > index b5c88a7..5ebda64 100644 > --- a/drivers/media/usb/au0828/au0828-video.c > +++ b/drivers/media/usb/au0828/au0828-video.c > @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, > int rc; > > au0828_isocdbg("au0828: called au0828_prepare_isoc\n"); > - > - dev->isoc_ctl.isoc_copy = isoc_copy; > - dev->isoc_ctl.num_bufs = num_bufs; > dev->isoc_ctl.urb = kcalloc(num_bufs, > sizeof(*dev->isoc_ctl.urb), > GFP_KERNEL); > @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, > dev->isoc_ctl.buf = NULL; > > sb_size = max_packets * dev->isoc_ctl.max_pkt_size; > + dev->isoc_ctl.num_bufs = num_bufs; > > /* allocate urbs and transfer buffers */ > for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { > @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, > k += dev->isoc_ctl.max_pkt_size; > } > } > + dev->isoc_ctl.isoc_copy = isoc_copy; > > /* submit urbs and enables IRQ */ > for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() 2016-11-03 12:41 ` Hans Verkuil @ 2016-11-03 19:56 ` SF Markus Elfring 2016-11-04 8:09 ` Hans Verkuil 0 siblings, 1 reply; 13+ messages in thread From: SF Markus Elfring @ 2016-11-03 19:56 UTC (permalink / raw) To: Hans Verkuil, linux-media Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors >> From: Markus Elfring <elfring@users.sourceforge.net> >> Date: Mon, 24 Oct 2016 22:44:02 +0200 >> >> Move the assignment for the data structure members "isoc_copy" >> and "num_bufs" behind the source code for memory allocations >> by this function. > > I don't see the point, Another explanation try … > dropping this patch. I proposed that these assignments should only be performed after the required memory allocations succeeded. Is this detail worth for further considerations? >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> >> --- >> drivers/media/usb/au0828/au0828-video.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c >> index b5c88a7..5ebda64 100644 >> --- a/drivers/media/usb/au0828/au0828-video.c >> +++ b/drivers/media/usb/au0828/au0828-video.c >> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >> int rc; >> >> au0828_isocdbg("au0828: called au0828_prepare_isoc\n"); >> - >> - dev->isoc_ctl.isoc_copy = isoc_copy; >> - dev->isoc_ctl.num_bufs = num_bufs; >> dev->isoc_ctl.urb = kcalloc(num_bufs, >> sizeof(*dev->isoc_ctl.urb), >> GFP_KERNEL); >> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >> dev->isoc_ctl.buf = NULL; >> >> sb_size = max_packets * dev->isoc_ctl.max_pkt_size; >> + dev->isoc_ctl.num_bufs = num_bufs; >> >> /* allocate urbs and transfer buffers */ >> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { >> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >> k += dev->isoc_ctl.max_pkt_size; >> } >> } >> + dev->isoc_ctl.isoc_copy = isoc_copy; >> >> /* submit urbs and enables IRQ */ >> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { >> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc() 2016-11-03 19:56 ` SF Markus Elfring @ 2016-11-04 8:09 ` Hans Verkuil 0 siblings, 0 replies; 13+ messages in thread From: Hans Verkuil @ 2016-11-04 8:09 UTC (permalink / raw) To: SF Markus Elfring, linux-media Cc: Hans Verkuil, Laurent Pinchart, Mauro Carvalho Chehab, Rafael Lourenço de Lima Chehab, Shuah Khan, Wolfram Sang, LKML, kernel-janitors On 03/11/16 20:56, SF Markus Elfring wrote: >>> From: Markus Elfring <elfring@users.sourceforge.net> >>> Date: Mon, 24 Oct 2016 22:44:02 +0200 >>> >>> Move the assignment for the data structure members "isoc_copy" >>> and "num_bufs" behind the source code for memory allocations >>> by this function. >> >> I don't see the point, > > Another explanation try … > > >> dropping this patch. > > I proposed that these assignments should only be performed after the required > memory allocations succeeded. Is this detail worth for further considerations? I understand why you think it is better, but I disagree :-) I prefer the current approach, that way I know as a reviewer that these fields are correctly set and I can forget about them. Not worth spending more time on this. Regards, Hans > > >>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> >>> --- >>> drivers/media/usb/au0828/au0828-video.c | 5 ++--- >>> 1 file changed, 2 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c >>> index b5c88a7..5ebda64 100644 >>> --- a/drivers/media/usb/au0828/au0828-video.c >>> +++ b/drivers/media/usb/au0828/au0828-video.c >>> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >>> int rc; >>> >>> au0828_isocdbg("au0828: called au0828_prepare_isoc\n"); >>> - >>> - dev->isoc_ctl.isoc_copy = isoc_copy; >>> - dev->isoc_ctl.num_bufs = num_bufs; >>> dev->isoc_ctl.urb = kcalloc(num_bufs, >>> sizeof(*dev->isoc_ctl.urb), >>> GFP_KERNEL); >>> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >>> dev->isoc_ctl.buf = NULL; >>> >>> sb_size = max_packets * dev->isoc_ctl.max_pkt_size; >>> + dev->isoc_ctl.num_bufs = num_bufs; >>> >>> /* allocate urbs and transfer buffers */ >>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { >>> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, >>> k += dev->isoc_ctl.max_pkt_size; >>> } >>> } >>> + dev->isoc_ctl.isoc_copy = isoc_copy; >>> >>> /* submit urbs and enables IRQ */ >>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { >>> > ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2016-11-04 8:09 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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
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).