Skip to contentSkip to conversation

vhost/crypto: fix build with asserts

PATCH Applied David Marchand 5 participants 5 messages Mar 5, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 lib/vhost/vhost_crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost_crypto.c +1 -1
index 8dd1806a39..3c6c5dc114 100644
@@ -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;
 }
 
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · David Marchand

../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")
---
  lib/vhost/vhost_crypto.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost_crypto.c +0 -0
index 8dd1806a39..3c6c5dc114 100644

lib/vhost/vhost_crypto.c virtio_crypto_asym_rsa_der_to_xform(uint8_t *der, size_t der_len, · line 541

Quoted 8 lines
lib/vhost/vhost_crypto.c +1 -1
@@ -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;
  }
 

Thanks,
Maxime

#2 lore raw

05/03/2025 10:48, Maxime Coquelin:

Quoted 34 lines · David Marchand
Quoted 32 lines

../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")
---
  lib/vhost/vhost_crypto.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost_crypto.c +0 -0
index 8dd1806a39..3c6c5dc114 100644
@@ -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;
 
Quoted 7 lines

lib/vhost/vhost_crypto.c virtio_crypto_asym_rsa_der_to_xform(uint8_t *der, size_t der_len, · line 541

Quoted 5 lines
lib/vhost/vhost_crypto.c +1 -1
-	RTE_ASSERT((tlv + len - &der[0]) == der_len);
+	RTE_ASSERT(tlv + len == der + der_len);
  	return 0;
  }
 

Applied, thanks.

Tested-by on v1 1/1
#4 lore raw
In reply to David Marchand
Quoted 26 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Wednesday, March 5, 2025 11:43 AM
To: [email protected]
Cc: Maxime Coquelin <[email protected]>; Chenbo Xia <[email protected]>; Akhil Goyal <[email protected]>; Gowrishankar Muthukrishnan <[email protected]>
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);
      |         ^~~~~~~~~~
Quoted 4 lines
Fixes d1b484bf1876 ("vhost/crypto: support asymmetric RSA")

---

Thanks!

- Ali