Commit 820109fb authored by Wolfram Sang's avatar Wolfram Sang Committed by Vasily Gorbik

s390: 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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
Acked-by: default avatarBenjamin Block <bblock@linux.ibm.com>
Acked-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Link: https://lore.kernel.org/r/20220818205948.6360-1-wsa+renesas@sang-engineering.com
Link: https://lore.kernel.org/r/20220818210102.7301-1-wsa+renesas@sang-engineering.com
[gor@linux.ibm.com: squashed two changes linked above together]
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent b90cb105
...@@ -250,7 +250,7 @@ static debug_info_t *debug_info_alloc(const char *name, int pages_per_area, ...@@ -250,7 +250,7 @@ static debug_info_t *debug_info_alloc(const char *name, int pages_per_area,
rc->level = level; rc->level = level;
rc->buf_size = buf_size; rc->buf_size = buf_size;
rc->entry_size = sizeof(debug_entry_t) + buf_size; rc->entry_size = sizeof(debug_entry_t) + buf_size;
strlcpy(rc->name, name, sizeof(rc->name)); strscpy(rc->name, name, sizeof(rc->name));
memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *)); memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS * sizeof(struct dentry *)); memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS * sizeof(struct dentry *));
refcount_set(&(rc->ref_count), 0); refcount_set(&(rc->ref_count), 0);
......
...@@ -267,7 +267,7 @@ char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; ...@@ -267,7 +267,7 @@ char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
static void __init setup_boot_command_line(void) static void __init setup_boot_command_line(void)
{ {
/* copy arch command line */ /* copy arch command line */
strlcpy(boot_command_line, early_command_line, COMMAND_LINE_SIZE); strscpy(boot_command_line, early_command_line, COMMAND_LINE_SIZE);
} }
static void __init check_image_bootable(void) static void __init check_image_bootable(void)
......
...@@ -426,7 +426,7 @@ dasd_add_busid(const char *bus_id, int features) ...@@ -426,7 +426,7 @@ dasd_add_busid(const char *bus_id, int features)
if (!devmap) { if (!devmap) {
/* This bus_id is new. */ /* This bus_id is new. */
new->devindex = dasd_max_devindex++; new->devindex = dasd_max_devindex++;
strlcpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); strscpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE);
new->features = features; new->features = features;
new->device = NULL; new->device = NULL;
list_add(&new->list, &dasd_hashlists[hash]); list_add(&new->list, &dasd_hashlists[hash]);
......
...@@ -313,7 +313,7 @@ static void dasd_eer_write_standard_trigger(struct dasd_device *device, ...@@ -313,7 +313,7 @@ static void dasd_eer_write_standard_trigger(struct dasd_device *device,
ktime_get_real_ts64(&ts); ktime_get_real_ts64(&ts);
header.tv_sec = ts.tv_sec; header.tv_sec = ts.tv_sec;
header.tv_usec = ts.tv_nsec / NSEC_PER_USEC; header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
strlcpy(header.busid, dev_name(&device->cdev->dev), strscpy(header.busid, dev_name(&device->cdev->dev),
DASD_EER_BUSID_SIZE); DASD_EER_BUSID_SIZE);
spin_lock_irqsave(&bufferlock, flags); spin_lock_irqsave(&bufferlock, flags);
...@@ -356,7 +356,7 @@ static void dasd_eer_write_snss_trigger(struct dasd_device *device, ...@@ -356,7 +356,7 @@ static void dasd_eer_write_snss_trigger(struct dasd_device *device,
ktime_get_real_ts64(&ts); ktime_get_real_ts64(&ts);
header.tv_sec = ts.tv_sec; header.tv_sec = ts.tv_sec;
header.tv_usec = ts.tv_nsec / NSEC_PER_USEC; header.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
strlcpy(header.busid, dev_name(&device->cdev->dev), strscpy(header.busid, dev_name(&device->cdev->dev),
DASD_EER_BUSID_SIZE); DASD_EER_BUSID_SIZE);
spin_lock_irqsave(&bufferlock, flags); spin_lock_irqsave(&bufferlock, flags);
......
...@@ -614,7 +614,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char ...@@ -614,7 +614,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
rc = -ENAMETOOLONG; rc = -ENAMETOOLONG;
goto seg_list_del; goto seg_list_del;
} }
strlcpy(local_buf, buf, i + 1); strscpy(local_buf, buf, i + 1);
dev_info->num_of_segments = num_of_segments; dev_info->num_of_segments = num_of_segments;
rc = dcssblk_is_continuous(dev_info); rc = dcssblk_is_continuous(dev_info);
if (rc < 0) if (rc < 0)
......
...@@ -154,7 +154,7 @@ static ssize_t hmcdrv_cache_do(const struct hmcdrv_ftp_cmdspec *ftp, ...@@ -154,7 +154,7 @@ static ssize_t hmcdrv_cache_do(const struct hmcdrv_ftp_cmdspec *ftp,
/* cache some file info (FTP command, file name and file /* cache some file info (FTP command, file name and file
* size) unconditionally * size) unconditionally
*/ */
strlcpy(hmcdrv_cache_file.fname, ftp->fname, strscpy(hmcdrv_cache_file.fname, ftp->fname,
HMCDRV_FTP_FIDENT_MAX); HMCDRV_FTP_FIDENT_MAX);
hmcdrv_cache_file.id = ftp->id; hmcdrv_cache_file.id = ftp->id;
pr_debug("caching cmd %d, file size %zu for '%s'\n", pr_debug("caching cmd %d, file size %zu for '%s'\n",
......
...@@ -54,10 +54,10 @@ struct tape_class_device *register_tape_dev( ...@@ -54,10 +54,10 @@ struct tape_class_device *register_tape_dev(
if (!tcd) if (!tcd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
strlcpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN); strscpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/')) for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/'))
*s = '!'; *s = '!';
strlcpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN); strscpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN);
for (s = strchr(tcd->mode_name, '/'); s; s = strchr(s, '/')) for (s = strchr(tcd->mode_name, '/'); s; s = strchr(s, '/'))
*s = '!'; *s = '!';
......
...@@ -87,7 +87,7 @@ int qdio_allocate_dbf(struct qdio_irq *irq_ptr) ...@@ -87,7 +87,7 @@ int qdio_allocate_dbf(struct qdio_irq *irq_ptr)
debug_unregister(irq_ptr->debug_area); debug_unregister(irq_ptr->debug_area);
return -ENOMEM; return -ENOMEM;
} }
strlcpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN); strscpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN);
new_entry->dbf_info = irq_ptr->debug_area; new_entry->dbf_info = irq_ptr->debug_area;
mutex_lock(&qdio_dbf_list_mutex); mutex_lock(&qdio_dbf_list_mutex);
list_add(&new_entry->dbf_list, &qdio_dbf_list); list_add(&new_entry->dbf_list, &qdio_dbf_list);
......
...@@ -1566,7 +1566,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) ...@@ -1566,7 +1566,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
goto out_dev; goto out_dev;
} }
strlcpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name)); strscpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name));
dev_info(&dev->dev, dev_info(&dev->dev,
"setup OK : r/w = %s/%s, protocol : %d\n", "setup OK : r/w = %s/%s, protocol : %d\n",
......
...@@ -28,7 +28,7 @@ init_fsm(char *name, const char **state_names, const char **event_names, int nr_ ...@@ -28,7 +28,7 @@ init_fsm(char *name, const char **state_names, const char **event_names, int nr_
"fsm(%s): init_fsm: Couldn't alloc instance\n", name); "fsm(%s): init_fsm: Couldn't alloc instance\n", name);
return NULL; return NULL;
} }
strlcpy(this->name, name, sizeof(this->name)); strscpy(this->name, name, sizeof(this->name));
init_waitqueue_head(&this->wait_q); init_waitqueue_head(&this->wait_q);
f = kzalloc(sizeof(fsm), order); f = kzalloc(sizeof(fsm), order);
......
...@@ -188,9 +188,9 @@ static void qeth_get_drvinfo(struct net_device *dev, ...@@ -188,9 +188,9 @@ static void qeth_get_drvinfo(struct net_device *dev,
{ {
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
strlcpy(info->driver, IS_LAYER2(card) ? "qeth_l2" : "qeth_l3", strscpy(info->driver, IS_LAYER2(card) ? "qeth_l2" : "qeth_l3",
sizeof(info->driver)); sizeof(info->driver));
strlcpy(info->fw_version, card->info.mcl_level, strscpy(info->fw_version, card->info.mcl_level,
sizeof(info->fw_version)); sizeof(info->fw_version));
snprintf(info->bus_info, sizeof(info->bus_info), "%s/%s/%s", snprintf(info->bus_info, sizeof(info->bus_info), "%s/%s/%s",
CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card)); CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card));
......
...@@ -103,7 +103,7 @@ static void __init zfcp_init_device_setup(char *devstr) ...@@ -103,7 +103,7 @@ static void __init zfcp_init_device_setup(char *devstr)
token = strsep(&str, ","); token = strsep(&str, ",");
if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE) if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
goto err_out; goto err_out;
strlcpy(busid, token, ZFCP_BUS_ID_SIZE); strscpy(busid, token, ZFCP_BUS_ID_SIZE);
token = strsep(&str, ","); token = strsep(&str, ",");
if (!token || kstrtoull(token, 0, (unsigned long long *) &wwpn)) if (!token || kstrtoull(token, 0, (unsigned long long *) &wwpn))
......
...@@ -885,7 +885,7 @@ static int zfcp_fc_gspn(struct zfcp_adapter *adapter, ...@@ -885,7 +885,7 @@ static int zfcp_fc_gspn(struct zfcp_adapter *adapter,
dev_name(&adapter->ccw_device->dev), dev_name(&adapter->ccw_device->dev),
init_utsname()->nodename); init_utsname()->nodename);
else else
strlcpy(fc_host_symbolic_name(adapter->scsi_host), strscpy(fc_host_symbolic_name(adapter->scsi_host),
gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE); gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE);
return 0; return 0;
......
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