[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220818210054.7157-1-wsa+renesas@sang-engineering.com>
Date: Thu, 18 Aug 2022 23:00:53 +0200
From: Wolfram Sang <wsa+renesas@...g-engineering.com>
To: linux-kernel@...r.kernel.org
Cc: Wolfram Sang <wsa+renesas@...g-engineering.com>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
devicetree@...r.kernel.org
Subject: [PATCH] of: move from strlcpy with unused retval to strscpy
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.
Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@...g-engineering.com>
---
drivers/of/base.c | 2 +-
drivers/of/fdt.c | 6 +++---
drivers/of/unittest.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7fa960bd3df1..99cee6b02297 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1228,7 +1228,7 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
if (!compatible || strlen(compatible) > cplen)
return -ENODEV;
p = strchr(compatible, ',');
- strlcpy(modalias, p ? p + 1 : compatible, len);
+ strscpy(modalias, p ? p + 1 : compatible, len);
return 0;
}
EXPORT_SYMBOL_GPL(of_modalias_node);
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7bc92923104c..1617a31ecd22 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1178,7 +1178,7 @@ int __init early_init_dt_scan_chosen(char *cmdline)
/* Retrieve command line */
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0)
- strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
+ strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
/*
* CONFIG_CMDLINE is meant to be a default in case nothing else
@@ -1190,11 +1190,11 @@ int __init early_init_dt_scan_chosen(char *cmdline)
strlcat(cmdline, " ", COMMAND_LINE_SIZE);
strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#elif defined(CONFIG_CMDLINE_FORCE)
- strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+ strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#else
/* No arguments from boot loader, use kernel's cmdl*/
if (!((char *)cmdline)[0])
- strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+ strscpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#endif
#endif /* CONFIG_CMDLINE */
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index eafa8ffefbd0..6fa14b77086a 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -2465,7 +2465,7 @@ static int unittest_i2c_bus_probe(struct platform_device *pdev)
adap = &std->adap;
i2c_set_adapdata(adap, std);
adap->nr = -1;
- strlcpy(adap->name, pdev->name, sizeof(adap->name));
+ strscpy(adap->name, pdev->name, sizeof(adap->name));
adap->class = I2C_CLASS_DEPRECATED;
adap->algo = &unittest_i2c_algo;
adap->dev.parent = dev;
--
2.35.1
Powered by blists - more mailing lists