mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Restructure vec_idx loops
This replaces empty for loops with while loops to make the code easier to read. Reviewed-by: Tom Caputi <tcaputi@datto.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reported-by: github.com/dcb314 Signed-off-by: Richard Laager <rlaager@wiktel.com> Closes #6681 Closes #6682 Closes #6683 Closes #8623
This commit is contained in:
parent
50478c6dad
commit
59f6594cf6
@ -266,7 +266,7 @@ sha1_digest_update_uio(SHA1_CTX *sha1_ctx, crypto_data_t *data)
|
||||
{
|
||||
off_t offset = data->cd_offset;
|
||||
size_t length = data->cd_length;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
size_t cur_len;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
@ -277,10 +277,11 @@ sha1_digest_update_uio(SHA1_CTX *sha1_ctx, crypto_data_t *data)
|
||||
* Jump to the first iovec containing data to be
|
||||
* digested.
|
||||
*/
|
||||
for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
|
||||
offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
offset -= data->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < data->cd_uio->uio_iovcnt &&
|
||||
offset >= data->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= data->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == data->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
@ -329,7 +330,7 @@ sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
|
||||
ulong_t digest_len, uchar_t *digest_scratch)
|
||||
{
|
||||
off_t offset = digest->cd_offset;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
|
||||
@ -339,10 +340,11 @@ sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
|
||||
* Jump to the first iovec containing ptr to the digest to
|
||||
* be returned.
|
||||
*/
|
||||
for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
|
||||
vec_idx < digest->cd_uio->uio_iovcnt;
|
||||
offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < digest->cd_uio->uio_iovcnt &&
|
||||
offset >= digest->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= digest->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == digest->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is
|
||||
@ -1095,7 +1097,7 @@ sha1_mac_verify_atomic(crypto_provider_handle_t provider,
|
||||
|
||||
case CRYPTO_DATA_UIO: {
|
||||
off_t offset = mac->cd_offset;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
off_t scratch_offset = 0;
|
||||
size_t length = digest_len;
|
||||
size_t cur_len;
|
||||
@ -1105,11 +1107,11 @@ sha1_mac_verify_atomic(crypto_provider_handle_t provider,
|
||||
return (CRYPTO_ARGUMENTS_BAD);
|
||||
|
||||
/* jump to the first iovec containing the expected digest */
|
||||
for (vec_idx = 0;
|
||||
offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
|
||||
vec_idx < mac->cd_uio->uio_iovcnt;
|
||||
offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < mac->cd_uio->uio_iovcnt &&
|
||||
offset >= mac->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= mac->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == mac->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is
|
||||
|
@ -292,7 +292,7 @@ sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
|
||||
{
|
||||
off_t offset = data->cd_offset;
|
||||
size_t length = data->cd_length;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
size_t cur_len;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
@ -303,10 +303,11 @@ sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
|
||||
* Jump to the first iovec containing data to be
|
||||
* digested.
|
||||
*/
|
||||
for (vec_idx = 0; vec_idx < data->cd_uio->uio_iovcnt &&
|
||||
offset >= data->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
offset -= data->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < data->cd_uio->uio_iovcnt &&
|
||||
offset >= data->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= data->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == data->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
@ -353,7 +354,7 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
|
||||
ulong_t digest_len, uchar_t *digest_scratch)
|
||||
{
|
||||
off_t offset = digest->cd_offset;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
if (digest->cd_uio->uio_segflg != UIO_SYSSPACE)
|
||||
@ -363,10 +364,11 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
|
||||
* Jump to the first iovec containing ptr to the digest to
|
||||
* be returned.
|
||||
*/
|
||||
for (vec_idx = 0; offset >= digest->cd_uio->uio_iov[vec_idx].iov_len &&
|
||||
vec_idx < digest->cd_uio->uio_iovcnt;
|
||||
offset -= digest->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < digest->cd_uio->uio_iovcnt &&
|
||||
offset >= digest->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= digest->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == digest->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is
|
||||
@ -1251,7 +1253,7 @@ sha2_mac_verify_atomic(crypto_provider_handle_t provider,
|
||||
|
||||
case CRYPTO_DATA_UIO: {
|
||||
off_t offset = mac->cd_offset;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
off_t scratch_offset = 0;
|
||||
size_t length = digest_len;
|
||||
size_t cur_len;
|
||||
@ -1261,11 +1263,11 @@ sha2_mac_verify_atomic(crypto_provider_handle_t provider,
|
||||
return (CRYPTO_ARGUMENTS_BAD);
|
||||
|
||||
/* jump to the first iovec containing the expected digest */
|
||||
for (vec_idx = 0;
|
||||
offset >= mac->cd_uio->uio_iov[vec_idx].iov_len &&
|
||||
vec_idx < mac->cd_uio->uio_iovcnt;
|
||||
offset -= mac->cd_uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < mac->cd_uio->uio_iovcnt &&
|
||||
offset >= mac->cd_uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= mac->cd_uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == mac->cd_uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is
|
||||
|
@ -269,7 +269,7 @@ skein_digest_update_uio(skein_ctx_t *ctx, const crypto_data_t *data)
|
||||
{
|
||||
off_t offset = data->cd_offset;
|
||||
size_t length = data->cd_length;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
size_t cur_len;
|
||||
const uio_t *uio = data->cd_uio;
|
||||
|
||||
@ -281,10 +281,11 @@ skein_digest_update_uio(skein_ctx_t *ctx, const crypto_data_t *data)
|
||||
* Jump to the first iovec containing data to be
|
||||
* digested.
|
||||
*/
|
||||
for (vec_idx = 0; vec_idx < uio->uio_iovcnt &&
|
||||
offset >= uio->uio_iov[vec_idx].iov_len;
|
||||
offset -= uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < uio->uio_iovcnt &&
|
||||
offset >= uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
@ -325,7 +326,7 @@ skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
crypto_req_handle_t req)
|
||||
{
|
||||
off_t offset = digest->cd_offset;
|
||||
uint_t vec_idx;
|
||||
uint_t vec_idx = 0;
|
||||
uio_t *uio = digest->cd_uio;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
@ -335,10 +336,11 @@ skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
/*
|
||||
* Jump to the first iovec containing ptr to the digest to be returned.
|
||||
*/
|
||||
for (vec_idx = 0; offset >= uio->uio_iov[vec_idx].iov_len &&
|
||||
vec_idx < uio->uio_iovcnt;
|
||||
offset -= uio->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
while (vec_idx < uio->uio_iovcnt &&
|
||||
offset >= uio->uio_iov[vec_idx].iov_len) {
|
||||
offset -= uio->uio_iov[vec_idx].iov_len;
|
||||
vec_idx++;
|
||||
}
|
||||
if (vec_idx == uio->uio_iovcnt) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
|
Loading…
Reference in New Issue
Block a user