linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform: move from strlcpy with unused retval to strscpy
@ 2022-08-18 21:00 Wolfram Sang
  2022-08-18 21:58 ` Maximilian Luz
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wolfram Sang, Hans de Goede, Mark Gross, Maximilian Luz,
	Divya Bharathi, Prasanth Ksr, Henrique de Moraes Holschuh,
	platform-driver-x86, Dell.Client.Kernel, ibm-acpi-devel

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@sang-engineering.com>
---
 drivers/platform/surface/surface3_power.c          | 2 +-
 drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
 drivers/platform/x86/intel/chtwc_int33fe.c         | 6 +++---
 drivers/platform/x86/thinkpad_acpi.c               | 4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c
index 444ec81ba02d..4c53d116d59b 100644
--- a/drivers/platform/surface/surface3_power.c
+++ b/drivers/platform/surface/surface3_power.c
@@ -519,7 +519,7 @@ static int mshw0011_probe(struct i2c_client *client)
 	i2c_set_clientdata(client, data);
 
 	memset(&board_info, 0, sizeof(board_info));
-	strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
+	strscpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
 
 	bat0 = i2c_acpi_new_device(dev, 1, &board_info);
 	if (IS_ERR(bat0))
diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
index 636bdfa83284..0a6411a8a104 100644
--- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
+++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
@@ -270,7 +270,7 @@ void strlcpy_attr(char *dest, char *src)
 	size_t len = strlen(src) + 1;
 
 	if (len > 1 && len <= MAX_BUFF)
-		strlcpy(dest, src, len);
+		strscpy(dest, src, len);
 
 	/*len can be zero because any property not-applicable to attribute can
 	 * be empty so check only for too long buffers and log error
diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
index c52ac23e2331..1ea989df513c 100644
--- a/drivers/platform/x86/intel/chtwc_int33fe.c
+++ b/drivers/platform/x86/intel/chtwc_int33fe.c
@@ -270,7 +270,7 @@ cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
 	}
 
 	memset(&board_info, 0, sizeof(board_info));
-	strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
+	strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
 	board_info.dev_name = "max17047";
 	board_info.fwnode = fwnode;
 	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
@@ -361,7 +361,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
 	}
 
 	memset(&board_info, 0, sizeof(board_info));
-	strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
+	strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
 	board_info.dev_name = "fusb302";
 	board_info.fwnode = fwnode;
 	board_info.irq = fusb302_irq;
@@ -381,7 +381,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
 	memset(&board_info, 0, sizeof(board_info));
 	board_info.dev_name = "pi3usb30532";
 	board_info.fwnode = fwnode;
-	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
+	strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
 
 	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
 	if (IS_ERR(data->pi3usb30532)) {
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 22d4e8633e30..8dad0428a83c 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -7623,9 +7623,9 @@ static int __init volume_create_alsa_mixer(void)
 	data = card->private_data;
 	data->card = card;
 
-	strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
+	strscpy(card->driver, TPACPI_ALSA_DRVNAME,
 		sizeof(card->driver));
-	strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
+	strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
 		sizeof(card->shortname));
 	snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
 		 (thinkpad_id.ec_version_str) ?
-- 
2.35.1


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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-18 21:00 [PATCH] platform: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-18 21:58 ` Maximilian Luz
  2022-08-19  6:22 ` Andy Shevchenko
  2022-08-26 10:01 ` Hans de Goede
  2 siblings, 0 replies; 7+ messages in thread
From: Maximilian Luz @ 2022-08-18 21:58 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Hans de Goede, Mark Gross, Divya Bharathi, Prasanth Ksr,
	Henrique de Moraes Holschuh, platform-driver-x86,
	Dell.Client.Kernel, ibm-acpi-devel

On 8/18/22 23:00, Wolfram Sang wrote:
> 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@sang-engineering.com>

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>  # for platform/surface

