vhost/crypto: fix build with asserts

Message ID 20250305094323.598983-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vhost/crypto: fix build with asserts |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

David Marchand March 5, 2025, 9:43 a.m. UTC
../lib/vhost/vhost_crypto.c: In function ‘virtio_crypto_asym_rsa_der_to_xform’:
../lib/vhost/vhost_crypto.c:538:42: warning: comparison of integer expressions
	of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’}
	[-Wsign-compare]
  538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
      |                                          ^~
../lib/eal/include/rte_branch_prediction.h:43:45: note: in definition of macro
	‘unlikely’
   43 | #define unlikely(x)     __builtin_expect(!!(x), 0)
      |                                             ^
../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
   47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
      |                         ^~~~~~~~~~
../lib/vhost/vhost_crypto.c:538:9: note: in expansion of macro ‘RTE_ASSERT’
  538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
      |         ^~~~~~~~~~

Fixes: d1b484bf1876 ("vhost/crypto: support asymmetric RSA")

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/vhost/vhost_crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Maxime Coquelin March 5, 2025, 9:48 a.m. UTC | #1
On 3/5/25 10:43 AM, David Marchand wrote:
> ../lib/vhost/vhost_crypto.c: In function ‘virtio_crypto_asym_rsa_der_to_xform’:
> ../lib/vhost/vhost_crypto.c:538:42: warning: comparison of integer expressions
> 	of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’}
> 	[-Wsign-compare]
>    538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
>        |                                          ^~
> ../lib/eal/include/rte_branch_prediction.h:43:45: note: in definition of macro
> 	‘unlikely’
>     43 | #define unlikely(x)     __builtin_expect(!!(x), 0)
>        |                                             ^
> ../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
>     47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
>        |                         ^~~~~~~~~~
> ../lib/vhost/vhost_crypto.c:538:9: note: in expansion of macro ‘RTE_ASSERT’
>    538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
>        |         ^~~~~~~~~~
> 
> Fixes: d1b484bf1876 ("vhost/crypto: support asymmetric RSA")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>   lib/vhost/vhost_crypto.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
> index 8dd1806a39..3c6c5dc114 100644
> --- a/lib/vhost/vhost_crypto.c
> +++ b/lib/vhost/vhost_crypto.c
> @@ -535,7 +535,7 @@ virtio_crypto_asym_rsa_der_to_xform(uint8_t *der, size_t der_len,
>   	xform->rsa.qt.qInv.data = qinv;
>   	xform->rsa.qt.qInv.length = qinvlen;
>   
> -	RTE_ASSERT((tlv + len - &der[0]) == der_len);
> +	RTE_ASSERT(tlv + len == der + der_len);
>   	return 0;
>   }
>   

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

Thanks,
Maxime
  
Gowrishankar Muthukrishnan March 5, 2025, 9:54 a.m. UTC | #2
> 
> Fixes: d1b484bf1876 ("vhost/crypto: support asymmetric RSA")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Tested-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
  
Ali Alnubani March 5, 2025, 10:43 a.m. UTC | #3
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Wednesday, March 5, 2025 11:43 AM
> To: dev@dpdk.org
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Chenbo Xia
> <chenbox@nvidia.com>; Akhil Goyal <gakhil@marvell.com>; Gowrishankar
> Muthukrishnan <gmuthukrishn@marvell.com>
> Subject: [PATCH] vhost/crypto: fix build with asserts
> 
> ../lib/vhost/vhost_crypto.c: In function ‘virtio_crypto_asym_rsa_der_to_xform’:
> ../lib/vhost/vhost_crypto.c:538:42: warning: comparison of integer expressions
> 	of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’}
> 	[-Wsign-compare]
>   538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
>       |                                          ^~
> ../lib/eal/include/rte_branch_prediction.h:43:45: note: in definition of macro
> 	‘unlikely’
>    43 | #define unlikely(x)     __builtin_expect(!!(x), 0)
>       |                                             ^
> ../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
>    47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
>       |                         ^~~~~~~~~~
> ../lib/vhost/vhost_crypto.c:538:9: note: in expansion of macro ‘RTE_ASSERT’
>   538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
>       |         ^~~~~~~~~~
> 
> Fixes: d1b484bf1876 ("vhost/crypto: support asymmetric RSA")
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---

Tested-by: Ali Alnubani <alialnu@nvidia.com>

Thanks!

- Ali
  
Thomas Monjalon March 5, 2025, 11 a.m. UTC | #4
05/03/2025 10:48, Maxime Coquelin:
> 
> On 3/5/25 10:43 AM, David Marchand wrote:
> > ../lib/vhost/vhost_crypto.c: In function ‘virtio_crypto_asym_rsa_der_to_xform’:
> > ../lib/vhost/vhost_crypto.c:538:42: warning: comparison of integer expressions
> > 	of different signedness: ‘long int’ and ‘size_t’ {aka ‘long unsigned int’}
> > 	[-Wsign-compare]
> >    538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
> >        |                                          ^~
> > ../lib/eal/include/rte_branch_prediction.h:43:45: note: in definition of macro
> > 	‘unlikely’
> >     43 | #define unlikely(x)     __builtin_expect(!!(x), 0)
> >        |                                             ^
> > ../lib/eal/include/rte_debug.h:47:25: note: in expansion of macro ‘RTE_VERIFY’
> >     47 | #define RTE_ASSERT(exp) RTE_VERIFY(exp)
> >        |                         ^~~~~~~~~~
> > ../lib/vhost/vhost_crypto.c:538:9: note: in expansion of macro ‘RTE_ASSERT’
> >    538 |         RTE_ASSERT((tlv + len - &der[0]) == der_len);
> >        |         ^~~~~~~~~~
> > 
> > Fixes: d1b484bf1876 ("vhost/crypto: support asymmetric RSA")
> > 
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> >   lib/vhost/vhost_crypto.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
> > index 8dd1806a39..3c6c5dc114 100644
> > --- a/lib/vhost/vhost_crypto.c
> > +++ b/lib/vhost/vhost_crypto.c
> > @@ -535,7 +535,7 @@ virtio_crypto_asym_rsa_der_to_xform(uint8_t *der, size_t der_len,
> >   	xform->rsa.qt.qInv.data = qinv;
> >   	xform->rsa.qt.qInv.length = qinvlen;
> >   
> > -	RTE_ASSERT((tlv + len - &der[0]) == der_len);
> > +	RTE_ASSERT(tlv + len == der + der_len);
> >   	return 0;
> >   }
> >   
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied, thanks.
  

Patch

diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c
index 8dd1806a39..3c6c5dc114 100644
--- a/lib/vhost/vhost_crypto.c
+++ b/lib/vhost/vhost_crypto.c
@@ -535,7 +535,7 @@  virtio_crypto_asym_rsa_der_to_xform(uint8_t *der, size_t der_len,
 	xform->rsa.qt.qInv.data = qinv;
 	xform->rsa.qt.qInv.length = qinvlen;
 
-	RTE_ASSERT((tlv + len - &der[0]) == der_len);
+	RTE_ASSERT(tlv + len == der + der_len);
 	return 0;
 }