summaryrefslogtreecommitdiff
path: root/examples/vhost_scsi
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2019-04-03 15:45:04 +0100
committerThomas Monjalon <thomas@monjalon.net>2019-04-04 22:45:54 +0200
commitf9acaf84e923066344bd3467e4703da66f1f23a8 (patch)
treecd3780dd1ae1739aee8930533401e58d67b3f32e /examples/vhost_scsi
parent277b6e7ef457729b88fe415dfd4a2184e5b329fb (diff)
downloaddpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.zip
dpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.tar.gz
dpdk-f9acaf84e923066344bd3467e4703da66f1f23a8.tar.xz
replace snprintf with strlcpy without adding extra include
For files that already have rte_string_fns.h included in them, we can do a straight replacement of snprintf(..."%s",...) with strlcpy. The changes in this patch were auto-generated via command: spatch --sp-file devtools/cocci/strlcpy-with-header.cocci --dir . --in-place Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'examples/vhost_scsi')
-rw-r--r--examples/vhost_scsi/scsi.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c
index 0c2fa3e..b1529af 100644
--- a/examples/vhost_scsi/scsi.c
+++ b/examples/vhost_scsi/scsi.c
@@ -234,8 +234,8 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev,
desig->reserved0 = 0;
desig->piv = 1;
desig->reserved1 = 0;
- desig->len = snprintf((char *)desig->desig,
- 255, "%s", bdev->name);
+ desig->len = strlcpy((char *)desig->desig, bdev->name,
+ 255);
len += sizeof(struct scsi_desig_desc) + desig->len;
buf += sizeof(struct scsi_desig_desc) + desig->len;
@@ -281,9 +281,8 @@ vhost_bdev_scsi_inquiry_command(struct vhost_block_dev *bdev,
sizeof(inqdata->t10_vendor_id));
/* PRODUCT IDENTIFICATION */
- snprintf((char *)inqdata->product_id,
- RTE_DIM(inqdata->product_id), "%s",
- bdev->product_name);
+ strlcpy((char *)inqdata->product_id, bdev->product_name,
+ RTE_DIM(inqdata->product_id));
/* PRODUCT REVISION LEVEL */
strlcpy((char *)inqdata->product_rev, "0001",