* [PATCH 0/3] HID-Lenovo: Adjustments for three function implementations
@ 2018-02-06 16:14 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:14 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:12:34 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in two functions
Improve a size determination in lenovo_probe_tpkbd()
Adjust four checks for null pointers
drivers/hid/hid-lenovo.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--
2.16.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 0/3] HID-Lenovo: Adjustments for three function implementations
@ 2018-02-06 16:14 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:14 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:12:34 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in two functions
Improve a size determination in lenovo_probe_tpkbd()
Adjust four checks for null pointers
drivers/hid/hid-lenovo.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
--
2.16.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] HID: lenovo: Delete an error message for a failed memory allocation in two functions
2018-02-06 16:14 ` SF Markus Elfring
@ 2018-02-06 16:16 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:16 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:48:52 +0100
Omit an extra message 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/hid/hid-lenovo.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 1ac4ff4d57a6..549b84d01b46 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -688,7 +688,6 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
sizeof(struct lenovo_drvdata_tpkbd),
GFP_KERNEL);
if (data_pointer == NULL) {
- hid_err(hdev, "Could not allocate memory for driver data\n");
ret = -ENOMEM;
goto err;
}
@@ -746,10 +745,9 @@ static int lenovo_probe_cptkbd(struct hid_device *hdev)
cptkbd_data = devm_kzalloc(&hdev->dev,
sizeof(*cptkbd_data),
GFP_KERNEL);
- if (cptkbd_data == NULL) {
- hid_err(hdev, "can't alloc keyboard descriptor\n");
+ if (!cptkbd_data)
return -ENOMEM;
- }
+
hid_set_drvdata(hdev, cptkbd_data);
/*
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/3] HID: lenovo: Delete an error message for a failed memory allocation in two functions
@ 2018-02-06 16:16 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:16 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:48:52 +0100
Omit an extra message 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/hid/hid-lenovo.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 1ac4ff4d57a6..549b84d01b46 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -688,7 +688,6 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
sizeof(struct lenovo_drvdata_tpkbd),
GFP_KERNEL);
if (data_pointer = NULL) {
- hid_err(hdev, "Could not allocate memory for driver data\n");
ret = -ENOMEM;
goto err;
}
@@ -746,10 +745,9 @@ static int lenovo_probe_cptkbd(struct hid_device *hdev)
cptkbd_data = devm_kzalloc(&hdev->dev,
sizeof(*cptkbd_data),
GFP_KERNEL);
- if (cptkbd_data = NULL) {
- hid_err(hdev, "can't alloc keyboard descriptor\n");
+ if (!cptkbd_data)
return -ENOMEM;
- }
+
hid_set_drvdata(hdev, cptkbd_data);
/*
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] HID: lenovo: Improve a size determination in lenovo_probe_tpkbd()
2018-02-06 16:14 ` SF Markus Elfring
@ 2018-02-06 16:17 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:17 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:52:58 +0100
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/hid/hid-lenovo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 549b84d01b46..f863b94f3476 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -685,7 +685,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
hid_warn(hdev, "Could not create sysfs group: %d\n", ret);
data_pointer = devm_kzalloc(&hdev->dev,
- sizeof(struct lenovo_drvdata_tpkbd),
+ sizeof(*data_pointer),
GFP_KERNEL);
if (data_pointer == NULL) {
ret = -ENOMEM;
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] HID: lenovo: Improve a size determination in lenovo_probe_tpkbd()
@ 2018-02-06 16:17 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:17 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 16:52:58 +0100
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/hid/hid-lenovo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index 549b84d01b46..f863b94f3476 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -685,7 +685,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
hid_warn(hdev, "Could not create sysfs group: %d\n", ret);
data_pointer = devm_kzalloc(&hdev->dev,
- sizeof(struct lenovo_drvdata_tpkbd),
+ sizeof(*data_pointer),
GFP_KERNEL);
if (data_pointer = NULL) {
ret = -ENOMEM;
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] HID: lenovo: Adjust four checks for null pointers
2018-02-06 16:14 ` SF Markus Elfring
@ 2018-02-06 16:19 ` SF Markus Elfring
-1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:19 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:02:53 +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 the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lenovo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index f863b94f3476..ba128123466b 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -687,7 +687,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer = devm_kzalloc(&hdev->dev,
sizeof(*data_pointer),
GFP_KERNEL);
- if (data_pointer == NULL) {
+ if (!data_pointer) {
ret = -ENOMEM;
goto err;
}
@@ -698,7 +698,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
- if (name_mute == NULL || name_micmute == NULL) {
+ if (!name_mute || !name_micmute) {
hid_err(hdev, "Could not allocate memory for led data\n");
ret = -ENOMEM;
goto err;
@@ -823,7 +823,7 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev)
* Only the trackpoint half of the keyboard has drvdata and stuff that
* needs unregistering.
*/
- if (data_pointer == NULL)
+ if (!data_pointer)
return;
sysfs_remove_group(&hdev->dev.kobj,
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] HID: lenovo: Adjust four checks for null pointers
@ 2018-02-06 16:19 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2018-02-06 16:19 UTC (permalink / raw)
To: linux-input, Benjamin Tissoires, Jiri Kosina; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 6 Feb 2018 17:02:53 +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 the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-lenovo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index f863b94f3476..ba128123466b 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -687,7 +687,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
data_pointer = devm_kzalloc(&hdev->dev,
sizeof(*data_pointer),
GFP_KERNEL);
- if (data_pointer = NULL) {
+ if (!data_pointer) {
ret = -ENOMEM;
goto err;
}
@@ -698,7 +698,7 @@ static int lenovo_probe_tpkbd(struct hid_device *hdev)
name_mute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
name_micmute = devm_kzalloc(&hdev->dev, name_sz, GFP_KERNEL);
- if (name_mute = NULL || name_micmute = NULL) {
+ if (!name_mute || !name_micmute) {
hid_err(hdev, "Could not allocate memory for led data\n");
ret = -ENOMEM;
goto err;
@@ -823,7 +823,7 @@ static void lenovo_remove_tpkbd(struct hid_device *hdev)
* Only the trackpoint half of the keyboard has drvdata and stuff that
* needs unregistering.
*/
- if (data_pointer = NULL)
+ if (!data_pointer)
return;
sysfs_remove_group(&hdev->dev.kobj,
--
2.16.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-02-06 16:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-06 16:14 [PATCH 0/3] HID-Lenovo: Adjustments for three function implementations SF Markus Elfring
2018-02-06 16:14 ` SF Markus Elfring
2018-02-06 16:16 ` [PATCH 1/3] HID: lenovo: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2018-02-06 16:16 ` SF Markus Elfring
2018-02-06 16:17 ` [PATCH 2/3] HID: lenovo: Improve a size determination in lenovo_probe_tpkbd() SF Markus Elfring
2018-02-06 16:17 ` SF Markus Elfring
2018-02-06 16:19 ` [PATCH 3/3] HID: lenovo: Adjust four checks for null pointers SF Markus Elfring
2018-02-06 16:19 ` SF Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.