* [PATCH 0/3] [media] usbvision: Adjustments for six function implementations
@ 2017-08-26 20:42 SF Markus Elfring
2017-08-26 20:44 ` [PATCH 1/3] [media] usbvision: Delete an error message for a failed memory allocation in usbvision_probe() SF Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-26 20:42 UTC (permalink / raw)
To: linux-media, Davidlohr Bueso, Hans Verkuil, Johan Hovold,
Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Aug 2017 22:36:54 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in usbvision_probe()
Adjust eight checks for null pointers
Improve a size determination in usbvision_alloc()
drivers/media/usb/usbvision/usbvision-video.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
--
2.14.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] [media] usbvision: Delete an error message for a failed memory allocation in usbvision_probe()
2017-08-26 20:42 [PATCH 0/3] [media] usbvision: Adjustments for six function implementations SF Markus Elfring
@ 2017-08-26 20:44 ` SF Markus Elfring
2017-08-26 20:50 ` [PATCH 2/3] [media] usbvision: Adjust eight checks for null pointers SF Markus Elfring
2017-08-26 20:52 ` [PATCH 3/3] [media] usbvision: Improve a size determination in usbvision_alloc() SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-26 20:44 UTC (permalink / raw)
To: linux-media, Davidlohr Bueso, Hans Verkuil, Johan Hovold,
Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Aug 2017 22:06:05 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/usbvision/usbvision-video.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index 756322c4ac05..b74fb2dcb6f5 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -1498,4 +1498,3 @@ static int usbvision_probe(struct usb_interface *intf,
- dev_err(&intf->dev, "usbvision: out of memory!\n");
ret = -ENOMEM;
goto err_pkt;
}
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] [media] usbvision: Adjust eight checks for null pointers
2017-08-26 20:42 [PATCH 0/3] [media] usbvision: Adjustments for six function implementations SF Markus Elfring
2017-08-26 20:44 ` [PATCH 1/3] [media] usbvision: Delete an error message for a failed memory allocation in usbvision_probe() SF Markus Elfring
@ 2017-08-26 20:50 ` SF Markus Elfring
2017-08-26 20:52 ` [PATCH 3/3] [media] usbvision: Improve a size determination in usbvision_alloc() SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-26 20:50 UTC (permalink / raw)
To: linux-media, Davidlohr Bueso, Hans Verkuil, Johan Hovold,
Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Aug 2017 22:16:52 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/usbvision/usbvision-video.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index b74fb2dcb6f5..e6807bad9792 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -904,7 +904,7 @@ static ssize_t usbvision_read(struct file *file, char __user *buf,
PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__,
(unsigned long)count, noblock);
- if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL))
+ if (!USBVISION_IS_OPERATIONAL(usbvision) || !buf)
return -EFAULT;
/* This entry point is compatible with the mmap routines
@@ -1234,7 +1234,7 @@ static void usbvision_vdev_init(struct usb_usbvision *usbvision,
{
struct usb_device *usb_dev = usbvision->dev;
- if (usb_dev == NULL) {
+ if (!usb_dev) {
dev_err(&usbvision->dev->dev,
"%s: usbvision->dev is not set\n", __func__);
return;
@@ -1323,4 +1323,4 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
- if (usbvision == NULL)
+ if (!usbvision)
return NULL;
usbvision->dev = dev;
@@ -1334,7 +1334,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
/* prepare control urb for control messages during interrupts */
usbvision->ctrl_urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
- if (usbvision->ctrl_urb == NULL)
+ if (!usbvision->ctrl_urb)
goto err_unreg;
return usbvision;
@@ -1380,7 +1380,7 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
{
int model;
- if (usbvision == NULL)
+ if (!usbvision)
return;
model = usbvision->dev_model;
@@ -1474,7 +1474,7 @@ static int usbvision_probe(struct usb_interface *intf,
}
usbvision = usbvision_alloc(dev, intf);
- if (usbvision == NULL) {
+ if (!usbvision) {
dev_err(&intf->dev, "%s: couldn't allocate USBVision struct\n", __func__);
ret = -ENOMEM;
goto err_usb;
@@ -1494,5 +1494,5 @@ static int usbvision_probe(struct usb_interface *intf,
usbvision->num_alt = uif->num_altsetting;
PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt);
usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL);
- if (usbvision->alt_max_pkt_size == NULL) {
+ if (!usbvision->alt_max_pkt_size) {
ret = -ENOMEM;
@@ -1565,7 +1565,7 @@ static void usbvision_disconnect(struct usb_interface *intf)
PDEBUG(DBG_PROBE, "");
- if (usbvision == NULL) {
+ if (!usbvision) {
pr_err("%s: usb_get_intfdata() failed\n", __func__);
return;
}
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] [media] usbvision: Improve a size determination in usbvision_alloc()
2017-08-26 20:42 [PATCH 0/3] [media] usbvision: Adjustments for six function implementations SF Markus Elfring
2017-08-26 20:44 ` [PATCH 1/3] [media] usbvision: Delete an error message for a failed memory allocation in usbvision_probe() SF Markus Elfring
2017-08-26 20:50 ` [PATCH 2/3] [media] usbvision: Adjust eight checks for null pointers SF Markus Elfring
@ 2017-08-26 20:52 ` SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-26 20:52 UTC (permalink / raw)
To: linux-media, Davidlohr Bueso, Hans Verkuil, Johan Hovold,
Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Aug 2017 22:22:13 +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/usbvision/usbvision-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c
index e6807bad9792..960272d3c924 100644
--- a/drivers/media/usb/usbvision/usbvision-video.c
+++ b/drivers/media/usb/usbvision/usbvision-video.c
@@ -1319,7 +1319,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev,
{
struct usb_usbvision *usbvision;
- usbvision = kzalloc(sizeof(struct usb_usbvision), GFP_KERNEL);
+ usbvision = kzalloc(sizeof(*usbvision), GFP_KERNEL);
if (!usbvision)
return NULL;
--
2.14.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-26 20:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-26 20:42 [PATCH 0/3] [media] usbvision: Adjustments for six function implementations SF Markus Elfring
2017-08-26 20:44 ` [PATCH 1/3] [media] usbvision: Delete an error message for a failed memory allocation in usbvision_probe() SF Markus Elfring
2017-08-26 20:50 ` [PATCH 2/3] [media] usbvision: Adjust eight checks for null pointers SF Markus Elfring
2017-08-26 20:52 ` [PATCH 3/3] [media] usbvision: Improve a size determination in usbvision_alloc() SF Markus Elfring
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).