mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
net: use get_random_u{16,32,64}() where appropriate
Use the typed random integer helpers instead of get_random_bytes() when filling a single integer variable. The helpers return the value directly, require no pointer or size argument, and better express intent. Skipped sites writing into __be16 (netdevsim) and __le64 (ceph) fields where a direct assignment would trigger sparse endianness warnings. Signed-off-by: David Carlier <devnexen@gmail.com> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260407150758.5889-1-devnexen@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
581d28606c
commit
9addea5d44
@@ -94,7 +94,7 @@ static void nsim_dev_psample_md_prepare(const struct nsim_dev_psample *psample,
|
||||
if (psample->out_tc_occ_max) {
|
||||
u64 out_tc_occ;
|
||||
|
||||
get_random_bytes(&out_tc_occ, sizeof(u64));
|
||||
out_tc_occ = get_random_u64();
|
||||
md->out_tc_occ = out_tc_occ & (psample->out_tc_occ_max - 1);
|
||||
md->out_tc_occ_valid = 1;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ static void nsim_dev_psample_md_prepare(const struct nsim_dev_psample *psample,
|
||||
if (psample->latency_max) {
|
||||
u64 latency;
|
||||
|
||||
get_random_bytes(&latency, sizeof(u64));
|
||||
latency = get_random_u64();
|
||||
md->latency = latency & (psample->latency_max - 1);
|
||||
md->latency_valid = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user