vhost/crypto: fix build with gcc 4.7.2

Build error has been reported by Intel build system:
SUSE12SP3_64 / Linux 3.7.10-1 / GCC 4.7.2
lib/librte_vhost/vhost_crypto.c: In function ‘rte_vhost_crypto_set_zero_copy’:
lib/librte_vhost/vhost_crypto.c:1192:2: error:
comparison of unsigned expression < 0 is always false

As enums can be either signed or unsigned, this patch removes
the negative check and cast to unsigned the upper limit check.

Fixes: 939066d96563 ("vhost/crypto: add public function implementation")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
This commit is contained in:
Maxime Coquelin 2018-04-27 11:04:38 +02:00 committed by Thomas Monjalon
parent a5c9b9278c
commit 996096e629

View File

@ -1189,8 +1189,8 @@ rte_vhost_crypto_set_zero_copy(int vid, enum rte_vhost_crypto_zero_copy option)
return -EINVAL;
}
if (unlikely(option < 0 || option >=
RTE_VHOST_CRYPTO_MAX_ZERO_COPY_OPTIONS)) {
if (unlikely((uint32_t)option >=
RTE_VHOST_CRYPTO_MAX_ZERO_COPY_OPTIONS)) {
VC_LOG_ERR("Invalid option %i", option);
return -EINVAL;
}