Commit a6611144 authored by Kumar Kartikeya Dwivedi's avatar Kumar Kartikeya Dwivedi Committed by Greg Kroah-Hartman

staging: greybus: Switch from strlcpy to strscpy

strlcpy is marked as deprecated in Documentation/process/deprecated.rst,
and there is no functional difference when the caller expects truncation
(when not checking the return value). strscpy is relatively better as it
also avoids scanning the whole source string.

This silences the related checkpatch warnings from:
5dbdb2d8 ("checkpatch: prefer strscpy to strlcpy")
Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20210131172838.146706-3-memxor@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a91e4e01
...@@ -166,7 +166,7 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev, ...@@ -166,7 +166,7 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
snprintf(id.name, sizeof(id.name), "%s %s", prefix, snprintf(id.name, sizeof(id.name), "%s %s", prefix,
control->name); control->name);
else else
strlcpy(id.name, control->name, sizeof(id.name)); strscpy(id.name, control->name, sizeof(id.name));
id.numid = 0; id.numid = 0;
id.iface = control->iface; id.iface = control->iface;
id.device = control->device; id.device = control->device;
......
...@@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle, ...@@ -342,7 +342,7 @@ static int gb_audio_probe(struct gb_bundle *bundle,
/* inform above layer for uevent */ /* inform above layer for uevent */
dev_dbg(dev, "Inform set_event:%d to above layer\n", 1); dev_dbg(dev, "Inform set_event:%d to above layer\n", 1);
/* prepare for the audio manager */ /* prepare for the audio manager */
strlcpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN); strscpy(desc.name, gbmodule->name, GB_AUDIO_MANAGER_MODULE_NAME_LEN);
desc.vid = 2; /* todo */ desc.vid = 2; /* todo */
desc.pid = 3; /* todo */ desc.pid = 3; /* todo */
desc.intf_id = gbmodule->dev_id; desc.intf_id = gbmodule->dev_id;
......
...@@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, ...@@ -200,7 +200,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
name = gbaudio_map_controlid(module, data->ctl_id, name = gbaudio_map_controlid(module, data->ctl_id,
uinfo->value.enumerated.item); uinfo->value.enumerated.item);
strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE); strscpy(uinfo->value.enumerated.name, name, NAME_SIZE);
break; break;
default: default:
dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n", dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n",
...@@ -1047,7 +1047,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module, ...@@ -1047,7 +1047,7 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
} }
/* Prefix dev_id to widget control_name */ /* Prefix dev_id to widget control_name */
strlcpy(temp_name, w->name, NAME_SIZE); strscpy(temp_name, w->name, NAME_SIZE);
snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name); snprintf(w->name, NAME_SIZE, "GB %d %s", module->dev_id, temp_name);
switch (w->type) { switch (w->type) {
...@@ -1169,7 +1169,7 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module, ...@@ -1169,7 +1169,7 @@ static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module,
} }
control->id = curr->id; control->id = curr->id;
/* Prefix dev_id to widget_name */ /* Prefix dev_id to widget_name */
strlcpy(temp_name, curr->name, NAME_SIZE); strscpy(temp_name, curr->name, NAME_SIZE);
snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id, snprintf(curr->name, NAME_SIZE, "GB %d %s", module->dev_id,
temp_name); temp_name);
control->name = curr->name; control->name = curr->name;
......
...@@ -449,7 +449,7 @@ static int __gb_power_supply_set_name(char *init_name, char *name, size_t len) ...@@ -449,7 +449,7 @@ static int __gb_power_supply_set_name(char *init_name, char *name, size_t len)
if (!strlen(init_name)) if (!strlen(init_name))
init_name = "gb_power_supply"; init_name = "gb_power_supply";
strlcpy(name, init_name, len); strscpy(name, init_name, len);
while ((ret < len) && (psy = power_supply_get_by_name(name))) { while ((ret < len) && (psy = power_supply_get_by_name(name))) {
power_supply_put(psy); power_supply_put(psy);
......
...@@ -455,10 +455,10 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs) ...@@ -455,10 +455,10 @@ static int gb_spi_setup_device(struct gb_spilib *spi, u8 cs)
dev_type = response.device_type; dev_type = response.device_type;
if (dev_type == GB_SPI_SPI_DEV) if (dev_type == GB_SPI_SPI_DEV)
strlcpy(spi_board.modalias, "spidev", strscpy(spi_board.modalias, "spidev",
sizeof(spi_board.modalias)); sizeof(spi_board.modalias));
else if (dev_type == GB_SPI_SPI_NOR) else if (dev_type == GB_SPI_SPI_NOR)
strlcpy(spi_board.modalias, "spi-nor", strscpy(spi_board.modalias, "spi-nor",
sizeof(spi_board.modalias)); sizeof(spi_board.modalias));
else if (dev_type == GB_SPI_SPI_MODALIAS) else if (dev_type == GB_SPI_SPI_MODALIAS)
memcpy(spi_board.modalias, response.name, memcpy(spi_board.modalias, response.name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment