* [PATCH 0/2] ARM-SAMSUNG: Adjustments for 14 function implementations
@ 2017-10-04 11:10 SF Markus Elfring
2017-10-04 11:11 ` [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-10-04 11:12 ` [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions SF Markus Elfring
0 siblings, 2 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-04 11:10 UTC (permalink / raw)
To: linux-arm-kernel
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 12:48:24 +0200
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete an error message for a failed memory allocation in three functions
Improve a size determination in 13 functions
arch/arm/plat-samsung/adc.c | 12 ++++--------
arch/arm/plat-samsung/devs.c | 33 +++++++++++----------------------
arch/arm/plat-samsung/platformdata.c | 4 +---
3 files changed, 16 insertions(+), 33 deletions(-)
--
2.14.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions
2017-10-04 11:10 [PATCH 0/2] ARM-SAMSUNG: Adjustments for 14 function implementations SF Markus Elfring
@ 2017-10-04 11:11 ` SF Markus Elfring
2017-10-04 19:04 ` Krzysztof Kozlowski
2017-10-04 11:12 ` [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions SF Markus Elfring
1 sibling, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-04 11:11 UTC (permalink / raw)
To: linux-arm-kernel
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 09:33:52 +0200
Omit extra messages 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>
---
arch/arm/plat-samsung/adc.c | 8 ++------
arch/arm/plat-samsung/platformdata.c | 4 +---
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c
index daf3db9f0058..f8d6206e4daa 100644
--- a/arch/arm/plat-samsung/adc.c
+++ b/arch/arm/plat-samsung/adc.c
@@ -239,10 +239,8 @@ struct s3c_adc_client *s3c_adc_register(struct platform_device *pdev,
return ERR_PTR(-EINVAL);
client = kzalloc(sizeof(struct s3c_adc_client), GFP_KERNEL);
- if (!client) {
- dev_err(&pdev->dev, "no memory for adc client\n");
+ if (!client)
return ERR_PTR(-ENOMEM);
- }
client->pdev = pdev;
client->is_ts = is_ts;
@@ -345,10 +343,8 @@ static int s3c_adc_probe(struct platform_device *pdev)
unsigned tmp;
adc = devm_kzalloc(dev, sizeof(struct adc_device), GFP_KERNEL);
- if (adc == NULL) {
- dev_err(dev, "failed to allocate adc_device\n");
+ if (!adc)
return -ENOMEM;
- }
spin_lock_init(&adc->lock);
diff --git a/arch/arm/plat-samsung/platformdata.c b/arch/arm/plat-samsung/platformdata.c
index b430e9946287..6cf52ee7eeec 100644
--- a/arch/arm/plat-samsung/platformdata.c
+++ b/arch/arm/plat-samsung/platformdata.c
@@ -29,10 +29,8 @@ void __init *s3c_set_platdata(void *pd, size_t pdsize,
}
npd = kmemdup(pd, pdsize, GFP_KERNEL);
- if (!npd) {
- printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
+ if (!npd)
return NULL;
- }
pdev->dev.platform_data = npd;
return npd;
--
2.14.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions
2017-10-04 11:10 [PATCH 0/2] ARM-SAMSUNG: Adjustments for 14 function implementations SF Markus Elfring
2017-10-04 11:11 ` [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-10-04 11:12 ` SF Markus Elfring
2017-10-04 19:11 ` Krzysztof Kozlowski
1 sibling, 1 reply; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-04 11:12 UTC (permalink / raw)
To: linux-arm-kernel
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Oct 2017 09:52:33 +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>
---
arch/arm/plat-samsung/adc.c | 4 ++--
arch/arm/plat-samsung/devs.c | 33 +++++++++++----------------------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c
index f8d6206e4daa..e9de9e92ce01 100644
--- a/arch/arm/plat-samsung/adc.c
+++ b/arch/arm/plat-samsung/adc.c
@@ -238,7 +238,7 @@ struct s3c_adc_client *s3c_adc_register(struct platform_device *pdev,
if (!pdev)
return ERR_PTR(-EINVAL);
- client = kzalloc(sizeof(struct s3c_adc_client), GFP_KERNEL);
+ client = kzalloc(sizeof(*client), GFP_KERNEL);
if (!client)
return ERR_PTR(-ENOMEM);
@@ -342,7 +342,7 @@ static int s3c_adc_probe(struct platform_device *pdev)
int ret;
unsigned tmp;
- adc = devm_kzalloc(dev, sizeof(struct adc_device), GFP_KERNEL);
+ adc = devm_kzalloc(dev, sizeof(*adc), GFP_KERNEL);
if (!adc)
return -ENOMEM;
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index dc269d9143bc..5668e4eb03df 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -339,8 +339,7 @@ void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 0;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c0);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c0);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c0_cfg_gpio;
@@ -368,8 +367,7 @@ void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 1;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c1);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c1);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c1_cfg_gpio;
@@ -398,8 +396,7 @@ void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 2;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c2);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c2);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c2_cfg_gpio;
@@ -428,8 +425,7 @@ void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 3;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c3);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c3);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c3_cfg_gpio;
@@ -458,8 +454,7 @@ void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 4;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c4);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c4);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c4_cfg_gpio;
@@ -488,8 +483,7 @@ void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 5;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c5);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c5);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c5_cfg_gpio;
@@ -518,8 +512,7 @@ void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 6;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c6);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c6);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c6_cfg_gpio;
@@ -548,8 +541,7 @@ void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd)
pd->bus_num = 7;
}
- npd = s3c_set_platdata(pd, sizeof(struct s3c2410_platform_i2c),
- &s3c_device_i2c7);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c7);
if (!npd->cfg_gpio)
npd->cfg_gpio = s3c_i2c7_cfg_gpio;
@@ -615,8 +607,7 @@ void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd)
{
struct samsung_keypad_platdata *npd;
- npd = s3c_set_platdata(pd, sizeof(struct samsung_keypad_platdata),
- &samsung_device_keypad);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &samsung_device_keypad);
if (!npd->cfg_gpio)
npd->cfg_gpio = samsung_keypad_cfg_gpio;
@@ -721,8 +712,7 @@ void __init s3c_nand_set_platdata(struct s3c2410_platform_nand *nand)
* time then there is little chance the system is going to run.
*/
- npd = s3c_set_platdata(nand, sizeof(struct s3c2410_platform_nand),
- &s3c_device_nand);
+ npd = s3c_set_platdata(nand, sizeof(*npd), &s3c_device_nand);
if (!npd)
return;
@@ -1022,8 +1012,7 @@ void __init dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat *pd)
{
struct dwc2_hsotg_plat *npd;
- npd = s3c_set_platdata(pd, sizeof(struct dwc2_hsotg_plat),
- &s3c_device_usb_hsotg);
+ npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_usb_hsotg);
if (!npd->phy_init)
npd->phy_init = s5p_usb_phy_init;
--
2.14.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions
2017-10-04 11:11 ` [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
@ 2017-10-04 19:04 ` Krzysztof Kozlowski
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2017-10-04 19:04 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Oct 04, 2017 at 01:11:56PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Oct 2017 09:33:52 +0200
>
> Omit extra messages 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>
> ---
> arch/arm/plat-samsung/adc.c | 8 ++------
> arch/arm/plat-samsung/platformdata.c | 4 +---
> 2 files changed, 3 insertions(+), 9 deletions(-)
>
Thanks, applied.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions
2017-10-04 11:12 ` [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions SF Markus Elfring
@ 2017-10-04 19:11 ` Krzysztof Kozlowski
2017-10-10 9:28 ` SF Markus Elfring
0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2017-10-04 19:11 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Oct 04, 2017 at 01:12:55PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Oct 2017 09:52:33 +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>
> ---
> arch/arm/plat-samsung/adc.c | 4 ++--
> arch/arm/plat-samsung/devs.c | 33 +++++++++++----------------------
> 2 files changed, 13 insertions(+), 24 deletions(-)
>
Thanks, applied.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* ARM: SAMSUNG: Improve a size determination in 13 functions
2017-10-04 19:11 ` Krzysztof Kozlowski
@ 2017-10-10 9:28 ` SF Markus Elfring
0 siblings, 0 replies; 6+ messages in thread
From: SF Markus Elfring @ 2017-10-10 9:28 UTC (permalink / raw)
To: linux-arm-kernel
> Thanks, applied.
Is the chosen commit description ?Simplify the size argument of kzalloc() memory allocation
by using ?? really appropriate when calls were adjusted for further two function names
by this update suggestion?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=09e1cf829c45a2f030c7fd49533a86b0935d068a
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-10 9:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-04 11:10 [PATCH 0/2] ARM-SAMSUNG: Adjustments for 14 function implementations SF Markus Elfring
2017-10-04 11:11 ` [PATCH 1/2] ARM: SAMSUNG: Delete an error message for a failed memory allocation in three functions SF Markus Elfring
2017-10-04 19:04 ` Krzysztof Kozlowski
2017-10-04 11:12 ` [PATCH 2/2] ARM: SAMSUNG: Improve a size determination in 13 functions SF Markus Elfring
2017-10-04 19:11 ` Krzysztof Kozlowski
2017-10-10 9:28 ` 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;
as well as URLs for NNTP newsgroup(s).