> ---
>   drivers/platform/surface/surface3_power.c          | 2 +->   drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
>   drivers/platform/x86/intel/chtwc_int33fe.c         | 6 +++---
>   drivers/platform/x86/thinkpad_acpi.c               | 4 ++--
>   4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c
> index 444ec81ba02d..4c53d116d59b 100644
> --- a/drivers/platform/surface/surface3_power.c
> +++ b/drivers/platform/surface/surface3_power.c
> @@ -519,7 +519,7 @@ static int mshw0011_probe(struct i2c_client *client)
>   	i2c_set_clientdata(client, data);
>   
>   	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>   
>   	bat0 = i2c_acpi_new_device(dev, 1, &board_info);
>   	if (IS_ERR(bat0))
> diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> index 636bdfa83284..0a6411a8a104 100644
> --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> @@ -270,7 +270,7 @@ void strlcpy_attr(char *dest, char *src)
>   	size_t len = strlen(src) + 1;
>   
>   	if (len > 1 && len <= MAX_BUFF)
> -		strlcpy(dest, src, len);
> +		strscpy(dest, src, len);
>   
>   	/*len can be zero because any property not-applicable to attribute can
>   	 * be empty so check only for too long buffers and log error
> diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
> index c52ac23e2331..1ea989df513c 100644
> --- a/drivers/platform/x86/intel/chtwc_int33fe.c
> +++ b/drivers/platform/x86/intel/chtwc_int33fe.c
> @@ -270,7 +270,7 @@ cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
>   	}
>   
>   	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
>   	board_info.dev_name = "max17047";
>   	board_info.fwnode = fwnode;
>   	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
> @@ -361,7 +361,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>   	}
>   
>   	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
>   	board_info.dev_name = "fusb302";
>   	board_info.fwnode = fwnode;
>   	board_info.irq = fusb302_irq;
> @@ -381,7 +381,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>   	memset(&board_info, 0, sizeof(board_info));
>   	board_info.dev_name = "pi3usb30532";
>   	board_info.fwnode = fwnode;
> -	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>   
>   	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
>   	if (IS_ERR(data->pi3usb30532)) {
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 22d4e8633e30..8dad0428a83c 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -7623,9 +7623,9 @@ static int __init volume_create_alsa_mixer(void)
>   	data = card->private_data;
>   	data->card = card;
>   
> -	strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
> +	strscpy(card->driver, TPACPI_ALSA_DRVNAME,
>   		sizeof(card->driver));
> -	strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
> +	strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
>   		sizeof(card->shortname));
>   	snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
>   		 (thinkpad_id.ec_version_str) ?

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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-18 21:00 [PATCH] platform: move from strlcpy with unused retval to strscpy Wolfram Sang
  2022-08-18 21:58 ` Maximilian Luz
@ 2022-08-19  6:22 ` Andy Shevchenko
  2022-08-19  8:57   ` Hans de Goede
  2022-08-19  9:19   ` Wolfram Sang
  2022-08-26 10:01 ` Hans de Goede
  2 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-08-19  6:22 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Linux Kernel Mailing List, Hans de Goede, Mark Gross,
	Maximilian Luz, Divya Bharathi, Prasanth Ksr,
	Henrique de Moraes Holschuh, Platform Driver, Dell.Client.Kernel,
	Thinkpad-acpi devel ML

On Fri, Aug 19, 2022 at 12:06 AM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> Follow the advice of the below link and prefer 'strscpy' in this

We refer to the functions like this: strscpy() (note no quote marks).

> subsystem. Conversion is 1:1 because the return value is not used.
> Generated by a coccinelle script.

I assume you are experimenting with coccinelle, so I have no objection
to the change, but in PDx86 we usually want to have one patch per
driver. Can you split?

You also may add
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
to each of them.

> Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/platform/surface/surface3_power.c          | 2 +-
>  drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
>  drivers/platform/x86/intel/chtwc_int33fe.c         | 6 +++---
>  drivers/platform/x86/thinkpad_acpi.c               | 4 ++--
>  4 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c
> index 444ec81ba02d..4c53d116d59b 100644
> --- a/drivers/platform/surface/surface3_power.c
> +++ b/drivers/platform/surface/surface3_power.c
> @@ -519,7 +519,7 @@ static int mshw0011_probe(struct i2c_client *client)
>         i2c_set_clientdata(client, data);
>
>         memset(&board_info, 0, sizeof(board_info));
> -       strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
> +       strscpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>
>         bat0 = i2c_acpi_new_device(dev, 1, &board_info);
>         if (IS_ERR(bat0))
> diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> index 636bdfa83284..0a6411a8a104 100644
> --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> @@ -270,7 +270,7 @@ void strlcpy_attr(char *dest, char *src)
>         size_t len = strlen(src) + 1;
>
>         if (len > 1 && len <= MAX_BUFF)
> -               strlcpy(dest, src, len);
> +               strscpy(dest, src, len);
>
>         /*len can be zero because any property not-applicable to attribute can
>          * be empty so check only for too long buffers and log error
> diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
> index c52ac23e2331..1ea989df513c 100644
> --- a/drivers/platform/x86/intel/chtwc_int33fe.c
> +++ b/drivers/platform/x86/intel/chtwc_int33fe.c
> @@ -270,7 +270,7 @@ cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
>         }
>
>         memset(&board_info, 0, sizeof(board_info));
> -       strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
> +       strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
>         board_info.dev_name = "max17047";
>         board_info.fwnode = fwnode;
>         data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
> @@ -361,7 +361,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>         }
>
>         memset(&board_info, 0, sizeof(board_info));
> -       strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
> +       strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
>         board_info.dev_name = "fusb302";
>         board_info.fwnode = fwnode;
>         board_info.irq = fusb302_irq;
> @@ -381,7 +381,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>         memset(&board_info, 0, sizeof(board_info));
>         board_info.dev_name = "pi3usb30532";
>         board_info.fwnode = fwnode;
> -       strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
> +       strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>
>         data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
>         if (IS_ERR(data->pi3usb30532)) {
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 22d4e8633e30..8dad0428a83c 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -7623,9 +7623,9 @@ static int __init volume_create_alsa_mixer(void)
>         data = card->private_data;
>         data->card = card;
>
> -       strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
> +       strscpy(card->driver, TPACPI_ALSA_DRVNAME,
>                 sizeof(card->driver));
> -       strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
> +       strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
>                 sizeof(card->shortname));
>         snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
>                  (thinkpad_id.ec_version_str) ?
> --
> 2.35.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-19  6:22 ` Andy Shevchenko
@ 2022-08-19  8:57   ` Hans de Goede
  2022-08-19  9:19   ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2022-08-19  8:57 UTC (permalink / raw)
  To: Andy Shevchenko, Wolfram Sang
  Cc: Linux Kernel Mailing List, Mark Gross, Maximilian Luz,
	Divya Bharathi, Prasanth Ksr, Henrique de Moraes Holschuh,
	Platform Driver, Dell.Client.Kernel, Thinkpad-acpi devel ML

Hi,

On 8/19/22 08:22, Andy Shevchenko wrote:
> On Fri, Aug 19, 2022 at 12:06 AM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
>>
>> Follow the advice of the below link and prefer 'strscpy' in this
> 
> We refer to the functions like this: strscpy() (note no quote marks).
> 
>> subsystem. Conversion is 1:1 because the return value is not used.
>> Generated by a coccinelle script.
> 
> I assume you are experimenting with coccinelle, so I have no objection
> to the change, but in PDx86 we usually want to have one patch per
> driver. Can you split?

Actually, although we do in general split patches per driver
as Andy says, this one is so small / simple that I'm happy to
merge it as is. I'll pick this up during my next round of
merges coming Monday.

> You also may add
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Thanks for the review.

Regards,

Hans




> to each of them.
> 
>> Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
>> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
>> ---
>>  drivers/platform/surface/surface3_power.c          | 2 +-
>>  drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
>>  drivers/platform/x86/intel/chtwc_int33fe.c         | 6 +++---
>>  drivers/platform/x86/thinkpad_acpi.c               | 4 ++--
>>  4 files changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c
>> index 444ec81ba02d..4c53d116d59b 100644
>> --- a/drivers/platform/surface/surface3_power.c
>> +++ b/drivers/platform/surface/surface3_power.c
>> @@ -519,7 +519,7 @@ static int mshw0011_probe(struct i2c_client *client)
>>         i2c_set_clientdata(client, data);
>>
>>         memset(&board_info, 0, sizeof(board_info));
>> -       strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>> +       strscpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>>
>>         bat0 = i2c_acpi_new_device(dev, 1, &board_info);
>>         if (IS_ERR(bat0))
>> diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
>> index 636bdfa83284..0a6411a8a104 100644
>> --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
>> +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
>> @@ -270,7 +270,7 @@ void strlcpy_attr(char *dest, char *src)
>>         size_t len = strlen(src) + 1;
>>
>>         if (len > 1 && len <= MAX_BUFF)
>> -               strlcpy(dest, src, len);
>> +               strscpy(dest, src, len);
>>
>>         /*len can be zero because any property not-applicable to attribute can
>>          * be empty so check only for too long buffers and log error
>> diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
>> index c52ac23e2331..1ea989df513c 100644
>> --- a/drivers/platform/x86/intel/chtwc_int33fe.c
>> +++ b/drivers/platform/x86/intel/chtwc_int33fe.c
>> @@ -270,7 +270,7 @@ cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
>>         }
>>
>>         memset(&board_info, 0, sizeof(board_info));
>> -       strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
>> +       strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
>>         board_info.dev_name = "max17047";
>>         board_info.fwnode = fwnode;
>>         data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
>> @@ -361,7 +361,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>>         }
>>
>>         memset(&board_info, 0, sizeof(board_info));
>> -       strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
>> +       strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
>>         board_info.dev_name = "fusb302";
>>         board_info.fwnode = fwnode;
>>         board_info.irq = fusb302_irq;
>> @@ -381,7 +381,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>>         memset(&board_info, 0, sizeof(board_info));
>>         board_info.dev_name = "pi3usb30532";
>>         board_info.fwnode = fwnode;
>> -       strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>> +       strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>>
>>         data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
>>         if (IS_ERR(data->pi3usb30532)) {
>> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
>> index 22d4e8633e30..8dad0428a83c 100644
>> --- a/drivers/platform/x86/thinkpad_acpi.c
>> +++ b/drivers/platform/x86/thinkpad_acpi.c
>> @@ -7623,9 +7623,9 @@ static int __init volume_create_alsa_mixer(void)
>>         data = card->private_data;
>>         data->card = card;
>>
>> -       strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
>> +       strscpy(card->driver, TPACPI_ALSA_DRVNAME,
>>                 sizeof(card->driver));
>> -       strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
>> +       strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
>>                 sizeof(card->shortname));
>>         snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
>>                  (thinkpad_id.ec_version_str) ?
>> --
>> 2.35.1
>>
> 
> 


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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-19  6:22 ` Andy Shevchenko
  2022-08-19  8:57   ` Hans de Goede
@ 2022-08-19  9:19   ` Wolfram Sang
  2022-08-19  9:20     ` Hans de Goede
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2022-08-19  9:19 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Hans de Goede, Mark Gross,
	Maximilian Luz, Divya Bharathi, Prasanth Ksr,
	Henrique de Moraes Holschuh, Platform Driver, Dell.Client.Kernel,
	Thinkpad-acpi devel ML

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]


> I assume you are experimenting with coccinelle, so I have no objection
> to the change, but in PDx86 we usually want to have one patch per
> driver. Can you split?

I can split if you want.

I intentionally did group per subsystem, otherwise I would have sent out
1200+ patches. So, I chose to do it on subsystem level first and adapt
later where this scheme does not fit.

So, your choice.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-19  9:19   ` Wolfram Sang
@ 2022-08-19  9:20     ` Hans de Goede
  0 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2022-08-19  9:20 UTC (permalink / raw)
  To: Wolfram Sang, Andy Shevchenko, Linux Kernel Mailing List,
	Mark Gross, Maximilian Luz, Divya Bharathi, Prasanth Ksr,
	Henrique de Moraes Holschuh, Platform Driver, Dell.Client.Kernel,
	Thinkpad-acpi devel ML

Hi,

On 8/19/22 11:19, Wolfram Sang wrote:
> 
>> I assume you are experimenting with coccinelle, so I have no objection
>> to the change, but in PDx86 we usually want to have one patch per
>> driver. Can you split?
> 
> I can split if you want.
> 
> I intentionally did group per subsystem, otherwise I would have sent out
> 1200+ patches. So, I chose to do it on subsystem level first and adapt
> later where this scheme does not fit.

See my reply to Andy, there is no need to split this further IMHO,
as you sat 1200 patches would be a bit much.

I will merge this as is during my next round of merges.

Regards,

Hans


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

* Re: [PATCH] platform: move from strlcpy with unused retval to strscpy
  2022-08-18 21:00 [PATCH] platform: move from strlcpy with unused retval to strscpy Wolfram Sang
  2022-08-18 21:58 ` Maximilian Luz
  2022-08-19  6:22 ` Andy Shevchenko
@ 2022-08-26 10:01 ` Hans de Goede
  2 siblings, 0 replies; 7+ messages in thread
From: Hans de Goede @ 2022-08-26 10:01 UTC (permalink / raw)
  To: Wolfram Sang, linux-kernel
  Cc: Mark Gross, Maximilian Luz, Divya Bharathi, Prasanth Ksr,
	Henrique de Moraes Holschuh, platform-driver-x86,
	Dell.Client.Kernel, ibm-acpi-devel

Hi,

On 8/18/22 23:00, Wolfram Sang wrote:
> 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@sang-engineering.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
>  drivers/platform/surface/surface3_power.c          | 2 +-
>  drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
>  drivers/platform/x86/intel/chtwc_int33fe.c         | 6 +++---
>  drivers/platform/x86/thinkpad_acpi.c               | 4 ++--
>  4 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c
> index 444ec81ba02d..4c53d116d59b 100644
> --- a/drivers/platform/surface/surface3_power.c
> +++ b/drivers/platform/surface/surface3_power.c
> @@ -519,7 +519,7 @@ static int mshw0011_probe(struct i2c_client *client)
>  	i2c_set_clientdata(client, data);
>  
>  	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "MSHW0011-bat0", I2C_NAME_SIZE);
>  
>  	bat0 = i2c_acpi_new_device(dev, 1, &board_info);
>  	if (IS_ERR(bat0))
> diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> index 636bdfa83284..0a6411a8a104 100644
> --- a/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> +++ b/drivers/platform/x86/dell/dell-wmi-sysman/sysman.c
> @@ -270,7 +270,7 @@ void strlcpy_attr(char *dest, char *src)
>  	size_t len = strlen(src) + 1;
>  
>  	if (len > 1 && len <= MAX_BUFF)
> -		strlcpy(dest, src, len);
> +		strscpy(dest, src, len);
>  
>  	/*len can be zero because any property not-applicable to attribute can
>  	 * be empty so check only for too long buffers and log error
> diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
> index c52ac23e2331..1ea989df513c 100644
> --- a/drivers/platform/x86/intel/chtwc_int33fe.c
> +++ b/drivers/platform/x86/intel/chtwc_int33fe.c
> @@ -270,7 +270,7 @@ cht_int33fe_register_max17047(struct device *dev, struct cht_int33fe_data *data)
>  	}
>  
>  	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "max17047", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
>  	board_info.dev_name = "max17047";
>  	board_info.fwnode = fwnode;
>  	data->battery_fg = i2c_acpi_new_device(dev, 1, &board_info);
> @@ -361,7 +361,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>  	}
>  
>  	memset(&board_info, 0, sizeof(board_info));
> -	strlcpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
>  	board_info.dev_name = "fusb302";
>  	board_info.fwnode = fwnode;
>  	board_info.irq = fusb302_irq;
> @@ -381,7 +381,7 @@ static int cht_int33fe_typec_probe(struct platform_device *pdev)
>  	memset(&board_info, 0, sizeof(board_info));
>  	board_info.dev_name = "pi3usb30532";
>  	board_info.fwnode = fwnode;
> -	strlcpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
> +	strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
>  
>  	data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
>  	if (IS_ERR(data->pi3usb30532)) {
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 22d4e8633e30..8dad0428a83c 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -7623,9 +7623,9 @@ static int __init volume_create_alsa_mixer(void)
>  	data = card->private_data;
>  	data->card = card;
>  
> -	strlcpy(card->driver, TPACPI_ALSA_DRVNAME,
> +	strscpy(card->driver, TPACPI_ALSA_DRVNAME,
>  		sizeof(card->driver));
> -	strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME,
> +	strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
>  		sizeof(card->shortname));
>  	snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
>  		 (thinkpad_id.ec_version_str) ?


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

end of thread, other threads:[~2022-08-26 10:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 21:00 [PATCH] platform: move from strlcpy with unused retval to strscpy Wolfram Sang
2022-08-18 21:58 ` Maximilian Luz
2022-08-19  6:22 ` Andy Shevchenko
2022-08-19  8:57   ` Hans de Goede
2022-08-19  9:19   ` Wolfram Sang
2022-08-19  9:20     ` Hans de Goede
2022-08-26 10:01 ` Hans de Goede

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