Skip to content

Commit

Permalink
random: use proper return types on get_random_{int,long}_wait()
Browse files Browse the repository at this point in the history
commit 7c3a8a1 upstream.

Before these were returning signed values, but the API is intended to be
used with unsigned values.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zx2c4 authored and gregkh committed May 30, 2022
1 parent 1fdd7ee commit 33783ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/linux/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ static inline int get_random_bytes_wait(void *buf, size_t nbytes)
return ret;
}

#define declare_get_random_var_wait(var) \
static inline int get_random_ ## var ## _wait(var *out) { \
#define declare_get_random_var_wait(name, ret_type) \
static inline int get_random_ ## name ## _wait(ret_type *out) { \
int ret = wait_for_random_bytes(); \
if (unlikely(ret)) \
return ret; \
*out = get_random_ ## var(); \
*out = get_random_ ## name(); \
return 0; \
}
declare_get_random_var_wait(u32)
declare_get_random_var_wait(u64)
declare_get_random_var_wait(int)
declare_get_random_var_wait(long)
declare_get_random_var_wait(u32, u32)
declare_get_random_var_wait(u64, u32)
declare_get_random_var_wait(int, unsigned int)
declare_get_random_var_wait(long, unsigned long)
#undef declare_get_random_var

/*
Expand Down

0 comments on commit 33783ca

Please sign in to comment.