examples/vhost_blk: use common macros for min/max
PATCH 1/1 examples/vhost_blk: use common macros for min/max
The macros RTE_MIN and RTE_MAX can be used in DPDK applications.
This change implies fixing the sign of used_len as size_t as defined in vhost_strcpy_pad().
--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
examples/vhost_blk/blk.c +2 -2
@@ -68,7 +68,7 @@ int vhost_bdev_process_blk_commands(struct vhost_block_dev *bdev, struct vhost_blk_task *task) { - int used_len; + size_t used_len;if (unlikely (task->data_len > (bdev->blockcnt * bdev->blocklen))) {fprintf (stderr,"read or write beyond capacity\n" );
@@ -113,7 +113,7 @@ vhost_bdev_process_blk_commands(struct vhost_block_dev *bdev,case VIRTIO_BLK_T_GET_ID :if (!task->iovs_cnt || task->data_len)return VIRTIO_BLK_S_UNSUPP ; - used_len =min (VIRTIO_BLK_ID_BYTES , task->data_len); + used_len =RTE_MIN ((size_t )VIRTIO_BLK_ID_BYTES , task->data_len);vhost_strcpy_pad (task->iovs[0 ].iov_base, bdev->product_name, used_len,' ' );break ;
examples/vhost_blk/vhost_blk.h +0 -2
@@ -40,8 +40,6 @@ struct vhost_blk_queue {#define NUM_OF_BLK_QUEUES 1 -#define min (a, b) (((a) < (b)) ? (a) : (b)) -struct vhost_block_dev {/** ID for vhost library. */ int vid;
examples/vhost_blk/vhost_blk_compat.c +1 -1
@@ -60,7 +60,7 @@ vhost_blk_get_config(struct vhost_block_dev *bdev, uint8_t *config,fprintf (stdout,"block device:blk_size = %d, blkcnt = %" PRIx64"\n" , blk_size, blkcnt); -memcpy (config, &blkcfg,min (len,sizeof (blkcfg))); +memcpy (config, &blkcfg,RTE_MIN (len,sizeof (blkcfg)));return 0 ; }
Signature · 1 line
2.25.0
Quoted 11 lines · Thomas Monjalon
The macros
RTE_MINandRTE_MAXcan be used in DPDK applications.This change implies fixing the sign of
used_lenassize_tas defined invhost_strcpy_pad().Signed-off-by Thomas Monjalon <[email protected]>--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
Thanks,
Tiwei
20/02/2020 03:52, Tiwei Bie:
Quoted 2 lines · Thomas Monjalon
Quoted 1 line
The macros
RTE_MINandRTE_MAXcan be used in DPDK applications.
Only RTE_MIN is used in this patch. The title is wrong as well.
Quoted 11 lines
Quoted 9 lines
This change implies fixing the sign of
used_lenassize_tas defined invhost_strcpy_pad().Signed-off-by Thomas Monjalon <[email protected]>--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)Reviewed-by Tiwei Bie <[email protected]>
Quoted 5 lines · Thomas Monjalon
20/02/2020 03:52, Tiwei Bie:
Quoted 2 lines · Thomas Monjalon
Quoted 1 line
The macros
RTE_MINandRTE_MAXcan be used in DPDK applications.Only
RTE_MINis used in this patch. The title is wrong as well.
Make sense! The commit log should describe what's changed by the patch exactly.
Quoted 16 lines
Quoted 13 lines
Quoted 11 lines
This change implies fixing the sign of
used_lenassize_tas defined invhost_strcpy_pad().Signed-off-by Thomas Monjalon <[email protected]>--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)Reviewed-by Tiwei Bie <[email protected]>
Maxime Coquelin
Reviewed-byQuoted 27 lines · Tiwei Bie
Quoted 5 lines · Thomas Monjalon
20/02/2020 03:52, Tiwei Bie:
Quoted 2 lines · Thomas Monjalon
Quoted 1 line
The macros
RTE_MINandRTE_MAXcan be used in DPDK applications.Only
RTE_MINis used in this patch. The title is wrong as well.Make sense! The commit log should describe what's changed by the patch exactly.
Quoted 16 lines
Quoted 13 lines
Quoted 11 lines
This change implies fixing the sign of
used_lenassize_tas defined invhost_strcpy_pad().Signed-off-by Thomas Monjalon <[email protected]>--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)Reviewed-by Tiwei Bie <[email protected]>
I'll fixup the patch when applying.
Thanks,
Maxime
Maxime Coquelin
AppliedQuoted 11 lines · Thomas Monjalon
The macros
RTE_MINandRTE_MAXcan be used in DPDK applications.This change implies fixing the sign of
used_lenassize_tas defined invhost_strcpy_pad().Signed-off-by Thomas Monjalon <[email protected]>--- examples/vhost_blk/blk.c | 4 ++-- examples/vhost_blk/vhost_blk.h | 2 -- examples/vhost_blk/vhost_blk_compat.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-)
Applied to dpdk-next-virtio/master.
Thanks,
Maxime