* [PATCH v1 1/7] platform/x86: asus-tf103c-dock: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 13:28 ` Hans de Goede
2024-06-02 8:57 ` [PATCH v1 2/7] platform/x86: hp: hp-bioscfg: " Andy Shevchenko
` (6 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/asus-tf103c-dock.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/platform/x86/asus-tf103c-dock.c b/drivers/platform/x86/asus-tf103c-dock.c
index 8f0f87637c5f..b441d8ca72d3 100644
--- a/drivers/platform/x86/asus-tf103c-dock.c
+++ b/drivers/platform/x86/asus-tf103c-dock.c
@@ -490,7 +490,7 @@ static void tf103c_dock_enable_touchpad(struct tf103c_dock_data *dock)
return;
}
- strscpy(board_info.type, "elan_i2c", I2C_NAME_SIZE);
+ strscpy(board_info.type, "elan_i2c");
board_info.addr = TF103C_DOCK_TP_ADDR;
board_info.dev_name = TF103C_DOCK_DEV_NAME "-tp";
board_info.irq = dock->tp_irq;
@@ -795,7 +795,7 @@ static int tf103c_dock_probe(struct i2c_client *client)
*/
dock->ec_client = client;
- strscpy(board_info.type, "tf103c-dock-intr", I2C_NAME_SIZE);
+ strscpy(board_info.type, "tf103c-dock-intr");
board_info.addr = TF103C_DOCK_INTR_ADDR;
board_info.dev_name = TF103C_DOCK_DEV_NAME "-intr";
@@ -803,7 +803,7 @@ static int tf103c_dock_probe(struct i2c_client *client)
if (IS_ERR(dock->intr_client))
return dev_err_probe(dev, PTR_ERR(dock->intr_client), "creating intr client\n");
- strscpy(board_info.type, "tf103c-dock-kbd", I2C_NAME_SIZE);
+ strscpy(board_info.type, "tf103c-dock-kbd");
board_info.addr = TF103C_DOCK_KBD_ADDR;
board_info.dev_name = TF103C_DOCK_DEV_NAME "-kbd";
@@ -846,8 +846,8 @@ static int tf103c_dock_probe(struct i2c_client *client)
dock->hid->vendor = 0x0b05; /* USB_VENDOR_ID_ASUSTEK */
dock->hid->product = 0x0103; /* From TF-103-C */
dock->hid->version = 0x0100; /* 1.0 */
- strscpy(dock->hid->name, "Asus TF103C Dock Keyboard", sizeof(dock->hid->name));
- strscpy(dock->hid->phys, dev_name(dev), sizeof(dock->hid->phys));
+ strscpy(dock->hid->name, "Asus TF103C Dock Keyboard");
+ strscpy(dock->hid->phys, dev_name(dev));
ret = hid_add_device(dock->hid);
if (ret)
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v1 1/7] platform/x86: asus-tf103c-dock: Use 2-argument strscpy()
2024-06-02 8:57 ` [PATCH v1 1/7] platform/x86: asus-tf103c-dock: Use " Andy Shevchenko
@ 2024-06-02 13:28 ` Hans de Goede
0 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2024-06-02 13:28 UTC (permalink / raw)
To: Andy Shevchenko, Jorge Lopez, Li Zetao, Simon Trimmer,
Ilpo Järvinen, Mark Pearson, platform-driver-x86,
linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Hi,
On 6/2/24 10:57 AM, Andy Shevchenko wrote:
> Use 2-argument strscpy(), which is not only shorter but also provides
> an additional check that destination buffer is an array.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks, the entire series looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
for the series.
Regards,
Hans
> ---
> drivers/platform/x86/asus-tf103c-dock.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-tf103c-dock.c b/drivers/platform/x86/asus-tf103c-dock.c
> index 8f0f87637c5f..b441d8ca72d3 100644
> --- a/drivers/platform/x86/asus-tf103c-dock.c
> +++ b/drivers/platform/x86/asus-tf103c-dock.c
> @@ -490,7 +490,7 @@ static void tf103c_dock_enable_touchpad(struct tf103c_dock_data *dock)
> return;
> }
>
> - strscpy(board_info.type, "elan_i2c", I2C_NAME_SIZE);
> + strscpy(board_info.type, "elan_i2c");
> board_info.addr = TF103C_DOCK_TP_ADDR;
> board_info.dev_name = TF103C_DOCK_DEV_NAME "-tp";
> board_info.irq = dock->tp_irq;
> @@ -795,7 +795,7 @@ static int tf103c_dock_probe(struct i2c_client *client)
> */
> dock->ec_client = client;
>
> - strscpy(board_info.type, "tf103c-dock-intr", I2C_NAME_SIZE);
> + strscpy(board_info.type, "tf103c-dock-intr");
> board_info.addr = TF103C_DOCK_INTR_ADDR;
> board_info.dev_name = TF103C_DOCK_DEV_NAME "-intr";
>
> @@ -803,7 +803,7 @@ static int tf103c_dock_probe(struct i2c_client *client)
> if (IS_ERR(dock->intr_client))
> return dev_err_probe(dev, PTR_ERR(dock->intr_client), "creating intr client\n");
>
> - strscpy(board_info.type, "tf103c-dock-kbd", I2C_NAME_SIZE);
> + strscpy(board_info.type, "tf103c-dock-kbd");
> board_info.addr = TF103C_DOCK_KBD_ADDR;
> board_info.dev_name = TF103C_DOCK_DEV_NAME "-kbd";
>
> @@ -846,8 +846,8 @@ static int tf103c_dock_probe(struct i2c_client *client)
> dock->hid->vendor = 0x0b05; /* USB_VENDOR_ID_ASUSTEK */
> dock->hid->product = 0x0103; /* From TF-103-C */
> dock->hid->version = 0x0100; /* 1.0 */
> - strscpy(dock->hid->name, "Asus TF103C Dock Keyboard", sizeof(dock->hid->name));
> - strscpy(dock->hid->phys, dev_name(dev), sizeof(dock->hid->phys));
> + strscpy(dock->hid->name, "Asus TF103C Dock Keyboard");
> + strscpy(dock->hid->phys, dev_name(dev));
>
> ret = hid_add_device(dock->hid);
> if (ret)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v1 2/7] platform/x86: hp: hp-bioscfg: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 1/7] platform/x86: asus-tf103c-dock: Use " Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 3/7] platform/x86: intel: chtwc_int33fe: " Andy Shevchenko
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
.../x86/hp/hp-bioscfg/enum-attributes.c | 18 +++++-------------
.../x86/hp/hp-bioscfg/int-attributes.c | 7 ++-----
.../x86/hp/hp-bioscfg/order-list-attributes.c | 18 +++++-------------
.../x86/hp/hp-bioscfg/passwdobj-attributes.c | 19 +++++--------------
.../x86/hp/hp-bioscfg/spmobj-attributes.c | 3 +--
.../x86/hp/hp-bioscfg/string-attributes.c | 12 ++++--------
6 files changed, 22 insertions(+), 55 deletions(-)
diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
index a2402d31c146..c50ad5880503 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
@@ -52,9 +52,7 @@ static void update_enumeration_value(int instance_id, char *attr_value)
{
struct enumeration_data *enum_data = &bioscfg_drv.enumeration_data[instance_id];
- strscpy(enum_data->current_value,
- attr_value,
- sizeof(enum_data->current_value));
+ strscpy(enum_data->current_value, attr_value);
}
ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, enumeration);
@@ -174,8 +172,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
case VALUE:
break;
case PATH:
- strscpy(enum_data->common.path, str_value,
- sizeof(enum_data->common.path));
+ strscpy(enum_data->common.path, str_value);
break;
case IS_READONLY:
enum_data->common.is_readonly = int_value;
@@ -222,9 +219,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
if (ret)
return -EINVAL;
- strscpy(enum_data->common.prerequisites[reqs],
- str_value,
- sizeof(enum_data->common.prerequisites[reqs]));
+ strscpy(enum_data->common.prerequisites[reqs], str_value);
kfree(str_value);
str_value = NULL;
@@ -236,8 +231,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
break;
case ENUM_CURRENT_VALUE:
- strscpy(enum_data->current_value,
- str_value, sizeof(enum_data->current_value));
+ strscpy(enum_data->current_value, str_value);
break;
case ENUM_SIZE:
if (int_value > MAX_VALUES_SIZE) {
@@ -278,9 +272,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
* is greater than MAX_VALUES_SIZE
*/
if (size < MAX_VALUES_SIZE)
- strscpy(enum_data->possible_values[pos_values],
- str_value,
- sizeof(enum_data->possible_values[pos_values]));
+ strscpy(enum_data->possible_values[pos_values], str_value);
kfree(str_value);
str_value = NULL;
diff --git a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
index 86b7ac63fec2..6c7f4d5fa9cb 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c
@@ -192,8 +192,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
integer_data->current_value = int_value;
break;
case PATH:
- strscpy(integer_data->common.path, str_value,
- sizeof(integer_data->common.path));
+ strscpy(integer_data->common.path, str_value);
break;
case IS_READONLY:
integer_data->common.is_readonly = int_value;
@@ -240,9 +239,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
if (ret)
continue;
- strscpy(integer_data->common.prerequisites[reqs],
- str_value,
- sizeof(integer_data->common.prerequisites[reqs]));
+ strscpy(integer_data->common.prerequisites[reqs], str_value);
kfree(str_value);
str_value = NULL;
}
diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
index 1ff09dfb7d7e..c6e57bb9d8b7 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c
@@ -57,9 +57,7 @@ static void update_ordered_list_value(int instance, char *attr_value)
{
struct ordered_list_data *ordered_list_data = &bioscfg_drv.ordered_list_data[instance];
- strscpy(ordered_list_data->current_value,
- attr_value,
- sizeof(ordered_list_data->current_value));
+ strscpy(ordered_list_data->current_value, attr_value);
}
ATTRIBUTE_S_COMMON_PROPERTY_SHOW(display_name, ordered_list);
@@ -179,13 +177,11 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
/* Assign appropriate element value to corresponding field*/
switch (eloc) {
case VALUE:
- strscpy(ordered_list_data->current_value,
- str_value, sizeof(ordered_list_data->current_value));
+ strscpy(ordered_list_data->current_value, str_value);
replace_char_str(ordered_list_data->current_value, COMMA_SEP, SEMICOLON_SEP);
break;
case PATH:
- strscpy(ordered_list_data->common.path, str_value,
- sizeof(ordered_list_data->common.path));
+ strscpy(ordered_list_data->common.path, str_value);
break;
case IS_READONLY:
ordered_list_data->common.is_readonly = int_value;
@@ -227,9 +223,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
if (ret)
continue;
- strscpy(ordered_list_data->common.prerequisites[reqs],
- str_value,
- sizeof(ordered_list_data->common.prerequisites[reqs]));
+ strscpy(ordered_list_data->common.prerequisites[reqs], str_value);
kfree(str_value);
str_value = NULL;
@@ -271,9 +265,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
part = strsep(&part_tmp, COMMA_SEP);
for (olist_elem = 0; olist_elem < MAX_ELEMENTS_SIZE && part; olist_elem++) {
- strscpy(ordered_list_data->elements[olist_elem],
- part,
- sizeof(ordered_list_data->elements[olist_elem]));
+ strscpy(ordered_list_data->elements[olist_elem], part);
part = strsep(&part_tmp, COMMA_SEP);
}
ordered_list_data->elements_size = olist_elem;
diff --git a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
index f7efe217a4bb..35936c05e45b 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c
@@ -101,13 +101,9 @@ static int store_password_instance(struct kobject *kobj, const char *buf,
if (!ret) {
if (is_current)
- strscpy(bioscfg_drv.password_data[id].current_password,
- buf_cp,
- sizeof(bioscfg_drv.password_data[id].current_password));
+ strscpy(bioscfg_drv.password_data[id].current_password, buf_cp);
else
- strscpy(bioscfg_drv.password_data[id].new_password,
- buf_cp,
- sizeof(bioscfg_drv.password_data[id].new_password));
+ strscpy(bioscfg_drv.password_data[id].new_password, buf_cp);
}
kfree(buf_cp);
@@ -272,8 +268,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
case VALUE:
break;
case PATH:
- strscpy(password_data->common.path, str_value,
- sizeof(password_data->common.path));
+ strscpy(password_data->common.path, str_value);
break;
case IS_READONLY:
password_data->common.is_readonly = int_value;
@@ -315,9 +310,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
if (ret)
break;
- strscpy(password_data->common.prerequisites[reqs],
- str_value,
- sizeof(password_data->common.prerequisites[reqs]));
+ strscpy(password_data->common.prerequisites[reqs], str_value);
kfree(str_value);
str_value = NULL;
@@ -359,9 +352,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
if (ret)
break;
- strscpy(password_data->encodings[pos_values],
- str_value,
- sizeof(password_data->encodings[pos_values]));
+ strscpy(password_data->encodings[pos_values], str_value);
kfree(str_value);
str_value = NULL;
diff --git a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
index 86f90238750c..2b00a14792e9 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/spmobj-attributes.c
@@ -365,8 +365,7 @@ int hp_populate_secure_platform_data(struct kobject *attr_name_kobj)
/* Populate data for Secure Platform Management */
bioscfg_drv.spm_data.attr_name_kobj = attr_name_kobj;
- strscpy(bioscfg_drv.spm_data.attribute_name, SPM_STR,
- sizeof(bioscfg_drv.spm_data.attribute_name));
+ strscpy(bioscfg_drv.spm_data.attribute_name, SPM_STR);
bioscfg_drv.spm_data.is_enabled = 0;
bioscfg_drv.spm_data.mechanism = 0;
diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
index f0c20070094d..27758b779b2d 100644
--- a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
+++ b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c
@@ -50,7 +50,7 @@ static void update_string_value(int instance_id, char *attr_value)
struct string_data *string_data = &bioscfg_drv.string_data[instance_id];
/* Write settings to BIOS */
- strscpy(string_data->current_value, attr_value, sizeof(string_data->current_value));
+ strscpy(string_data->current_value, attr_value);
}
/*
@@ -178,12 +178,10 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
/* Assign appropriate element value to corresponding field*/
switch (eloc) {
case VALUE:
- strscpy(string_data->current_value,
- str_value, sizeof(string_data->current_value));
+ strscpy(string_data->current_value, str_value);
break;
case PATH:
- strscpy(string_data->common.path, str_value,
- sizeof(string_data->common.path));
+ strscpy(string_data->common.path, str_value);
break;
case IS_READONLY:
string_data->common.is_readonly = int_value;
@@ -231,9 +229,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
if (ret)
continue;
- strscpy(string_data->common.prerequisites[reqs],
- str_value,
- sizeof(string_data->common.prerequisites[reqs]));
+ strscpy(string_data->common.prerequisites[reqs], str_value);
kfree(str_value);
str_value = NULL;
}
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v1 3/7] platform/x86: intel: chtwc_int33fe: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 1/7] platform/x86: asus-tf103c-dock: Use " Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 2/7] platform/x86: hp: hp-bioscfg: " Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 4/7] platform/x86: serial-multi-instantiate: " Andy Shevchenko
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/intel/chtwc_int33fe.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/intel/chtwc_int33fe.c b/drivers/platform/x86/intel/chtwc_int33fe.c
index 93f75ba1dafd..11503b1c85f3 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));
- strscpy(board_info.type, "max17047", I2C_NAME_SIZE);
+ strscpy(board_info.type, "max17047");
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));
- strscpy(board_info.type, "typec_fusb302", I2C_NAME_SIZE);
+ strscpy(board_info.type, "typec_fusb302");
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;
- strscpy(board_info.type, "pi3usb30532", I2C_NAME_SIZE);
+ strscpy(board_info.type, "pi3usb30532");
data->pi3usb30532 = i2c_acpi_new_device(dev, 3, &board_info);
if (IS_ERR(data->pi3usb30532)) {
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v1 4/7] platform/x86: serial-multi-instantiate: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
` (2 preceding siblings ...)
2024-06-02 8:57 ` [PATCH v1 3/7] platform/x86: intel: chtwc_int33fe: " Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 5/7] platform/x86: think-lmi: " Andy Shevchenko
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/serial-multi-instantiate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/serial-multi-instantiate.c b/drivers/platform/x86/serial-multi-instantiate.c
index 97b9c6392230..3be016cfe601 100644
--- a/drivers/platform/x86/serial-multi-instantiate.c
+++ b/drivers/platform/x86/serial-multi-instantiate.c
@@ -131,7 +131,7 @@ static int smi_spi_probe(struct platform_device *pdev, struct smi *smi,
ctlr = spi_dev->controller;
- strscpy(spi_dev->modalias, inst_array[i].type, sizeof(spi_dev->modalias));
+ strscpy(spi_dev->modalias, inst_array[i].type);
ret = smi_get_irq(pdev, adev, &inst_array[i]);
if (ret < 0) {
@@ -205,7 +205,7 @@ static int smi_i2c_probe(struct platform_device *pdev, struct smi *smi,
for (i = 0; i < count && inst_array[i].type; i++) {
memset(&board_info, 0, sizeof(board_info));
- strscpy(board_info.type, inst_array[i].type, I2C_NAME_SIZE);
+ strscpy(board_info.type, inst_array[i].type);
snprintf(name, sizeof(name), "%s-%s.%d", dev_name(dev), inst_array[i].type, i);
board_info.dev_name = name;
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v1 5/7] platform/x86: think-lmi: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
` (3 preceding siblings ...)
2024-06-02 8:57 ` [PATCH v1 4/7] platform/x86: serial-multi-instantiate: " Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 8:57 ` [PATCH v1 6/7] platform/x86: thinkpad_acpi: " Andy Shevchenko
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/think-lmi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index 0f2264bb7577..4cfb53206cb8 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -1508,7 +1508,7 @@ static struct tlmi_pwd_setting *tlmi_create_auth(const char *pwd_type,
if (!new_pwd)
return NULL;
- strscpy(new_pwd->kbdlang, "us", TLMI_LANG_MAXLEN);
+ strscpy(new_pwd->kbdlang, "us");
new_pwd->encoding = TLMI_ENCODING_ASCII;
new_pwd->pwd_type = pwd_type;
new_pwd->role = pwd_role;
@@ -1582,7 +1582,7 @@ static int tlmi_analyze(void)
goto fail_clear_attr;
}
setting->index = i;
- strscpy(setting->display_name, item, TLMI_SETTINGS_MAXLEN);
+ strscpy(setting->display_name, item);
/* If BIOS selections supported, load those */
if (tlmi_priv.can_get_bios_selections) {
ret = tlmi_get_bios_selections(setting->display_name,
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v1 6/7] platform/x86: thinkpad_acpi: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
` (4 preceding siblings ...)
2024-06-02 8:57 ` [PATCH v1 5/7] platform/x86: think-lmi: " Andy Shevchenko
@ 2024-06-02 8:57 ` Andy Shevchenko
2024-06-02 8:58 ` [PATCH v1 7/7] platform/x86: touchscreen_dmi: " Andy Shevchenko
2024-06-03 11:54 ` [PATCH v1 0/7] platform/x86: Move to " Ilpo Järvinen
7 siblings, 0 replies; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:57 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/thinkpad_acpi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 397b409064c9..f269ca1ff771 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -7416,10 +7416,8 @@ static int __init volume_create_alsa_mixer(void)
data = card->private_data;
data->card = card;
- strscpy(card->driver, TPACPI_ALSA_DRVNAME,
- sizeof(card->driver));
- strscpy(card->shortname, TPACPI_ALSA_SHRTNAME,
- sizeof(card->shortname));
+ strscpy(card->driver, TPACPI_ALSA_DRVNAME);
+ strscpy(card->shortname, TPACPI_ALSA_SHRTNAME);
snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s",
(thinkpad_id.ec_version_str) ?
thinkpad_id.ec_version_str : "(unknown)");
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH v1 7/7] platform/x86: touchscreen_dmi: Use 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
` (5 preceding siblings ...)
2024-06-02 8:57 ` [PATCH v1 6/7] platform/x86: thinkpad_acpi: " Andy Shevchenko
@ 2024-06-02 8:58 ` Andy Shevchenko
2024-06-03 9:16 ` Hans de Goede
2024-06-03 11:54 ` [PATCH v1 0/7] platform/x86: Move to " Ilpo Järvinen
7 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2024-06-02 8:58 UTC (permalink / raw)
To: Hans de Goede, Andy Shevchenko, Jorge Lopez, Li Zetao,
Simon Trimmer, Ilpo Järvinen, Mark Pearson,
platform-driver-x86, linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Use 2-argument strscpy(), which is not only shorter but also provides
an additional check that destination buffer is an array.
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/platform/x86/touchscreen_dmi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c
index 2d9ca2292ea1..879a63e4ecd0 100644
--- a/drivers/platform/x86/touchscreen_dmi.c
+++ b/drivers/platform/x86/touchscreen_dmi.c
@@ -1907,7 +1907,7 @@ static int __init ts_parse_props(char *str)
u32 u32val;
int i, ret;
- strscpy(orig_str, str, sizeof(orig_str));
+ strscpy(orig_str, str);
/*
* str is part of the static_command_line from init/main.c and poking
--
2.45.1
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH v1 7/7] platform/x86: touchscreen_dmi: Use 2-argument strscpy()
2024-06-02 8:58 ` [PATCH v1 7/7] platform/x86: touchscreen_dmi: " Andy Shevchenko
@ 2024-06-03 9:16 ` Hans de Goede
0 siblings, 0 replies; 11+ messages in thread
From: Hans de Goede @ 2024-06-03 9:16 UTC (permalink / raw)
To: Andy Shevchenko, Jorge Lopez, Li Zetao, Simon Trimmer,
Ilpo Järvinen, Mark Pearson, platform-driver-x86,
linux-kernel, ibm-acpi-devel, linux-input
Cc: Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
Hi,
On 6/2/24 10:58 AM, Andy Shevchenko wrote:
> Use 2-argument strscpy(), which is not only shorter but also provides
> an additional check that destination buffer is an array.
>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Since the code being modified only exists on the fixes branch I've merged
this as a fix now.
I know this is more of a cleanup then a pure fix, but since the DMI quirks
always get updated through the fixes branch this avoids conflicts.
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
Regards,
Hans
> ---
> drivers/platform/x86/touchscreen_dmi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c
> index 2d9ca2292ea1..879a63e4ecd0 100644
> --- a/drivers/platform/x86/touchscreen_dmi.c
> +++ b/drivers/platform/x86/touchscreen_dmi.c
> @@ -1907,7 +1907,7 @@ static int __init ts_parse_props(char *str)
> u32 u32val;
> int i, ret;
>
> - strscpy(orig_str, str, sizeof(orig_str));
> + strscpy(orig_str, str);
>
> /*
> * str is part of the static_command_line from init/main.c and poking
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy()
2024-06-02 8:57 [PATCH v1 0/7] platform/x86: Move to 2-argument strscpy() Andy Shevchenko
` (6 preceding siblings ...)
2024-06-02 8:58 ` [PATCH v1 7/7] platform/x86: touchscreen_dmi: " Andy Shevchenko
@ 2024-06-03 11:54 ` Ilpo Järvinen
7 siblings, 0 replies; 11+ messages in thread
From: Ilpo Järvinen @ 2024-06-03 11:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Hans de Goede, Jorge Lopez, Li Zetao, Simon Trimmer, Mark Pearson,
platform-driver-x86, LKML, ibm-acpi-devel, linux-input,
Corentin Chary, Luke D. Jones, Mark Pearson,
Henrique de Moraes Holschuh
On Sun, 2 Jun 2024, Andy Shevchenko wrote:
> Move to 2-argument strscpy() to make code shorter and have an additional check.
> No functional change intended.
>
> Some cases are let untouched where it looks better with the 3rd argument.
>
> Andy Shevchenko (7):
> platform/x86: asus-tf103c-dock: Use 2-argument strscpy()
> platform/x86: hp: hp-bioscfg: Use 2-argument strscpy()
> platform/x86: intel: chtwc_int33fe: Use 2-argument strscpy()
> platform/x86: serial-multi-instantiate: Use 2-argument strscpy()
> platform/x86: think-lmi: Use 2-argument strscpy()
> platform/x86: thinkpad_acpi: Use 2-argument strscpy()
> platform/x86: touchscreen_dmi: Use 2-argument strscpy()
Patches 1-6 applied to review-ilpo branch.
--
i.
^ permalink raw reply [flat|nested] 11+ messages in thread