linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] NFC-digital: Adjustments for four function implementations
@ 2017-05-22 12:57 SF Markus Elfring
  2017-05-22 12:58 ` [PATCH 1/2] NFC: digital: Improve a size determination in four functions SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-22 12:57 UTC (permalink / raw)
  To: linux-wireless, netdev, David S. Miller, Samuel Ortiz, Thierry Escande
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:50:05 +0200

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

Markus Elfring (2):
  Improve a size determination in four functions
  Delete an error message for a failed memory allocation in digital_in_send()

 net/nfc/digital_core.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

-- 
2.13.0

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

* [PATCH 1/2] NFC: digital: Improve a size determination in four functions
  2017-05-22 12:57 [PATCH 0/2] NFC-digital: Adjustments for four function implementations SF Markus Elfring
@ 2017-05-22 12:58 ` SF Markus Elfring
  2017-05-22 13:00 ` [PATCH 2/2] NFC: digital: Delete an error message for a failed memory allocation in digital_in_send() SF Markus Elfring
  2017-06-22 22:17 ` [PATCH 0/2] NFC-digital: Adjustments for four function implementations Samuel Ortiz
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-22 12:58 UTC (permalink / raw)
  To: linux-wireless, netdev, David S. Miller, Samuel Ortiz, Thierry Escande
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:11:01 +0200

Replace the specification of four 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>
---
 net/nfc/digital_core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 0fd5518bf252..3baf91f3ef80 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -240,5 +240,5 @@ int digital_send_cmd(struct nfc_digital_dev *ddev, u8 cmd_type,
 {
 	struct digital_cmd *cmd;
 
-	cmd = kzalloc(sizeof(struct digital_cmd), GFP_KERNEL);
+	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
 	if (!cmd)
@@ -287,5 +287,5 @@ static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
 {
 	struct digital_tg_mdaa_params *params;
 
-	params = kzalloc(sizeof(struct digital_tg_mdaa_params), GFP_KERNEL);
+	params = kzalloc(sizeof(*params), GFP_KERNEL);
 	if (!params)
@@ -706,5 +706,5 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
 	struct digital_data_exch *data_exch;
 	int rc;
 
-	data_exch = kzalloc(sizeof(struct digital_data_exch), GFP_KERNEL);
+	data_exch = kzalloc(sizeof(*data_exch), GFP_KERNEL);
 	if (!data_exch) {
@@ -764,5 +764,5 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
 	    !ops->switch_rf || (ops->tg_listen_md && !ops->tg_get_rf_tech))
 		return NULL;
 
-	ddev = kzalloc(sizeof(struct nfc_digital_dev), GFP_KERNEL);
+	ddev = kzalloc(sizeof(*ddev), GFP_KERNEL);
 	if (!ddev)
-- 
2.13.0

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

* [PATCH 2/2] NFC: digital: Delete an error message for a failed memory allocation in digital_in_send()
  2017-05-22 12:57 [PATCH 0/2] NFC-digital: Adjustments for four function implementations SF Markus Elfring
  2017-05-22 12:58 ` [PATCH 1/2] NFC: digital: Improve a size determination in four functions SF Markus Elfring
@ 2017-05-22 13:00 ` SF Markus Elfring
  2017-06-22 22:17 ` [PATCH 0/2] NFC-digital: Adjustments for four function implementations Samuel Ortiz
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-22 13:00 UTC (permalink / raw)
  To: linux-wireless, netdev, David S. Miller, Samuel Ortiz, Thierry Escande
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:24:24 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/nfc/digital_core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 3baf91f3ef80..8e02a3e1b319 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -710,7 +710,5 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
-	if (!data_exch) {
-		pr_err("Failed to allocate data_exch struct\n");
+	if (!data_exch)
 		return -ENOMEM;
-	}
 
 	data_exch->cb = cb;
 	data_exch->cb_context = cb_context;
-- 
2.13.0

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

* Re: [PATCH 0/2] NFC-digital: Adjustments for four function implementations
  2017-05-22 12:57 [PATCH 0/2] NFC-digital: Adjustments for four function implementations SF Markus Elfring
  2017-05-22 12:58 ` [PATCH 1/2] NFC: digital: Improve a size determination in four functions SF Markus Elfring
  2017-05-22 13:00 ` [PATCH 2/2] NFC: digital: Delete an error message for a failed memory allocation in digital_in_send() SF Markus Elfring
@ 2017-06-22 22:17 ` Samuel Ortiz
  2 siblings, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2017-06-22 22:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, David S. Miller, Thierry Escande, LKML,
	kernel-janitors

Hi Markus,

On Mon, May 22, 2017 at 02:57:42PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 May 2017 14:50:05 +0200
> 
> Two update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (2):
>   Improve a size determination in four functions
>   Delete an error message for a failed memory allocation in digital_in_send()
Both patches applied to nfc-next, thanks.

Cheers,
Samuel.

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

end of thread, other threads:[~2017-06-22 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 12:57 [PATCH 0/2] NFC-digital: Adjustments for four function implementations SF Markus Elfring
2017-05-22 12:58 ` [PATCH 1/2] NFC: digital: Improve a size determination in four functions SF Markus Elfring
2017-05-22 13:00 ` [PATCH 2/2] NFC: digital: Delete an error message for a failed memory allocation in digital_in_send() SF Markus Elfring
2017-06-22 22:17 ` [PATCH 0/2] NFC-digital: Adjustments for four function implementations Samuel Ortiz

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).