cppcheck: (error) Uninitialized variable
Resolve the following uninitialized variable warnings. In practice these were unreachable due to the goto. Replacing the goto with a return resolves the warning and yields more readable code. [module/icp/algs/modes/ccm.c:892]: (error) Uninitialized variable: ccm_param [module/icp/algs/modes/ccm.c:893]: (error) Uninitialized variable: ccm_param [module/icp/algs/modes/gcm.c:564]: (error) Uninitialized variable: gcm_param [module/icp/algs/modes/gcm.c:565]: (error) Uninitialized variable: gcm_param [module/icp/algs/modes/gcm.c:599]: (error) Uninitialized variable: gmac_param [module/icp/algs/modes/gcm.c:600]: (error) Uninitialized variable: gmac_param Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #9732
This commit is contained in:
parent
78072b7936
commit
bf01567e4e
|
@ -885,15 +885,13 @@ ccm_init_ctx(ccm_ctx_t *ccm_ctx, char *param, int kmflag,
|
||||||
|
|
||||||
ccm_ctx->ccm_flags |= CCM_MODE;
|
ccm_ctx->ccm_flags |= CCM_MODE;
|
||||||
} else {
|
} else {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
return (CRYPTO_MECHANISM_PARAM_INVALID);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccm_init(ccm_ctx, ccm_param->nonce, ccm_param->ulNonceSize,
|
if (ccm_init(ccm_ctx, ccm_param->nonce, ccm_param->ulNonceSize,
|
||||||
ccm_param->authData, ccm_param->ulAuthDataSize, block_size,
|
ccm_param->authData, ccm_param->ulAuthDataSize, block_size,
|
||||||
encrypt_block, xor_block) != 0) {
|
encrypt_block, xor_block) != 0) {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
return (CRYPTO_MECHANISM_PARAM_INVALID);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
if (!is_encrypt_init) {
|
if (!is_encrypt_init) {
|
||||||
/* allocate buffer for storing decrypted plaintext */
|
/* allocate buffer for storing decrypted plaintext */
|
||||||
|
@ -903,7 +901,6 @@ ccm_init_ctx(ccm_ctx_t *ccm_ctx, char *param, int kmflag,
|
||||||
rv = CRYPTO_HOST_MEMORY;
|
rv = CRYPTO_HOST_MEMORY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -553,8 +553,7 @@ gcm_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
|
||||||
rv = CRYPTO_SUCCESS;
|
rv = CRYPTO_SUCCESS;
|
||||||
gcm_ctx->gcm_flags |= GCM_MODE;
|
gcm_ctx->gcm_flags |= GCM_MODE;
|
||||||
} else {
|
} else {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
return (CRYPTO_MECHANISM_PARAM_INVALID);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gcm_init(gcm_ctx, gcm_param->pIv, gcm_param->ulIvLen,
|
if (gcm_init(gcm_ctx, gcm_param->pIv, gcm_param->ulIvLen,
|
||||||
|
@ -562,7 +561,7 @@ gcm_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
|
||||||
encrypt_block, copy_block, xor_block) != 0) {
|
encrypt_block, copy_block, xor_block) != 0) {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,8 +587,7 @@ gmac_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
|
||||||
rv = CRYPTO_SUCCESS;
|
rv = CRYPTO_SUCCESS;
|
||||||
gcm_ctx->gcm_flags |= GMAC_MODE;
|
gcm_ctx->gcm_flags |= GMAC_MODE;
|
||||||
} else {
|
} else {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
return (CRYPTO_MECHANISM_PARAM_INVALID);
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gcm_init(gcm_ctx, gmac_param->pIv, AES_GMAC_IV_LEN,
|
if (gcm_init(gcm_ctx, gmac_param->pIv, AES_GMAC_IV_LEN,
|
||||||
|
@ -597,7 +595,7 @@ gmac_init_ctx(gcm_ctx_t *gcm_ctx, char *param, size_t block_size,
|
||||||
encrypt_block, copy_block, xor_block) != 0) {
|
encrypt_block, copy_block, xor_block) != 0) {
|
||||||
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
rv = CRYPTO_MECHANISM_PARAM_INVALID;
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue