tools/sched_ext: Fix get_prandom_u64() prototype
PATCH 1/1 tools/sched_ext: Fix get_prandom_u64() prototype
In C99 (Sec 6.7.5.3), an empty parameter list in a declaration leaves the parameter types unspecified (K&R style), not explicitly zero. Consequently, the compiler would silently accept arbitrary arguments passed to the function.
Declare the function with (void) to form a proper prototype asserting it takes no arguments.
--- tools/sched_ext/include/scx/common.bpf.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tools/sched_ext/include/scx/common.bpf.h +1 -3
@@ -621,7 +621,6 @@ static inline bool time_in_range_open(u64 a, u64 b, u64 c)return time_after_eq (a, b) &&time_before (a, c); } -/* * Other helpers */
@@ -870,11 +869,10 @@ static inline u64 scale_by_task_weight_inverse(const struct task_struct *p, u64return value *100 / p->scx.weight; } -/* * Get a random u64 from the kernel's pseudo-random generator. */ -static inline u64 get_prandom_u64 () +static inline u64 get_prandom_u64 (void ) {return ((u64 )bpf_get_prandom_u32 () <<32 ) |bpf_get_prandom_u32 (); }
Signature · 1 line
2.48.1
Andrea Righi
reviewerHi,
Quoted 9 lines · Cheng-Yang Chou
In C99 (Sec 6.7.5.3), an empty parameter list in a declaration leaves the parameter types unspecified (K&R style), not explicitly zero. Consequently, the compiler would silently accept arbitrary arguments passed to the function.
Declare the function with (void) to form a proper prototype asserting it takes no arguments.
Signed-off-by Cheng-Yang Chou <[email protected]>
I understand the motivation, but changes like this don't fix real issues or provide any measurable benefit. Patches consume maintainer and reviewer bandwidth, so it's usually best to focus on changes that fix real bugs or provide clear improvements.
If you encounter a real issue or can show a measurable improvement (with traces or numbers), patches addressing that would be much more useful.
Thanks,
-Andrea
Quoted 32 lines
--- tools/sched_ext/include/scx/common.bpf.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)tools/sched_ext/include/scx/common.bpf.h +1
-3@@ -621,7 +621,6 @@ static inline bool time_in_range_open(u64 a, u64 b, u64 c)return time_after_eq (a, b) &&time_before (a, c); } -/* * Other helpers */ @@ -870,11 +869,10 @@ static inline u64 scale_by_task_weight_inverse(const struct task_struct *p, u64return value *100 / p->scx.weight; } -/* * Get a random u64 from the kernel's pseudo-random generator. */ -static inline u64 get_prandom_u64 () +static inline u64 get_prandom_u64 (void ) {return ((u64 )bpf_get_prandom_u32 () <<32 ) |bpf_get_prandom_u32 (); }Signature · 1 line
2.48.1
Quoted 18 lines · Andrea Righi
Hi,
Quoted 9 lines · Cheng-Yang Chou
In C99 (Sec 6.7.5.3), an empty parameter list in a declaration leaves the parameter types unspecified (K&R style), not explicitly zero. Consequently, the compiler would silently accept arbitrary arguments passed to the function.
Declare the function with (void) to form a proper prototype asserting it takes no arguments.
Signed-off-by Cheng-Yang Chou <[email protected]>I understand the motivation, but changes like this don't fix real issues or provide any measurable benefit. Patches consume maintainer and reviewer bandwidth, so it's usually best to focus on changes that fix real bugs or provide clear improvements.
Quoted 5 lines
If you encounter a real issue or can show a measurable improvement (with traces or numbers), patches addressing that would be much more useful.
Thanks,
-Andrea
Understood.
Again, thanks for the explaination.
Signature · 2 lines
Thanks, Cheng-Yang