Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Benjamin Block <bblock@linux.ibm.com>
Acked-by: Alexandra 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: Vasily Gorbik <gor@linux.ibm.com>

authored by

Wolfram Sang and committed by
Vasily Gorbik
820109fb b90cb105

+16 -16
+1 -1
arch/s390/kernel/debug.c
··· 250 250 rc->level = level; 251 251 rc->buf_size = buf_size; 252 252 rc->entry_size = sizeof(debug_entry_t) + buf_size; 253 - strlcpy(rc->name, name, sizeof(rc->name)); 253 + strscpy(rc->name, name, sizeof(rc->name)); 254 254 memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *)); 255 255 memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS * sizeof(struct dentry *)); 256 256 refcount_set(&(rc->ref_count), 0);
+1 -1
arch/s390/kernel/early.c
··· 267 267 static void __init setup_boot_command_line(void) 268 268 { 269 269 /* copy arch command line */ 270 - strlcpy(boot_command_line, early_command_line, COMMAND_LINE_SIZE); 270 + strscpy(boot_command_line, early_command_line, COMMAND_LINE_SIZE); 271 271 } 272 272 273 273 static void __init check_image_bootable(void)
+1 -1
drivers/s390/block/dasd_devmap.c
··· 426 426 if (!devmap) { 427 427 /* This bus_id is new. */ 428 428 new->devindex = dasd_max_devindex++; 429 - strlcpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); 429 + strscpy(new->bus_id, bus_id, DASD_BUS_ID_SIZE); 430 430 new->features = features; 431 431 new->device = NULL; 432 432 list_add(&new->list, &dasd_hashlists[hash]);
+2 -2
drivers/s390/block/dasd_eer.c
··· 313 313 ktime_get_real_ts64(&ts); 314 314 header.tv_sec = ts.tv_sec; 315 315 header.tv_usec = ts.tv_nsec / NSEC_PER_USEC; 316 - strlcpy(header.busid, dev_name(&device->cdev->dev), 316 + strscpy(header.busid, dev_name(&device->cdev->dev), 317 317 DASD_EER_BUSID_SIZE); 318 318 319 319 spin_lock_irqsave(&bufferlock, flags); ··· 356 356 ktime_get_real_ts64(&ts); 357 357 header.tv_sec = ts.tv_sec; 358 358 header.tv_usec = ts.tv_nsec / NSEC_PER_USEC; 359 - strlcpy(header.busid, dev_name(&device->cdev->dev), 359 + strscpy(header.busid, dev_name(&device->cdev->dev), 360 360 DASD_EER_BUSID_SIZE); 361 361 362 362 spin_lock_irqsave(&bufferlock, flags);
+1 -1
drivers/s390/block/dcssblk.c
··· 614 614 rc = -ENAMETOOLONG; 615 615 goto seg_list_del; 616 616 } 617 - strlcpy(local_buf, buf, i + 1); 617 + strscpy(local_buf, buf, i + 1); 618 618 dev_info->num_of_segments = num_of_segments; 619 619 rc = dcssblk_is_continuous(dev_info); 620 620 if (rc < 0)
+1 -1
drivers/s390/char/hmcdrv_cache.c
··· 154 154 /* cache some file info (FTP command, file name and file 155 155 * size) unconditionally 156 156 */ 157 - strlcpy(hmcdrv_cache_file.fname, ftp->fname, 157 + strscpy(hmcdrv_cache_file.fname, ftp->fname, 158 158 HMCDRV_FTP_FIDENT_MAX); 159 159 hmcdrv_cache_file.id = ftp->id; 160 160 pr_debug("caching cmd %d, file size %zu for '%s'\n",
+2 -2
drivers/s390/char/tape_class.c
··· 54 54 if (!tcd) 55 55 return ERR_PTR(-ENOMEM); 56 56 57 - strlcpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN); 57 + strscpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN); 58 58 for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/')) 59 59 *s = '!'; 60 - strlcpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN); 60 + strscpy(tcd->mode_name, mode_name, TAPECLASS_NAME_LEN); 61 61 for (s = strchr(tcd->mode_name, '/'); s; s = strchr(s, '/')) 62 62 *s = '!'; 63 63
+1 -1
drivers/s390/cio/qdio_debug.c
··· 87 87 debug_unregister(irq_ptr->debug_area); 88 88 return -ENOMEM; 89 89 } 90 - strlcpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN); 90 + strscpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN); 91 91 new_entry->dbf_info = irq_ptr->debug_area; 92 92 mutex_lock(&qdio_dbf_list_mutex); 93 93 list_add(&new_entry->dbf_list, &qdio_dbf_list);
+1 -1
drivers/s390/net/ctcm_main.c
··· 1566 1566 goto out_dev; 1567 1567 } 1568 1568 1569 - strlcpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name)); 1569 + strscpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name)); 1570 1570 1571 1571 dev_info(&dev->dev, 1572 1572 "setup OK : r/w = %s/%s, protocol : %d\n",
+1 -1
drivers/s390/net/fsm.c
··· 28 28 "fsm(%s): init_fsm: Couldn't alloc instance\n", name); 29 29 return NULL; 30 30 } 31 - strlcpy(this->name, name, sizeof(this->name)); 31 + strscpy(this->name, name, sizeof(this->name)); 32 32 init_waitqueue_head(&this->wait_q); 33 33 34 34 f = kzalloc(sizeof(fsm), order);
+2 -2
drivers/s390/net/qeth_ethtool.c
··· 188 188 { 189 189 struct qeth_card *card = dev->ml_priv; 190 190 191 - strlcpy(info->driver, IS_LAYER2(card) ? "qeth_l2" : "qeth_l3", 191 + strscpy(info->driver, IS_LAYER2(card) ? "qeth_l2" : "qeth_l3", 192 192 sizeof(info->driver)); 193 - strlcpy(info->fw_version, card->info.mcl_level, 193 + strscpy(info->fw_version, card->info.mcl_level, 194 194 sizeof(info->fw_version)); 195 195 snprintf(info->bus_info, sizeof(info->bus_info), "%s/%s/%s", 196 196 CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card));
+1 -1
drivers/s390/scsi/zfcp_aux.c
··· 103 103 token = strsep(&str, ","); 104 104 if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE) 105 105 goto err_out; 106 - strlcpy(busid, token, ZFCP_BUS_ID_SIZE); 106 + strscpy(busid, token, ZFCP_BUS_ID_SIZE); 107 107 108 108 token = strsep(&str, ","); 109 109 if (!token || kstrtoull(token, 0, (unsigned long long *) &wwpn))
+1 -1
drivers/s390/scsi/zfcp_fc.c
··· 885 885 dev_name(&adapter->ccw_device->dev), 886 886 init_utsname()->nodename); 887 887 else 888 - strlcpy(fc_host_symbolic_name(adapter->scsi_host), 888 + strscpy(fc_host_symbolic_name(adapter->scsi_host), 889 889 gspn_rsp->gspn.fp_name, FC_SYMBOLIC_NAME_SIZE); 890 890 891 891 return 0;