All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/18] HID: Fine-tuning for several function implementations
@ 2017-02-07 19:36 ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:36 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:26:54 +0100

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (18):
  Use kmalloc_array() in hid_input_field()
  Delete an error message for a failed memory allocation in open_collection()
  Use kmalloc_array() in open_collection()
  Improve another size determination in open_collection()
  Improve two size determinations in hid_open_report()
  Improve another size determination in hid_scan_report()
  Improve another size determination in hid_register_report()
  Adjust five checks for null pointers
  Return an error code only as a constant in hid_allocate_device()
  debug: Replace five seq_printf() calls by seq_putc()
  debug: Delete an unnecessary seq_printf() call in hid_dump_device()
  debug: Replace 12 seq_printf() calls by seq_puts()
  debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
  debug: Adjust two function calls together with a variable assignment
  debug: Return an error code only as a constant in hid_debug_events_open()
  debug: Add some spaces for better code readability
  debug: Delete an unnecessary variable initialisation in hid_resolv_usage()
  Use seq_puts() in picolcd_debug_reset_show()

 drivers/hid/hid-core.c            |  39 ++++++-------
 drivers/hid/hid-debug.c           | 115 +++++++++++++++++++-------------------
 drivers/hid/hid-picolcd_debugfs.c |   6 +-
 3 files changed, 78 insertions(+), 82 deletions(-)

-- 
2.11.1

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 00/18] HID: Fine-tuning for several function implementations
@ 2017-02-07 19:36 ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:36 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:26:54 +0100

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (18):
  Use kmalloc_array() in hid_input_field()
  Delete an error message for a failed memory allocation in open_collection()
  Use kmalloc_array() in open_collection()
  Improve another size determination in open_collection()
  Improve two size determinations in hid_open_report()
  Improve another size determination in hid_scan_report()
  Improve another size determination in hid_register_report()
  Adjust five checks for null pointers
  Return an error code only as a constant in hid_allocate_device()
  debug: Replace five seq_printf() calls by seq_putc()
  debug: Delete an unnecessary seq_printf() call in hid_dump_device()
  debug: Replace 12 seq_printf() calls by seq_puts()
  debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
  debug: Adjust two function calls together with a variable assignment
  debug: Return an error code only as a constant in hid_debug_events_open()
  debug: Add some spaces for better code readability
  debug: Delete an unnecessary variable initialisation in hid_resolv_usage()
  Use seq_puts() in picolcd_debug_reset_show()

 drivers/hid/hid-core.c            |  39 ++++++-------
 drivers/hid/hid-debug.c           | 115 +++++++++++++++++++-------------------
 drivers/hid/hid-picolcd_debugfs.c |   6 +-
 3 files changed, 78 insertions(+), 82 deletions(-)

-- 
2.11.1


^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 01/18] HID: Use kmalloc_array() in hid_input_field()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:39   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:39 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 18:18:41 +0100

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 538ff697a4cf..9b0a97bbde96 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1272,7 +1272,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
 	__s32 max = field->logical_maximum;
 	__s32 *value;
 
-	value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
+	value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
 	if (!value)
 		return;
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 01/18] HID: Use kmalloc_array() in hid_input_field()
@ 2017-02-07 19:39   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:39 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 18:18:41 +0100

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 538ff697a4cf..9b0a97bbde96 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1272,7 +1272,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
 	__s32 max = field->logical_maximum;
 	__s32 *value;
 
-	value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
+	value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
 	if (!value)
 		return;
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 02/18] HID: Delete an error message for a failed memory allocation in open_collection()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:40   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:40 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 18:42:26 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus fix the affected source code place.

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

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9b0a97bbde96..ffb7e5d4ee19 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -133,10 +133,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 	if (parser->device->maxcollection == parser->device->collection_size) {
 		collection = kmalloc(sizeof(struct hid_collection) *
 				parser->device->collection_size * 2, GFP_KERNEL);
-		if (collection == NULL) {
-			hid_err(parser->device, "failed to reallocate collection array\n");
+		if (!collection)
 			return -ENOMEM;
-		}
+
 		memcpy(collection, parser->device->collection,
 			sizeof(struct hid_collection) *
 			parser->device->collection_size);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 02/18] HID: Delete an error message for a failed memory allocation in open_collection()
@ 2017-02-07 19:40   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:40 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 18:42:26 +0100

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus fix the affected source code place.

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

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9b0a97bbde96..ffb7e5d4ee19 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -133,10 +133,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 	if (parser->device->maxcollection = parser->device->collection_size) {
 		collection = kmalloc(sizeof(struct hid_collection) *
 				parser->device->collection_size * 2, GFP_KERNEL);
-		if (collection = NULL) {
-			hid_err(parser->device, "failed to reallocate collection array\n");
+		if (!collection)
 			return -ENOMEM;
-		}
+
 		memcpy(collection, parser->device->collection,
 			sizeof(struct hid_collection) *
 			parser->device->collection_size);
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 03/18] HID: Use kmalloc_array() in open_collection()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:42   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:42 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 19:09:42 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  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/hid/hid-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ffb7e5d4ee19..51f3547ca44f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -131,8 +131,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 	}
 
 	if (parser->device->maxcollection == parser->device->collection_size) {
-		collection = kmalloc(sizeof(struct hid_collection) *
-				parser->device->collection_size * 2, GFP_KERNEL);
+		collection = kmalloc_array(parser->device->collection_size * 2,
+					   sizeof(*collection),
+					   GFP_KERNEL);
 		if (!collection)
 			return -ENOMEM;
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 03/18] HID: Use kmalloc_array() in open_collection()
@ 2017-02-07 19:42   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:42 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 19:09:42 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  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/hid/hid-core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ffb7e5d4ee19..51f3547ca44f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -131,8 +131,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 	}
 
 	if (parser->device->maxcollection = parser->device->collection_size) {
-		collection = kmalloc(sizeof(struct hid_collection) *
-				parser->device->collection_size * 2, GFP_KERNEL);
+		collection = kmalloc_array(parser->device->collection_size * 2,
+					   sizeof(*collection),
+					   GFP_KERNEL);
 		if (!collection)
 			return -ENOMEM;
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 04/18] HID: Improve another size determination in open_collection()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:43   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:43 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 19:19:22 +0100

Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" 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/hid/hid-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 51f3547ca44f..404eccd0d670 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -138,11 +138,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 			return -ENOMEM;
 
 		memcpy(collection, parser->device->collection,
-			sizeof(struct hid_collection) *
-			parser->device->collection_size);
+		       sizeof(*collection) * parser->device->collection_size);
 		memset(collection + parser->device->collection_size, 0,
-			sizeof(struct hid_collection) *
-			parser->device->collection_size);
+		       sizeof(*collection) * parser->device->collection_size);
 		kfree(parser->device->collection);
 		parser->device->collection = collection;
 		parser->device->collection_size *= 2;
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 04/18] HID: Improve another size determination in open_collection()
@ 2017-02-07 19:43   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:43 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 19:19:22 +0100

Replace the specification of a data structure by pointer dereferences
as the parameter for the operator "sizeof" 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/hid/hid-core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 51f3547ca44f..404eccd0d670 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -138,11 +138,9 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 			return -ENOMEM;
 
 		memcpy(collection, parser->device->collection,
-			sizeof(struct hid_collection) *
-			parser->device->collection_size);
+		       sizeof(*collection) * parser->device->collection_size);
 		memset(collection + parser->device->collection_size, 0,
-			sizeof(struct hid_collection) *
-			parser->device->collection_size);
+		       sizeof(*collection) * parser->device->collection_size);
 		kfree(parser->device->collection);
 		parser->device->collection = collection;
 		parser->device->collection_size *= 2;
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 05/18] HID: Improve two size determinations in hid_open_report()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:46   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:46 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 22:00:07 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" 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/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 404eccd0d670..16c73bf49d55 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -975,7 +975,7 @@ int hid_open_report(struct hid_device *device)
 	device->rdesc = start;
 	device->rsize = size;
 
-	parser = vzalloc(sizeof(struct hid_parser));
+	parser = vzalloc(sizeof(*parser));
 	if (!parser) {
 		ret = -ENOMEM;
 		goto err;
@@ -986,7 +986,7 @@ int hid_open_report(struct hid_device *device)
 	end = start + size;
 
 	device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
-				     sizeof(struct hid_collection), GFP_KERNEL);
+				     sizeof(*device->collection), GFP_KERNEL);
 	if (!device->collection) {
 		ret = -ENOMEM;
 		goto err;
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 05/18] HID: Improve two size determinations in hid_open_report()
@ 2017-02-07 19:46   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:46 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 6 Feb 2017 22:00:07 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" 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/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 404eccd0d670..16c73bf49d55 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -975,7 +975,7 @@ int hid_open_report(struct hid_device *device)
 	device->rdesc = start;
 	device->rsize = size;
 
-	parser = vzalloc(sizeof(struct hid_parser));
+	parser = vzalloc(sizeof(*parser));
 	if (!parser) {
 		ret = -ENOMEM;
 		goto err;
@@ -986,7 +986,7 @@ int hid_open_report(struct hid_device *device)
 	end = start + size;
 
 	device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS,
-				     sizeof(struct hid_collection), GFP_KERNEL);
+				     sizeof(*device->collection), GFP_KERNEL);
 	if (!device->collection) {
 		ret = -ENOMEM;
 		goto err;
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 06/18] HID: Improve another size determination in hid_scan_report()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:48   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:48 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:10:53 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 16c73bf49d55..b943b2ebadc1 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -787,7 +787,7 @@ static int hid_scan_report(struct hid_device *hid)
 		hid_parser_reserved
 	};
 
-	parser = vzalloc(sizeof(struct hid_parser));
+	parser = vzalloc(sizeof(*parser));
 	if (!parser)
 		return -ENOMEM;
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 06/18] HID: Improve another size determination in hid_scan_report()
@ 2017-02-07 19:48   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:48 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:10:53 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 16c73bf49d55..b943b2ebadc1 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -787,7 +787,7 @@ static int hid_scan_report(struct hid_device *hid)
 		hid_parser_reserved
 	};
 
-	parser = vzalloc(sizeof(struct hid_parser));
+	parser = vzalloc(sizeof(*parser));
 	if (!parser)
 		return -ENOMEM;
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 07/18] HID: Improve another size determination in hid_register_report()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:49   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:49 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:12:56 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index b943b2ebadc1..1f75c1c022f0 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -67,7 +67,7 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
 	if (report_enum->report_id_hash[id])
 		return report_enum->report_id_hash[id];
 
-	report = kzalloc(sizeof(struct hid_report), GFP_KERNEL);
+	report = kzalloc(sizeof(*report), GFP_KERNEL);
 	if (!report)
 		return NULL;
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 07/18] HID: Improve another size determination in hid_register_report()
@ 2017-02-07 19:49   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:49 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:12:56 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index b943b2ebadc1..1f75c1c022f0 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -67,7 +67,7 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type,
 	if (report_enum->report_id_hash[id])
 		return report_enum->report_id_hash[id];
 
-	report = kzalloc(sizeof(struct hid_report), GFP_KERNEL);
+	report = kzalloc(sizeof(*report), GFP_KERNEL);
 	if (!report)
 		return NULL;
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 08/18] HID: Adjust five checks for null pointers
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:50   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:50 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

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 --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);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 08/18] HID: Adjust five checks for null pointers
@ 2017-02-07 19:50   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:50 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

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 --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);
-- 
2.11.1

--
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 related	[flat|nested] 40+ messages in thread

* [PATCH 09/18] HID: Return an error code only as a constant in hid_allocate_device()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:51   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:51 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:17:36 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f4ea3590954c..a5db000ed1c4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2716,11 +2716,10 @@ EXPORT_SYMBOL_GPL(hid_add_device);
 struct hid_device *hid_allocate_device(void)
 {
 	struct hid_device *hdev;
-	int ret = -ENOMEM;
 
 	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
 	if (!hdev)
-		return ERR_PTR(ret);
+		return ERR_PTR(-ENOMEM);
 
 	device_initialize(&hdev->dev);
 	hdev->dev.release = hid_device_release;
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 09/18] HID: Return an error code only as a constant in hid_allocate_device()
@ 2017-02-07 19:51   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:51 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:17:36 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f4ea3590954c..a5db000ed1c4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2716,11 +2716,10 @@ EXPORT_SYMBOL_GPL(hid_add_device);
 struct hid_device *hid_allocate_device(void)
 {
 	struct hid_device *hdev;
-	int ret = -ENOMEM;
 
 	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
 	if (!hdev)
-		return ERR_PTR(ret);
+		return ERR_PTR(-ENOMEM);
 
 	device_initialize(&hdev->dev);
 	hdev->dev.release = hid_device_release;
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 10/18] HID-debug: Replace five seq_printf() calls by seq_putc()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:52   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:52 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:21:17 +0100

Single characters should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

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

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index acfb522a432a..383a4a838351 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -497,7 +497,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 		len++;
 	}
 	else {
-		seq_printf(f, ".");
+		seq_putc(f, '.');
 	}
 	for (p = hid_usage_table; p->description; p++)
 		if (p->page == (usage >> 16)) {
@@ -548,7 +548,9 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 	}
 	tab(n, f); seq_printf(f, "Usage(%d)\n", field->maxusage);
 	for (j = 0; j < field->maxusage; j++) {
-		tab(n+2, f); hid_resolv_usage(field->usage[j].hid, f); seq_printf(f, "\n");
+		tab(n + 2, f);
+		hid_resolv_usage(field->usage[j].hid, f);
+		seq_putc(f, '\n');
 	}
 	if (field->logical_minimum != field->logical_maximum) {
 		tab(n, f); seq_printf(f, "Logical Minimum(%d)\n", field->logical_minimum);
@@ -592,7 +594,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 				data >>= 4;
 				if (nibble != 0) {
 					if(earlier_unit++ > 0)
-						seq_printf(f, "*");
+						seq_putc(f, '*');
 					seq_printf(f, "%s", units[sys][i]);
 					if(nibble != 1) {
 						/* This is a _signed_ nibble(!) */
@@ -1037,7 +1039,7 @@ static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
 					hid_resolv_usage(usage->hid, f);
 					seq_printf(f, " ---> ");
 					hid_resolv_event(usage->type, usage->code, f);
-					seq_printf(f, "\n");
+					seq_putc(f, '\n');
 				}
 			}
 		}
@@ -1064,7 +1066,7 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p)
 
 	/* dump parsed data and input mappings */
 	hid_dump_device(hdev, f);
-	seq_printf(f, "\n");
+	seq_putc(f, '\n');
 	hid_dump_input_mapping(hdev, f);
 
 	return 0;
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 10/18] HID-debug: Replace five seq_printf() calls by seq_putc()
@ 2017-02-07 19:52   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:52 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:21:17 +0100

Single characters should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

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

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index acfb522a432a..383a4a838351 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -497,7 +497,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 		len++;
 	}
 	else {
-		seq_printf(f, ".");
+		seq_putc(f, '.');
 	}
 	for (p = hid_usage_table; p->description; p++)
 		if (p->page = (usage >> 16)) {
@@ -548,7 +548,9 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 	}
 	tab(n, f); seq_printf(f, "Usage(%d)\n", field->maxusage);
 	for (j = 0; j < field->maxusage; j++) {
-		tab(n+2, f); hid_resolv_usage(field->usage[j].hid, f); seq_printf(f, "\n");
+		tab(n + 2, f);
+		hid_resolv_usage(field->usage[j].hid, f);
+		seq_putc(f, '\n');
 	}
 	if (field->logical_minimum != field->logical_maximum) {
 		tab(n, f); seq_printf(f, "Logical Minimum(%d)\n", field->logical_minimum);
@@ -592,7 +594,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 				data >>= 4;
 				if (nibble != 0) {
 					if(earlier_unit++ > 0)
-						seq_printf(f, "*");
+						seq_putc(f, '*');
 					seq_printf(f, "%s", units[sys][i]);
 					if(nibble != 1) {
 						/* This is a _signed_ nibble(!) */
@@ -1037,7 +1039,7 @@ static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
 					hid_resolv_usage(usage->hid, f);
 					seq_printf(f, " ---> ");
 					hid_resolv_event(usage->type, usage->code, f);
-					seq_printf(f, "\n");
+					seq_putc(f, '\n');
 				}
 			}
 		}
@@ -1064,7 +1066,7 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p)
 
 	/* dump parsed data and input mappings */
 	hid_dump_device(hdev, f);
-	seq_printf(f, "\n");
+	seq_putc(f, '\n');
 	hid_dump_input_mapping(hdev, f);
 
 	return 0;
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 11/18] HID-debug: Delete an unnecessary seq_printf() call in hid_dump_device()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:54   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:54 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:23:03 +0100

An information should be put into a sequence together with a line break.
Pass the desired data in a single function call instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 383a4a838351..8d019d0db4f3 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -645,8 +645,7 @@ void hid_dump_device(struct hid_device *device, struct seq_file *f)
 			seq_printf(f, "%s", table[i]);
 			if (report->id)
 				seq_printf(f, "(%d)", report->id);
-			seq_printf(f, "[%s]", table[report->type]);
-			seq_printf(f, "\n");
+			seq_printf(f, "[%s]\n", table[report->type]);
 			for (k = 0; k < report->maxfield; k++) {
 				tab(4, f);
 				seq_printf(f, "Field(%d)\n", k);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 11/18] HID-debug: Delete an unnecessary seq_printf() call in hid_dump_device()
@ 2017-02-07 19:54   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:54 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 19:23:03 +0100

An information should be put into a sequence together with a line break.
Pass the desired data in a single function call instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 383a4a838351..8d019d0db4f3 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -645,8 +645,7 @@ void hid_dump_device(struct hid_device *device, struct seq_file *f)
 			seq_printf(f, "%s", table[i]);
 			if (report->id)
 				seq_printf(f, "(%d)", report->id);
-			seq_printf(f, "[%s]", table[report->type]);
-			seq_printf(f, "\n");
+			seq_printf(f, "[%s]\n", table[report->type]);
 			for (k = 0; k < report->maxfield; k++) {
 				tab(4, f);
 				seq_printf(f, "Field(%d)\n", k);
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 12/18] HID-debug: Replace 12 seq_printf() calls by seq_puts()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:55   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:55 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:02:45 +0100

Strings which did not contain data format specifications should be put into
a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 8d019d0db4f3..2ce809eb4c97 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -508,9 +508,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 							max(0,HID_DEBUG_BUFSIZE - len - 1),
 							"%s", p->description);
 					else
-						seq_printf(f,
-							"%s",
-							p->description);
+						seq_puts(f, p->description);
 					return buf;
 				}
 			break;
@@ -533,18 +531,21 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 
 	if (field->physical) {
 		tab(n, f);
-		seq_printf(f, "Physical(");
-		hid_resolv_usage(field->physical, f); seq_printf(f, ")\n");
+		seq_puts(f, "Physical(");
+		hid_resolv_usage(field->physical, f);
+		seq_puts(f, ")\n");
 	}
 	if (field->logical) {
 		tab(n, f);
-		seq_printf(f, "Logical(");
-		hid_resolv_usage(field->logical, f); seq_printf(f, ")\n");
+		seq_puts(f, "Logical(");
+		hid_resolv_usage(field->logical, f);
+		seq_puts(f, ")\n");
 	}
 	if (field->application) {
 		tab(n, f);
-		seq_printf(f, "Application(");
-		hid_resolv_usage(field->application, f); seq_printf(f, ")\n");
+		seq_puts(f, "Application(");
+		hid_resolv_usage(field->application, f);
+		seq_puts(f, ")\n");
 	}
 	tab(n, f); seq_printf(f, "Usage(%d)\n", field->maxusage);
 	for (j = 0; j < field->maxusage; j++) {
@@ -582,7 +583,8 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 		data >>= 4;
 
 		if(sys > 4) {
-			tab(n, f); seq_printf(f, "Unit(Invalid)\n");
+			tab(n, f);
+			seq_puts(f, "Unit(Invalid)\n");
 		}
 		else {
 			int earlier_unit = 0;
@@ -595,7 +597,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 				if (nibble != 0) {
 					if(earlier_unit++ > 0)
 						seq_putc(f, '*');
-					seq_printf(f, "%s", units[sys][i]);
+					seq_puts(f, units[sys][i]);
 					if(nibble != 1) {
 						/* This is a _signed_ nibble(!) */
 
@@ -606,7 +608,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 					}
 				}
 			}
-			seq_printf(f, ")\n");
+			seq_puts(f, ")\n");
 		}
 	}
 	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
@@ -1036,7 +1038,7 @@ static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
 				for ( j = 0; j < report->field[i]->maxusage; j++) {
 					usage = report->field[i]->usage + j;
 					hid_resolv_usage(usage->hid, f);
-					seq_printf(f, " ---> ");
+					seq_puts(f, " ---> ");
 					hid_resolv_event(usage->type, usage->code, f);
 					seq_putc(f, '\n');
 				}
@@ -1061,7 +1063,7 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p)
 	/* dump HID report descriptor */
 	for (i = 0; i < rsize; i++)
 		seq_printf(f, "%02x ", rdesc[i]);
-	seq_printf(f, "\n\n");
+	seq_puts(f, "\n\n");
 
 	/* dump parsed data and input mappings */
 	hid_dump_device(hdev, f);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 12/18] HID-debug: Replace 12 seq_printf() calls by seq_puts()
@ 2017-02-07 19:55   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:55 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:02:45 +0100

Strings which did not contain data format specifications should be put into
a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 8d019d0db4f3..2ce809eb4c97 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -508,9 +508,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 							max(0,HID_DEBUG_BUFSIZE - len - 1),
 							"%s", p->description);
 					else
-						seq_printf(f,
-							"%s",
-							p->description);
+						seq_puts(f, p->description);
 					return buf;
 				}
 			break;
@@ -533,18 +531,21 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 
 	if (field->physical) {
 		tab(n, f);
-		seq_printf(f, "Physical(");
-		hid_resolv_usage(field->physical, f); seq_printf(f, ")\n");
+		seq_puts(f, "Physical(");
+		hid_resolv_usage(field->physical, f);
+		seq_puts(f, ")\n");
 	}
 	if (field->logical) {
 		tab(n, f);
-		seq_printf(f, "Logical(");
-		hid_resolv_usage(field->logical, f); seq_printf(f, ")\n");
+		seq_puts(f, "Logical(");
+		hid_resolv_usage(field->logical, f);
+		seq_puts(f, ")\n");
 	}
 	if (field->application) {
 		tab(n, f);
-		seq_printf(f, "Application(");
-		hid_resolv_usage(field->application, f); seq_printf(f, ")\n");
+		seq_puts(f, "Application(");
+		hid_resolv_usage(field->application, f);
+		seq_puts(f, ")\n");
 	}
 	tab(n, f); seq_printf(f, "Usage(%d)\n", field->maxusage);
 	for (j = 0; j < field->maxusage; j++) {
@@ -582,7 +583,8 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 		data >>= 4;
 
 		if(sys > 4) {
-			tab(n, f); seq_printf(f, "Unit(Invalid)\n");
+			tab(n, f);
+			seq_puts(f, "Unit(Invalid)\n");
 		}
 		else {
 			int earlier_unit = 0;
@@ -595,7 +597,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 				if (nibble != 0) {
 					if(earlier_unit++ > 0)
 						seq_putc(f, '*');
-					seq_printf(f, "%s", units[sys][i]);
+					seq_puts(f, units[sys][i]);
 					if(nibble != 1) {
 						/* This is a _signed_ nibble(!) */
 
@@ -606,7 +608,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 					}
 				}
 			}
-			seq_printf(f, ")\n");
+			seq_puts(f, ")\n");
 		}
 	}
 	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
@@ -1036,7 +1038,7 @@ static void hid_dump_input_mapping(struct hid_device *hid, struct seq_file *f)
 				for ( j = 0; j < report->field[i]->maxusage; j++) {
 					usage = report->field[i]->usage + j;
 					hid_resolv_usage(usage->hid, f);
-					seq_printf(f, " ---> ");
+					seq_puts(f, " ---> ");
 					hid_resolv_event(usage->type, usage->code, f);
 					seq_putc(f, '\n');
 				}
@@ -1061,7 +1063,7 @@ static int hid_debug_rdesc_show(struct seq_file *f, void *p)
 	/* dump HID report descriptor */
 	for (i = 0; i < rsize; i++)
 		seq_printf(f, "%02x ", rdesc[i]);
-	seq_printf(f, "\n\n");
+	seq_puts(f, "\n\n");
 
 	/* dump parsed data and input mappings */
 	hid_dump_device(hdev, f);
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:56   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:56 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:04:28 +0100

Some data were printed into a sequence by eleven separate function calls.
Print the same data by a single function call instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 2ce809eb4c97..aafa963e8a04 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -614,19 +614,18 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
 	tab(n, f); seq_printf(f, "Report Count(%u)\n", field->report_count);
 	tab(n, f); seq_printf(f, "Report Offset(%u)\n", field->report_offset);
-
-	tab(n, f); seq_printf(f, "Flags( ");
+	tab(n, f);
 	j = field->flags;
-	seq_printf(f, "%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
-	seq_printf(f, "%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
-	seq_printf(f, "%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPreferredState " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
-	seq_printf(f, ")\n");
+	seq_printf(f, "Flags( %s%s%s%s%s%s%s%s%s)\n",
+		   HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "",
+		   HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ",
+		   HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ",
+		   HID_MAIN_ITEM_WRAP & j ? "Wrap " : "",
+		   HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "",
+		   HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPreferredState " : "",
+		   HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "",
+		   HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "",
+		   HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
 }
 EXPORT_SYMBOL_GPL(hid_dump_field);
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
@ 2017-02-07 19:56   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:56 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:04:28 +0100

Some data were printed into a sequence by eleven separate function calls.
Print the same data by a single function call instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 2ce809eb4c97..aafa963e8a04 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -614,19 +614,18 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
 	tab(n, f); seq_printf(f, "Report Count(%u)\n", field->report_count);
 	tab(n, f); seq_printf(f, "Report Offset(%u)\n", field->report_offset);
-
-	tab(n, f); seq_printf(f, "Flags( ");
+	tab(n, f);
 	j = field->flags;
-	seq_printf(f, "%s", HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ");
-	seq_printf(f, "%s", HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ");
-	seq_printf(f, "%s", HID_MAIN_ITEM_WRAP & j ? "Wrap " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPreferredState " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "");
-	seq_printf(f, "%s", HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
-	seq_printf(f, ")\n");
+	seq_printf(f, "Flags( %s%s%s%s%s%s%s%s%s)\n",
+		   HID_MAIN_ITEM_CONSTANT & j ? "Constant " : "",
+		   HID_MAIN_ITEM_VARIABLE & j ? "Variable " : "Array ",
+		   HID_MAIN_ITEM_RELATIVE & j ? "Relative " : "Absolute ",
+		   HID_MAIN_ITEM_WRAP & j ? "Wrap " : "",
+		   HID_MAIN_ITEM_NONLINEAR & j ? "NonLinear " : "",
+		   HID_MAIN_ITEM_NO_PREFERRED & j ? "NoPreferredState " : "",
+		   HID_MAIN_ITEM_NULL_STATE & j ? "NullState " : "",
+		   HID_MAIN_ITEM_VOLATILE & j ? "Volatile " : "",
+		   HID_MAIN_ITEM_BUFFERED_BYTE & j ? "BufferedByte " : "");
 }
 EXPORT_SYMBOL_GPL(hid_dump_field);
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 14/18] HID-debug: Adjust two function calls together with a variable assignment
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:57   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:57 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:06:31 +0100

* The script "checkpatch.pl" pointed information out like the following.

  ERROR: do not use assignment in if condition

  Thus fix the affected source code places.

* Replace the specification of a data structure by a pointer dereference
  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/hid/hid-debug.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index aafa963e8a04..444c63f0e4be 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1083,12 +1083,15 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
 	struct hid_debug_list *list;
 	unsigned long flags;
 
-	if (!(list = kzalloc(sizeof(struct hid_debug_list), GFP_KERNEL))) {
+	list = kzalloc(sizeof(*list), GFP_KERNEL);
+	if (!list) {
 		err = -ENOMEM;
 		goto out;
 	}
 
-	if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
+	list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
+				      GFP_KERNEL);
+	if (!list->hid_debug_buf) {
 		err = -ENOMEM;
 		kfree(list);
 		goto out;
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 14/18] HID-debug: Adjust two function calls together with a variable assignment
@ 2017-02-07 19:57   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:57 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:06:31 +0100

* The script "checkpatch.pl" pointed information out like the following.

  ERROR: do not use assignment in if condition

  Thus fix the affected source code places.

* Replace the specification of a data structure by a pointer dereference
  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/hid/hid-debug.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index aafa963e8a04..444c63f0e4be 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1083,12 +1083,15 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
 	struct hid_debug_list *list;
 	unsigned long flags;
 
-	if (!(list = kzalloc(sizeof(struct hid_debug_list), GFP_KERNEL))) {
+	list = kzalloc(sizeof(*list), GFP_KERNEL);
+	if (!list) {
 		err = -ENOMEM;
 		goto out;
 	}
 
-	if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
+	list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
+				      GFP_KERNEL);
+	if (!list->hid_debug_buf) {
 		err = -ENOMEM;
 		kfree(list);
 		goto out;
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 15/18] HID-debug: Return an error code only as a constant in hid_debug_events_open()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:58   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:58 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:08:04 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "err" and the jump label "out" which became
  unnecessary with this refactoring.

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

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 444c63f0e4be..60984e2906a7 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1079,22 +1079,18 @@ static int hid_debug_rdesc_open(struct inode *inode, struct file *file)
 
 static int hid_debug_events_open(struct inode *inode, struct file *file)
 {
-	int err = 0;
 	struct hid_debug_list *list;
 	unsigned long flags;
 
 	list = kzalloc(sizeof(*list), GFP_KERNEL);
-	if (!list) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!list)
+		return -ENOMEM;
 
 	list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
 				      GFP_KERNEL);
 	if (!list->hid_debug_buf) {
-		err = -ENOMEM;
 		kfree(list);
-		goto out;
+		return -ENOMEM;
 	}
 	list->hdev = (struct hid_device *) inode->i_private;
 	file->private_data = list;
@@ -1103,9 +1099,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
 	spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
 	list_add_tail(&list->node, &list->hdev->debug_list);
 	spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
-
-out:
-	return err;
+	return 0;
 }
 
 static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 15/18] HID-debug: Return an error code only as a constant in hid_debug_events_open()
@ 2017-02-07 19:58   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:58 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:08:04 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the local variable "err" and the jump label "out" which became
  unnecessary with this refactoring.

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

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 444c63f0e4be..60984e2906a7 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -1079,22 +1079,18 @@ static int hid_debug_rdesc_open(struct inode *inode, struct file *file)
 
 static int hid_debug_events_open(struct inode *inode, struct file *file)
 {
-	int err = 0;
 	struct hid_debug_list *list;
 	unsigned long flags;
 
 	list = kzalloc(sizeof(*list), GFP_KERNEL);
-	if (!list) {
-		err = -ENOMEM;
-		goto out;
-	}
+	if (!list)
+		return -ENOMEM;
 
 	list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE,
 				      GFP_KERNEL);
 	if (!list->hid_debug_buf) {
-		err = -ENOMEM;
 		kfree(list);
-		goto out;
+		return -ENOMEM;
 	}
 	list->hdev = (struct hid_device *) inode->i_private;
 	file->private_data = list;
@@ -1103,9 +1099,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
 	spin_lock_irqsave(&list->hdev->debug_list_lock, flags);
 	list_add_tail(&list->node, &list->hdev->debug_list);
 	spin_unlock_irqrestore(&list->hdev->debug_list_lock, flags);
-
-out:
-	return err;
+	return 0;
 }
 
 static ssize_t hid_debug_events_read(struct file *file, char __user *buffer,
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 16/18] HID-debug: Add some spaces for better code readability
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 19:59   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:59 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:10:40 +0100

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 60984e2906a7..044b12e32240 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -493,7 +493,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 
 	if (!f) {
 		len = strlen(buf);
-		snprintf(buf+len, max(0, HID_DEBUG_BUFSIZE - len), ".");
+		snprintf(buf + len, max(0, HID_DEBUG_BUFSIZE - len), ".");
 		len++;
 	}
 	else {
@@ -501,12 +501,14 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 	}
 	for (p = hid_usage_table; p->description; p++)
 		if (p->page == (usage >> 16)) {
-			for(++p; p->description && p->usage != 0; p++)
+			for (++p; p->description && p->usage != 0; p++)
 				if (p->usage == (usage & 0xffff)) {
 					if (!f)
 						snprintf(buf + len,
-							max(0,HID_DEBUG_BUFSIZE - len - 1),
-							"%s", p->description);
+							 max(0,
+							     HID_DEBUG_BUFSIZE
+							     - len - 1),
+							 "%s", p->description);
 					else
 						seq_puts(f, p->description);
 					return buf;
@@ -582,7 +584,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 		sys = data & 0xf;
 		data >>= 4;
 
-		if(sys > 4) {
+		if (sys > 4) {
 			tab(n, f);
 			seq_puts(f, "Unit(Invalid)\n");
 		}
@@ -591,19 +593,19 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 
 			tab(n, f); seq_printf(f, "Unit(%s : ", systems[sys]);
 
-			for (i=1 ; i<sizeof(__u32)*2 ; i++) {
+			for (i = 1; i < sizeof(__u32) * 2; i++) {
 				char nibble = data & 0xf;
 				data >>= 4;
 				if (nibble != 0) {
-					if(earlier_unit++ > 0)
+					if (earlier_unit++ > 0)
 						seq_putc(f, '*');
 					seq_puts(f, units[sys][i]);
-					if(nibble != 1) {
+					if (nibble != 1) {
 						/* This is a _signed_ nibble(!) */
-
 						int val = nibble & 0x7;
-						if(nibble & 0x08)
-							val = -((0x7 & ~val) +1);
+
+						if (nibble & 0x08)
+							val = -((0x7 & ~val) + 1);
 						seq_printf(f, "^%d", val);
 					}
 				}
@@ -634,7 +636,7 @@ void hid_dump_device(struct hid_device *device, struct seq_file *f)
 	struct hid_report_enum *report_enum;
 	struct hid_report *report;
 	struct list_head *list;
-	unsigned i,k;
+	unsigned int i, k;
 	static const char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
 
 	for (i = 0; i < HID_REPORT_TYPES; i++) {
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 16/18] HID-debug: Add some spaces for better code readability
@ 2017-02-07 19:59   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 19:59 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:10:40 +0100

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 60984e2906a7..044b12e32240 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -493,7 +493,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 
 	if (!f) {
 		len = strlen(buf);
-		snprintf(buf+len, max(0, HID_DEBUG_BUFSIZE - len), ".");
+		snprintf(buf + len, max(0, HID_DEBUG_BUFSIZE - len), ".");
 		len++;
 	}
 	else {
@@ -501,12 +501,14 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 	}
 	for (p = hid_usage_table; p->description; p++)
 		if (p->page = (usage >> 16)) {
-			for(++p; p->description && p->usage != 0; p++)
+			for (++p; p->description && p->usage != 0; p++)
 				if (p->usage = (usage & 0xffff)) {
 					if (!f)
 						snprintf(buf + len,
-							max(0,HID_DEBUG_BUFSIZE - len - 1),
-							"%s", p->description);
+							 max(0,
+							     HID_DEBUG_BUFSIZE
+							     - len - 1),
+							 "%s", p->description);
 					else
 						seq_puts(f, p->description);
 					return buf;
@@ -582,7 +584,7 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 		sys = data & 0xf;
 		data >>= 4;
 
-		if(sys > 4) {
+		if (sys > 4) {
 			tab(n, f);
 			seq_puts(f, "Unit(Invalid)\n");
 		}
@@ -591,19 +593,19 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
 
 			tab(n, f); seq_printf(f, "Unit(%s : ", systems[sys]);
 
-			for (i=1 ; i<sizeof(__u32)*2 ; i++) {
+			for (i = 1; i < sizeof(__u32) * 2; i++) {
 				char nibble = data & 0xf;
 				data >>= 4;
 				if (nibble != 0) {
-					if(earlier_unit++ > 0)
+					if (earlier_unit++ > 0)
 						seq_putc(f, '*');
 					seq_puts(f, units[sys][i]);
-					if(nibble != 1) {
+					if (nibble != 1) {
 						/* This is a _signed_ nibble(!) */
-
 						int val = nibble & 0x7;
-						if(nibble & 0x08)
-							val = -((0x7 & ~val) +1);
+
+						if (nibble & 0x08)
+							val = -((0x7 & ~val) + 1);
 						seq_printf(f, "^%d", val);
 					}
 				}
@@ -634,7 +636,7 @@ void hid_dump_device(struct hid_device *device, struct seq_file *f)
 	struct hid_report_enum *report_enum;
 	struct hid_report *report;
 	struct list_head *list;
-	unsigned i,k;
+	unsigned int i, k;
 	static const char *table[] = {"INPUT", "OUTPUT", "FEATURE"};
 
 	for (i = 0; i < HID_REPORT_TYPES; i++) {
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 17/18] HID-debug: Delete an unnecessary variable initialisation in hid_resolv_usage()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 20:00   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 20:00 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:12:09 +0100

The local variable "buf" will be set to an appropriate pointer
by the following statement. Thus omit the explicit initialisation
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 044b12e32240..0d33bf0d47d1 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -481,7 +481,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) {
 
 char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 	const struct hid_usage_entry *p;
-	char *buf = NULL;
+	char *buf;
 	int len = 0;
 
 	buf = resolv_usage_page(usage >> 16, f);
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 17/18] HID-debug: Delete an unnecessary variable initialisation in hid_resolv_usage()
@ 2017-02-07 20:00   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 20:00 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:12:09 +0100

The local variable "buf" will be set to an appropriate pointer
by the following statement. Thus omit the explicit initialisation
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 044b12e32240..0d33bf0d47d1 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -481,7 +481,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) {
 
 char *hid_resolv_usage(unsigned usage, struct seq_file *f) {
 	const struct hid_usage_entry *p;
-	char *buf = NULL;
+	char *buf;
 	int len = 0;
 
 	buf = resolv_usage_page(usage >> 16, f);
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 18/18] HID-picoLCD: Use seq_puts() in picolcd_debug_reset_show()
  2017-02-07 19:36 ` SF Markus Elfring
@ 2017-02-07 20:01   ` SF Markus Elfring
  -1 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 20:01 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:14:16 +0100

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-picolcd_debugfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
index 3c13af684410..ddad570b4d9e 100644
--- a/drivers/hid/hid-picolcd_debugfs.c
+++ b/drivers/hid/hid-picolcd_debugfs.c
@@ -32,10 +32,8 @@
 
 static int picolcd_debug_reset_show(struct seq_file *f, void *p)
 {
-	if (picolcd_fbinfo((struct picolcd_data *)f->private))
-		seq_printf(f, "all fb\n");
-	else
-		seq_printf(f, "all\n");
+	seq_puts(f, picolcd_fbinfo((struct picolcd_data *)f->private)
+		    ? "all fb\n" : "all\n");
 	return 0;
 }
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 18/18] HID-picoLCD: Use seq_puts() in picolcd_debug_reset_show()
@ 2017-02-07 20:01   ` SF Markus Elfring
  0 siblings, 0 replies; 40+ messages in thread
From: SF Markus Elfring @ 2017-02-07 20:01 UTC (permalink / raw)
  To: linux-input, Benjamin Tissoires, Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 7 Feb 2017 20:14:16 +0100

A string which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-picolcd_debugfs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-picolcd_debugfs.c b/drivers/hid/hid-picolcd_debugfs.c
index 3c13af684410..ddad570b4d9e 100644
--- a/drivers/hid/hid-picolcd_debugfs.c
+++ b/drivers/hid/hid-picolcd_debugfs.c
@@ -32,10 +32,8 @@
 
 static int picolcd_debug_reset_show(struct seq_file *f, void *p)
 {
-	if (picolcd_fbinfo((struct picolcd_data *)f->private))
-		seq_printf(f, "all fb\n");
-	else
-		seq_printf(f, "all\n");
+	seq_puts(f, picolcd_fbinfo((struct picolcd_data *)f->private)
+		    ? "all fb\n" : "all\n");
 	return 0;
 }
 
-- 
2.11.1


^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
  2017-02-07 19:56   ` SF Markus Elfring
@ 2017-02-07 22:52     ` Joe Perches
  -1 siblings, 0 replies; 40+ messages in thread
From: Joe Perches @ 2017-02-07 22:52 UTC (permalink / raw)
  To: SF Markus Elfring, linux-input, Benjamin Tissoires,
	Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

On Tue, 2017-02-07 at 20:56 +0100, SF Markus Elfring wrote:
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
[]
> @@ -614,19 +614,18 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
>  	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
>  	tab(n, f); seq_printf(f, "Report Count(%u)\n", field->report_count);
>  	tab(n, f); seq_printf(f, "Report Offset(%u)\n", field->report_offset);
> -
> -	tab(n, f); seq_printf(f, "Flags( ");
> +	tab(n, f);

Consider converting tab(n, f) to seq_indent(f, n)
making seq_indent a global function or maybe using
a new name like seq_spaces, and converting the
existing uses in net/ipv4/fib_trie.c appropriately.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call in hid_dump_field()
@ 2017-02-07 22:52     ` Joe Perches
  0 siblings, 0 replies; 40+ messages in thread
From: Joe Perches @ 2017-02-07 22:52 UTC (permalink / raw)
  To: SF Markus Elfring, linux-input, Benjamin Tissoires,
	Bruno Prémont, Jiri Kosina
  Cc: LKML, kernel-janitors

On Tue, 2017-02-07 at 20:56 +0100, SF Markus Elfring wrote:
> diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
[]
> @@ -614,19 +614,18 @@ void hid_dump_field(struct hid_field *field, int n, struct seq_file *f) {
>  	tab(n, f); seq_printf(f, "Report Size(%u)\n", field->report_size);
>  	tab(n, f); seq_printf(f, "Report Count(%u)\n", field->report_count);
>  	tab(n, f); seq_printf(f, "Report Offset(%u)\n", field->report_offset);
> -
> -	tab(n, f); seq_printf(f, "Flags( ");
> +	tab(n, f);

Consider converting tab(n, f) to seq_indent(f, n)
making seq_indent a global function or maybe using
a new name like seq_spaces, and converting the
existing uses in net/ipv4/fib_trie.c appropriately.


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2017-02-07 22:53 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 19:36 [PATCH 00/18] HID: Fine-tuning for several function implementations SF Markus Elfring
2017-02-07 19:36 ` SF Markus Elfring
2017-02-07 19:39 ` [PATCH 01/18] HID: Use kmalloc_array() in hid_input_field() SF Markus Elfring
2017-02-07 19:39   ` SF Markus Elfring
2017-02-07 19:40 ` [PATCH 02/18] HID: Delete an error message for a failed memory allocation in open_collection() SF Markus Elfring
2017-02-07 19:40   ` SF Markus Elfring
2017-02-07 19:42 ` [PATCH 03/18] HID: Use kmalloc_array() " SF Markus Elfring
2017-02-07 19:42   ` SF Markus Elfring
2017-02-07 19:43 ` [PATCH 04/18] HID: Improve another size determination " SF Markus Elfring
2017-02-07 19:43   ` SF Markus Elfring
2017-02-07 19:46 ` [PATCH 05/18] HID: Improve two size determinations in hid_open_report() SF Markus Elfring
2017-02-07 19:46   ` SF Markus Elfring
2017-02-07 19:48 ` [PATCH 06/18] HID: Improve another size determination in hid_scan_report() SF Markus Elfring
2017-02-07 19:48   ` SF Markus Elfring
2017-02-07 19:49 ` [PATCH 07/18] HID: Improve another size determination in hid_register_report() SF Markus Elfring
2017-02-07 19:49   ` SF Markus Elfring
2017-02-07 19:50 ` [PATCH 08/18] HID: Adjust five checks for null pointers SF Markus Elfring
2017-02-07 19:50   ` SF Markus Elfring
2017-02-07 19:51 ` [PATCH 09/18] HID: Return an error code only as a constant in hid_allocate_device() SF Markus Elfring
2017-02-07 19:51   ` SF Markus Elfring
2017-02-07 19:52 ` [PATCH 10/18] HID-debug: Replace five seq_printf() calls by seq_putc() SF Markus Elfring
2017-02-07 19:52   ` SF Markus Elfring
2017-02-07 19:54 ` [PATCH 11/18] HID-debug: Delete an unnecessary seq_printf() call in hid_dump_device() SF Markus Elfring
2017-02-07 19:54   ` SF Markus Elfring
2017-02-07 19:55 ` [PATCH 12/18] HID-debug: Replace 12 seq_printf() calls by seq_puts() SF Markus Elfring
2017-02-07 19:55   ` SF Markus Elfring
2017-02-07 19:56 ` [PATCH 13/18] HID-debug: Combine 11 seq_printf() calls into one call in hid_dump_field() SF Markus Elfring
2017-02-07 19:56   ` SF Markus Elfring
2017-02-07 22:52   ` Joe Perches
2017-02-07 22:52     ` Joe Perches
2017-02-07 19:57 ` [PATCH 14/18] HID-debug: Adjust two function calls together with a variable assignment SF Markus Elfring
2017-02-07 19:57   ` SF Markus Elfring
2017-02-07 19:58 ` [PATCH 15/18] HID-debug: Return an error code only as a constant in hid_debug_events_open() SF Markus Elfring
2017-02-07 19:58   ` SF Markus Elfring
2017-02-07 19:59 ` [PATCH 16/18] HID-debug: Add some spaces for better code readability SF Markus Elfring
2017-02-07 19:59   ` SF Markus Elfring
2017-02-07 20:00 ` [PATCH 17/18] HID-debug: Delete an unnecessary variable initialisation in hid_resolv_usage() SF Markus Elfring
2017-02-07 20:00   ` SF Markus Elfring
2017-02-07 20:01 ` [PATCH 18/18] HID-picoLCD: Use seq_puts() in picolcd_debug_reset_show() SF Markus Elfring
2017-02-07 20:01   ` 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.