diff mbox

[08/18] HID: Adjust five checks for null pointers

Message ID 8dbffcc9-34e2-5e1d-e4f5-342786f91c53@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring Feb. 7, 2017, 7:50 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:15:21 +0100
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 affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 1f75c1c022f0..f4ea3590954c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -959,7 +959,7 @@  int hid_open_report(struct hid_device *device)
 	size = device->dev_rsize;
 
 	buf = kmemdup(start, size, GFP_KERNEL);
-	if (buf == NULL)
+	if (!buf)
 		return -ENOMEM;
 
 	if (device->driver->report_fixup)
@@ -969,7 +969,7 @@  int hid_open_report(struct hid_device *device)
 
 	start = kmemdup(start, size, GFP_KERNEL);
 	kfree(buf);
-	if (start == NULL)
+	if (!start)
 		return -ENOMEM;
 
 	device->rdesc = start;
@@ -1414,7 +1414,7 @@  static struct hid_report *hid_get_report(struct hid_report_enum *report_enum,
 		n = *data;
 
 	report = report_enum->report_id_hash[n];
-	if (report == NULL)
+	if (!report)
 		dbg_hid("undefined report_id %u received\n", n);
 
 	return report;
@@ -2222,7 +2222,7 @@  static int hid_device_probe(struct device *dev)
 
 	if (!hdev->driver) {
 		id = hid_match_device(hdev, hdrv);
-		if (id == NULL) {
+		if (!id) {
 			ret = -ENODEV;
 			goto unlock;
 		}
@@ -2719,7 +2719,7 @@  struct hid_device *hid_allocate_device(void)
 	int ret = -ENOMEM;
 
 	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
-	if (hdev == NULL)
+	if (!hdev)
 		return ERR_PTR(ret);
 
 	device_initialize(&hdev->dev);