* [PATCH 1/3] [media] hdpvr: Delete three error messages for a failed memory allocation
2017-09-19 18:44 [PATCH 0/3] [media] HD PVR USB: Adjustments for two function implementations SF Markus Elfring
@ 2017-09-19 18:45 ` SF Markus Elfring
2017-09-19 18:46 ` [PATCH 2/3] [media] hdpvr: Improve a size determination in hdpvr_alloc_buffers() SF Markus Elfring
2017-09-19 18:47 ` [PATCH 3/3] [media] hdpvr: Return an error code only as a constant " SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-09-19 18:45 UTC (permalink / raw)
To: linux-media, Andrew Morton, Arvind Yadav, Hans Verkuil,
Jonathan Sims, Laurent Pinchart, Masahiro Yamada,
Mauro Carvalho Chehab
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Sep 2017 09:33:26 +0200
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/hdpvr/hdpvr-core.c | 8 ++------
drivers/media/usb/hdpvr/hdpvr-video.c | 5 ++---
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr/hdpvr-core.c
index dbe29c6c4d8b..f1c156814e10 100644
--- a/drivers/media/usb/hdpvr/hdpvr-core.c
+++ b/drivers/media/usb/hdpvr/hdpvr-core.c
@@ -282,6 +282,4 @@ static int hdpvr_probe(struct usb_interface *interface,
- if (!dev) {
- dev_err(&interface->dev, "Out of memory\n");
+ if (!dev)
goto error;
- }
/* init video transfer queues first of all */
@@ -302,6 +300,4 @@ static int hdpvr_probe(struct usb_interface *interface,
- if (!dev->usbc_buf) {
- v4l2_err(&dev->v4l2_dev, "Out of memory\n");
+ if (!dev->usbc_buf)
goto error;
- }
init_waitqueue_head(&dev->wait_buffer);
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 7fb036d6a86e..657d910dfa1d 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -150,7 +150,6 @@ int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
- if (!buf) {
- v4l2_err(&dev->v4l2_dev, "cannot allocate buffer\n");
+ if (!buf)
goto exit;
- }
+
buf->dev = dev;
urb = usb_alloc_urb(0, GFP_KERNEL);
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/3] [media] hdpvr: Improve a size determination in hdpvr_alloc_buffers()
2017-09-19 18:44 [PATCH 0/3] [media] HD PVR USB: Adjustments for two function implementations SF Markus Elfring
2017-09-19 18:45 ` [PATCH 1/3] [media] hdpvr: Delete three error messages for a failed memory allocation SF Markus Elfring
@ 2017-09-19 18:46 ` SF Markus Elfring
2017-09-19 18:47 ` [PATCH 3/3] [media] hdpvr: Return an error code only as a constant " SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-09-19 18:46 UTC (permalink / raw)
To: linux-media, Andrew Morton, Arvind Yadav, Hans Verkuil,
Jonathan Sims, Laurent Pinchart, Masahiro Yamada,
Mauro Carvalho Chehab
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Sep 2017 19:27:53 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/hdpvr/hdpvr-video.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 657d910dfa1d..f06efcd70c14 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -145,6 +145,5 @@ int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
"allocating %u buffers\n", count);
for (i = 0; i < count; i++) {
-
- buf = kzalloc(sizeof(struct hdpvr_buffer), GFP_KERNEL);
+ buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/3] [media] hdpvr: Return an error code only as a constant in hdpvr_alloc_buffers()
2017-09-19 18:44 [PATCH 0/3] [media] HD PVR USB: Adjustments for two function implementations SF Markus Elfring
2017-09-19 18:45 ` [PATCH 1/3] [media] hdpvr: Delete three error messages for a failed memory allocation SF Markus Elfring
2017-09-19 18:46 ` [PATCH 2/3] [media] hdpvr: Improve a size determination in hdpvr_alloc_buffers() SF Markus Elfring
@ 2017-09-19 18:47 ` SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-09-19 18:47 UTC (permalink / raw)
To: linux-media, Andrew Morton, Arvind Yadav, Hans Verkuil,
Jonathan Sims, Laurent Pinchart, Masahiro Yamada,
Mauro Carvalho Chehab
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 19 Sep 2017 19:32:36 +0200
* Return an error code without storing it in an intermediate variable.
* Delete the local variable "retval" which became unnecessary
with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/hdpvr/hdpvr-video.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index f06efcd70c14..2b39834309d2 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -136,6 +136,5 @@ int hdpvr_free_buffers(struct hdpvr_device *dev)
int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
{
uint i;
- int retval = -ENOMEM;
u8 *mem;
struct hdpvr_buffer *buf;
@@ -181,6 +180,6 @@ int hdpvr_alloc_buffers(struct hdpvr_device *dev, uint count)
kfree(buf);
exit:
hdpvr_free_buffers(dev);
- return retval;
+ return -ENOMEM;
}
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread