Skip to content

Commit

Permalink
fix signed integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AttilaFueloep committed Dec 19, 2019
1 parent 45ee01e commit f488b0e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions module/icp/algs/modes/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ gcm_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
* Handle the "cycle" implementation by creating avx and non avx
* contexts alternately.
*/
if (GCM_IMPL_READ(icp_gcm_impl) != IMPL_CYCLE) {
if (GCM_IMPL_READ(icp_gcm_impl) != (uint32_t)IMPL_CYCLE) {
gcm_ctx->gcm_use_avx = GCM_IMPL_USE_AVX;
} else {
gcm_ctx->gcm_use_avx = gcm_toggle_avx();
Expand Down Expand Up @@ -679,7 +679,7 @@ gmac_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
* Handle the "cycle" implementation by creating avx and non avx
* contexts alternately.
*/
if (GCM_IMPL_READ(icp_gcm_impl) != IMPL_CYCLE) {
if (GCM_IMPL_READ(icp_gcm_impl) != (uint32_t)IMPL_CYCLE) {
gcm_ctx->gcm_use_avx = GCM_IMPL_USE_AVX;
} else {
gcm_ctx->gcm_use_avx = gcm_toggle_avx();
Expand Down Expand Up @@ -889,7 +889,8 @@ gcm_impl_set(const char *val)
for (i = 0; i < ARRAY_SIZE(gcm_impl_opts); i++) {
#if defined(__x86_64__) && defined(HAVE_AVX)
/* Ignore avx implementation if it won't work */
if (gcm_impl_opts[i].sel == IMPL_AVX && !gcm_avx_will_work()) {
if (gcm_impl_opts[i].sel == (uint32_t)IMPL_AVX &&
!gcm_avx_will_work()) {
continue;
}
#endif
Expand All @@ -914,7 +915,7 @@ gcm_impl_set(const char *val)
#if defined(__x86_64__) && defined(HAVE_AVX)
/* FIXME: Should we make `avx` the `fastest` implementation? */
if (gcm_avx_will_work() == B_TRUE &&
(impl == IMPL_AVX || impl == IMPL_FASTEST)) {
(impl == (uint32_t)IMPL_AVX || impl == (uint32_t)IMPL_FASTEST)) {
gcm_set_avx(B_TRUE);
} else {
gcm_set_avx(B_FALSE);
Expand Down Expand Up @@ -952,7 +953,8 @@ icp_gcm_impl_get(char *buffer, zfs_kernel_param_t *kp)
for (i = 0; i < ARRAY_SIZE(gcm_impl_opts); i++) {
#if defined(__x86_64__) && defined(HAVE_AVX)
/* Ignore avx implementation if it won't work */
if (gcm_impl_opts[i].sel == IMPL_AVX && !gcm_avx_will_work()) {
if (gcm_impl_opts[i].sel == (uint32_t)IMPL_AVX &&
!gcm_avx_will_work()) {
continue;
}
#endif
Expand Down

0 comments on commit f488b0e

Please sign in to comment.