]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drbd: use get_random_u64() where appropriate
authorDavid Carlier <devnexen@gmail.com>
Sun, 5 Apr 2026 15:47:04 +0000 (16:47 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 7 Apr 2026 12:27:39 +0000 (06:27 -0600)
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.

Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://patch.msgid.link/20260405154704.4610-1-devnexen@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c

index 200d464e984bbf017502019d76e2ca3161b8a3f7..b1a721dd0496999c29f80549f4e99270b1a53b55 100644 (file)
@@ -874,7 +874,7 @@ void drbd_gen_and_send_sync_uuid(struct drbd_peer_device *peer_device)
        if (uuid && uuid != UUID_JUST_CREATED)
                uuid = uuid + UUID_NEW_BM_OFFSET;
        else
-               get_random_bytes(&uuid, sizeof(u64));
+               uuid = get_random_u64();
        drbd_uuid_set(device, UI_BITMAP, uuid);
        drbd_print_uuids(device, "updated sync UUID");
        drbd_md_sync(device);
@@ -3337,7 +3337,7 @@ void drbd_uuid_new_current(struct drbd_device *device) __must_hold(local)
        u64 val;
        unsigned long long bm_uuid;
 
-       get_random_bytes(&val, sizeof(u64));
+       val = get_random_u64();
 
        spin_lock_irq(&device->ldev->md.uuid_lock);
        bm_uuid = device->ldev->md.uuid[UI_BITMAP];
index d997d274092cd4f4317dd8f2a6be2c3b2040723a..c2ac555473e7da1f721a960f053221b0bd36679e 100644 (file)
@@ -3236,7 +3236,7 @@ int drbd_adm_resume_io(struct sk_buff *skb, struct genl_info *info)
                         * matching real data uuid exists).
                         */
                        u64 val;
-                       get_random_bytes(&val, sizeof(u64));
+                       val = get_random_u64();
                        drbd_set_ed_uuid(device, val);
                        drbd_warn(device, "Resumed without access to data; please tear down before attempting to re-configure.\n");
                }