mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
hwrng: virtio - use min() in copy_data()
Use the simpler min() macro since all values are unsigned and compatible. The subtraction avail - vi->data_idx is also guaranteed to be positive by the preceding check. Signed-off-by: Thorsten Blum <blum@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b5c2df4297
commit
468dd85acf
|
|
@ -81,13 +81,13 @@ static unsigned int copy_data(struct virtrng_info *vi, void *buf,
|
|||
* steered into adjacent slab memory, including under
|
||||
* speculation.
|
||||
*/
|
||||
avail = min_t(unsigned int, vi->data_avail, sizeof(vi->data));
|
||||
avail = min(vi->data_avail, sizeof(vi->data));
|
||||
if (vi->data_idx >= avail) {
|
||||
vi->data_avail = 0;
|
||||
request_entropy(vi);
|
||||
return 0;
|
||||
}
|
||||
size = min_t(unsigned int, size, avail - vi->data_idx);
|
||||
size = min(size, avail - vi->data_idx);
|
||||
idx = array_index_nospec(vi->data_idx, sizeof(vi->data));
|
||||
memcpy(buf, vi->data + idx, size);
|
||||
vi->data_idx += size;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user