DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
@ 2020-02-19 10:39 Thomas Monjalon
  2020-02-20  2:52 ` Tiwei Bie
  2020-04-10 14:42 ` Maxime Coquelin
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2020-02-19 10:39 UTC (permalink / raw)
  To: dev; +Cc: Maxime Coquelin, Tiwei Bie, Zhihong Wang

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().

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 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(-)

diff --git a/examples/vhost_blk/blk.c b/examples/vhost_blk/blk.c
index 1b0b764b22..0d1e038741 100644
--- a/examples/vhost_blk/blk.c
+++ b/examples/vhost_blk/blk.c
@@ -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;
diff --git a/examples/vhost_blk/vhost_blk.h b/examples/vhost_blk/vhost_blk.h
index 933e2b7c57..ce36c6e588 100644
--- a/examples/vhost_blk/vhost_blk.h
+++ b/examples/vhost_blk/vhost_blk.h
@@ -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;
diff --git a/examples/vhost_blk/vhost_blk_compat.c b/examples/vhost_blk/vhost_blk_compat.c
index 51a1be6b6d..f6de83a5e4 100644
--- a/examples/vhost_blk/vhost_blk_compat.c
+++ b/examples/vhost_blk/vhost_blk_compat.c
@@ -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;
 }
-- 
2.25.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
  2020-02-19 10:39 [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max Thomas Monjalon
@ 2020-02-20  2:52 ` Tiwei Bie
  2020-02-21 18:29   ` Thomas Monjalon
  2020-04-10 14:42 ` Maxime Coquelin
  1 sibling, 1 reply; 6+ messages in thread
From: Tiwei Bie @ 2020-02-20  2:52 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Maxime Coquelin, Zhihong Wang

On Wed, Feb 19, 2020 at 11:39:22AM +0100, Thomas Monjalon wrote:
> 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().
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  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 <tiwei.bie@intel.com>

Thanks,
Tiwei

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
  2020-02-20  2:52 ` Tiwei Bie
@ 2020-02-21 18:29   ` Thomas Monjalon
  2020-02-21 23:50     ` Tiwei Bie
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2020-02-21 18:29 UTC (permalink / raw)
  To: Maxime Coquelin; +Cc: dev, Zhihong Wang, Tiwei Bie

20/02/2020 03:52, Tiwei Bie:
> On Wed, Feb 19, 2020 at 11:39:22AM +0100, Thomas Monjalon wrote:
> > The macros RTE_MIN and RTE_MAX can be used in DPDK applications.

Only RTE_MIN is used in this patch. The title is wrong as well.


> > 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>
> > ---
> >  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 <tiwei.bie@intel.com>




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
  2020-02-21 18:29   ` Thomas Monjalon
@ 2020-02-21 23:50     ` Tiwei Bie
  2020-04-07 13:36       ` Maxime Coquelin
  0 siblings, 1 reply; 6+ messages in thread
From: Tiwei Bie @ 2020-02-21 23:50 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Maxime Coquelin, dev, Zhihong Wang

On Fri, Feb 21, 2020 at 07:29:13PM +0100, Thomas Monjalon wrote:
> 20/02/2020 03:52, Tiwei Bie:
> > On Wed, Feb 19, 2020 at 11:39:22AM +0100, Thomas Monjalon wrote:
> > > The macros RTE_MIN and RTE_MAX can be used in DPDK applications.
> 
> Only RTE_MIN is used in this patch. The title is wrong as well.

Make sense! The commit log should describe what's changed
by the patch exactly.

> 
> 
> > > 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>
> > > ---
> > >  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 <tiwei.bie@intel.com>
> 
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
  2020-02-21 23:50     ` Tiwei Bie
@ 2020-04-07 13:36       ` Maxime Coquelin
  0 siblings, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2020-04-07 13:36 UTC (permalink / raw)
  To: Tiwei Bie, Thomas Monjalon; +Cc: dev, Zhihong Wang



On 2/22/20 12:50 AM, Tiwei Bie wrote:
> On Fri, Feb 21, 2020 at 07:29:13PM +0100, Thomas Monjalon wrote:
>> 20/02/2020 03:52, Tiwei Bie:
>>> On Wed, Feb 19, 2020 at 11:39:22AM +0100, Thomas Monjalon wrote:
>>>> The macros RTE_MIN and RTE_MAX can be used in DPDK applications.
>>
>> Only RTE_MIN is used in this patch. The title is wrong as well.
> 
> Make sense! The commit log should describe what's changed
> by the patch exactly.
> 
>>
>>
>>>> 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>
>>>> ---
>>>>  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 <tiwei.bie@intel.com>
>>
>>
>>
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

I'll fixup the patch when applying.

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max
  2020-02-19 10:39 [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max Thomas Monjalon
  2020-02-20  2:52 ` Tiwei Bie
@ 2020-04-10 14:42 ` Maxime Coquelin
  1 sibling, 0 replies; 6+ messages in thread
From: Maxime Coquelin @ 2020-04-10 14:42 UTC (permalink / raw)
  To: Thomas Monjalon, dev; +Cc: Tiwei Bie, Zhihong Wang



On 2/19/20 11:39 AM, Thomas Monjalon wrote:
> 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().
> 
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-10 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 10:39 [dpdk-dev] [PATCH] examples/vhost_blk: use common macros for min/max Thomas Monjalon
2020-02-20  2:52 ` Tiwei Bie
2020-02-21 18:29   ` Thomas Monjalon
2020-02-21 23:50     ` Tiwei Bie
2020-04-07 13:36       ` Maxime Coquelin
2020-04-10 14:42 ` Maxime Coquelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).