The macro RTE_MIN can be used in vhost-blk example.
This change implies fixing the sign of used_len as size_t
as defined in vhost_strcpy_pad().
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
vhost_bdev_process_blk_commands(struct vhost_block_dev *bdev,
struct vhost_blk_task *task)
{
vhost_bdev_process_blk_commands(struct vhost_block_dev *bdev,
struct vhost_blk_task *task)
{
if (unlikely(task->data_len > (bdev->blockcnt * bdev->blocklen))) {
fprintf(stderr, "read or write beyond capacity\n");
if (unlikely(task->data_len > (bdev->blockcnt * bdev->blocklen))) {
fprintf(stderr, "read or write beyond capacity\n");
case VIRTIO_BLK_T_GET_ID:
if (!task->iovs_cnt || task->data_len)
return VIRTIO_BLK_S_UNSUPP;
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;
vhost_strcpy_pad(task->iovs[0].iov_base,
bdev->product_name, used_len, ' ');
break;
#define NUM_OF_BLK_QUEUES 1
#define NUM_OF_BLK_QUEUES 1
-#define min(a, b) (((a) < (b)) ? (a) : (b))
-
struct vhost_block_dev {
/** ID for vhost library. */
int vid;
struct vhost_block_dev {
/** ID for vhost library. */
int vid;
fprintf(stdout, "block device:blk_size = %d, blkcnt = %"PRIx64"\n",
blk_size, blkcnt);
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)));