* [PATCH 0/4] w1: Adjustments for some function implementations
@ 2017-08-21 20:52 SF Markus Elfring
2017-08-21 20:53 ` [PATCH 1/4] w1: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-21 20:52 UTC (permalink / raw)
To: Andrew F. Davis, Christophe Jaillet, Greg Kroah-Hartman,
Gustavo A. R. Silva, Evgeniy Polyakov, Maciej S. Szmigiero,
Sebastian Reichel, Wei Yongjun
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 22:04:56 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (4):
Delete an error message for a failed memory allocation in two functions
Improve a size determination in two functions
masters: Delete an error message for a failed memory allocation in four functions
masters: Improve a size determination in four functions
drivers/w1/masters/ds2482.c | 3 ++-
drivers/w1/masters/ds2490.c | 7 +++----
drivers/w1/masters/matrox_w1.c | 7 +------
drivers/w1/masters/mxc_w1.c | 3 +--
drivers/w1/masters/omap_hdq.c | 4 +---
drivers/w1/masters/w1-gpio.c | 7 ++-----
drivers/w1/slaves/w1_ds28e04.c | 2 +-
drivers/w1/w1.c | 9 ++-------
drivers/w1/w1_int.c | 6 +-----
9 files changed, 14 insertions(+), 34 deletions(-)
--
2.14.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] w1: Delete an error message for a failed memory allocation in two functions
2017-08-21 20:52 [PATCH 0/4] w1: Adjustments for some function implementations SF Markus Elfring
@ 2017-08-21 20:53 ` SF Markus Elfring
2017-08-21 20:54 ` [PATCH 2/4] w1: Improve a size determination " SF Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-21 20:53 UTC (permalink / raw)
To: Andrew F. Davis, Christophe Jaillet, Greg Kroah-Hartman,
Gustavo A. R. Silva, Evgeniy Polyakov, Maciej S. Szmigiero,
Sebastian Reichel, Wei Yongjun
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 21:05:42 +0200
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/w1/w1.c | 7 +------
drivers/w1/w1_int.c | 6 +-----
2 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 74471e7aa5cc..f26c1ea280dd 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -715,10 +715,5 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
- if (!sl) {
- dev_err(&dev->dev,
- "%s: failed to allocate new slave device.\n",
- __func__);
+ if (!sl)
return -ENOMEM;
- }
-
sl->owner = THIS_MODULE;
sl->master = dev;
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 1c776178f598..9e37463960ed 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -44,9 +44,5 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
- if (!dev) {
- pr_err("Failed to allocate %zd bytes for new w1 device.\n",
- sizeof(struct w1_master));
+ if (!dev)
return NULL;
- }
-
dev->bus_master = (struct w1_bus_master *)(dev + 1);
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] w1: Improve a size determination in two functions
2017-08-21 20:52 [PATCH 0/4] w1: Adjustments for some function implementations SF Markus Elfring
2017-08-21 20:53 ` [PATCH 1/4] w1: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
@ 2017-08-21 20:54 ` SF Markus Elfring
2017-08-21 20:56 ` [PATCH 3/4] w1-masters: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
2017-08-21 20:57 ` [PATCH 4/4] w1-masters: Improve a size determination " SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-21 20:54 UTC (permalink / raw)
To: Andrew F. Davis, Christophe Jaillet, Greg Kroah-Hartman,
Gustavo A. R. Silva, Evgeniy Polyakov, Maciej S. Szmigiero,
Sebastian Reichel, Wei Yongjun
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 21:17:01 +0200
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.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/w1/slaves/w1_ds28e04.c | 2 +-
drivers/w1/w1.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/w1/slaves/w1_ds28e04.c b/drivers/w1/slaves/w1_ds28e04.c
index ec234b846eb3..794db5e8f46f 100644
--- a/drivers/w1/slaves/w1_ds28e04.c
+++ b/drivers/w1/slaves/w1_ds28e04.c
@@ -397,5 +397,5 @@ static int w1_f1C_add_slave(struct w1_slave *sl)
struct w1_f1C_data *data = NULL;
if (w1_enable_crccheck) {
- data = kzalloc(sizeof(struct w1_f1C_data), GFP_KERNEL);
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data)
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index f26c1ea280dd..9f71dc7aca3a 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -711,5 +711,5 @@ int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn)
int err;
struct w1_netlink_msg msg;
- sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL);
+ sl = kzalloc(sizeof(*sl), GFP_KERNEL);
if (!sl)
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] w1-masters: Delete an error message for a failed memory allocation in four functions
2017-08-21 20:52 [PATCH 0/4] w1: Adjustments for some function implementations SF Markus Elfring
2017-08-21 20:53 ` [PATCH 1/4] w1: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-08-21 20:54 ` [PATCH 2/4] w1: Improve a size determination " SF Markus Elfring
@ 2017-08-21 20:56 ` SF Markus Elfring
2017-08-21 20:57 ` [PATCH 4/4] w1-masters: Improve a size determination " SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-21 20:56 UTC (permalink / raw)
To: Andrew F. Davis, Christophe Jaillet, Greg Kroah-Hartman,
Gustavo A. R. Silva, Evgeniy Polyakov, Maciej S. Szmigiero,
Sebastian Reichel, Wei Yongjun
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 21:40:29 +0200
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/w1/masters/ds2490.c | 5 ++---
drivers/w1/masters/matrox_w1.c | 7 +------
drivers/w1/masters/omap_hdq.c | 4 +---
drivers/w1/masters/w1-gpio.c | 4 +---
4 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 46ccb2fc4f60..c0ee6ca9ce93 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -998,7 +998,6 @@ static int ds_probe(struct usb_interface *intf,
- if (!dev) {
- pr_info("Failed to allocate new DS9490R structure.\n");
+ if (!dev)
return -ENOMEM;
- }
+
dev->udev = usb_get_dev(udev);
if (!dev->udev) {
err = -ENOMEM;
diff --git a/drivers/w1/masters/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index d83d7c99d81d..62be2f9cdb4e 100644
--- a/drivers/w1/masters/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -140,10 +140,5 @@ static int matrox_w1_probe(struct pci_dev *pdev, const struct pci_device_id *ent
- if (!dev) {
- dev_err(&pdev->dev,
- "%s: Failed to create new matrox_device object.\n",
- __func__);
+ if (!dev)
return -ENOMEM;
- }
-
dev->bus_master = (struct w1_bus_master *)(dev + 1);
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index 83fc9aab34e8..6349fcd650dc 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -669,7 +669,5 @@ static int omap_hdq_probe(struct platform_device *pdev)
- if (!hdq_data) {
- dev_dbg(&pdev->dev, "unable to allocate memory\n");
+ if (!hdq_data)
return -ENOMEM;
- }
hdq_data->dev = dev;
platform_set_drvdata(pdev, hdq_data);
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index a90728ceec5a..6e8b18bf9fb1 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -133,7 +133,5 @@ static int w1_gpio_probe(struct platform_device *pdev)
- if (!master) {
- dev_err(&pdev->dev, "Out of memory\n");
+ if (!master)
return -ENOMEM;
- }
err = devm_gpio_request(&pdev->dev, pdata->pin, "w1");
if (err) {
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] w1-masters: Improve a size determination in four functions
2017-08-21 20:52 [PATCH 0/4] w1: Adjustments for some function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-08-21 20:56 ` [PATCH 3/4] w1-masters: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
@ 2017-08-21 20:57 ` SF Markus Elfring
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-08-21 20:57 UTC (permalink / raw)
To: Andrew F. Davis, Christophe Jaillet, Greg Kroah-Hartman,
Gustavo A. R. Silva, Evgeniy Polyakov, Maciej S. Szmigiero,
Sebastian Reichel, Wei Yongjun
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Aug 2017 21:53:21 +0200
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.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/w1/masters/ds2482.c | 3 ++-
drivers/w1/masters/ds2490.c | 2 +-
drivers/w1/masters/mxc_w1.c | 3 +--
drivers/w1/masters/w1-gpio.c | 3 +--
4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
index d49681cd29af..7c3e25108285 100644
--- a/drivers/w1/masters/ds2482.c
+++ b/drivers/w1/masters/ds2482.c
@@ -451,7 +451,8 @@ static int ds2482_probe(struct i2c_client *client,
I2C_FUNC_SMBUS_BYTE))
return -ENODEV;
- if (!(data = kzalloc(sizeof(struct ds2482_data), GFP_KERNEL))) {
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data) {
err = -ENOMEM;
goto exit;
}
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index c0ee6ca9ce93..1e5b81490ffe 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -994,5 +994,5 @@ static int ds_probe(struct usb_interface *intf,
struct ds_device *dev;
int i, err, alt;
- dev = kzalloc(sizeof(struct ds_device), GFP_KERNEL);
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
index 74f2e6e6202a..40a34942d07f 100644
--- a/drivers/w1/masters/mxc_w1.c
+++ b/drivers/w1/masters/mxc_w1.c
@@ -103,6 +103,5 @@ static int mxc_w1_probe(struct platform_device *pdev)
unsigned int clkdiv;
int err;
- mdev = devm_kzalloc(&pdev->dev, sizeof(struct mxc_w1_device),
- GFP_KERNEL);
+ mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
if (!mdev)
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index 6e8b18bf9fb1..a92eb1407f0f 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -128,6 +128,5 @@ static int w1_gpio_probe(struct platform_device *pdev)
return -ENXIO;
}
- master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master),
- GFP_KERNEL);
+ master = devm_kzalloc(&pdev->dev, sizeof(*master), GFP_KERNEL);
if (!master)
--
2.14.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-21 20:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 20:52 [PATCH 0/4] w1: Adjustments for some function implementations SF Markus Elfring
2017-08-21 20:53 ` [PATCH 1/4] w1: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-08-21 20:54 ` [PATCH 2/4] w1: Improve a size determination " SF Markus Elfring
2017-08-21 20:56 ` [PATCH 3/4] w1-masters: Delete an error message for a failed memory allocation in four functions SF Markus Elfring
2017-08-21 20:57 ` [PATCH 4/4] w1-masters: Improve a size determination " SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox