From 657279109a503e754c426d8f72f7a61aad3d8281 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Sat, 19 Aug 2023 18:32:41 +0100 Subject: [PATCH] uclampset: Remove validation logic While experimenting with a potential extension to uclamp; I realized I had to modify uclampset to be able to use this extension, which is not scalable. Since the syscall will do checks anyway, drop the validation logic and let the kernel do its work without duplication that can potentially get stale. Use more magic value for NOT_SET define. We do have uclamp_set_set flag to verify if the value is valid anyway, so this is extra paranoia. Signed-off-by: Qais Yousef --- schedutils/uclampset.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/schedutils/uclampset.c b/schedutils/uclampset.c index 0de806abcf..011fac4ae4 100644 --- a/schedutils/uclampset.c +++ b/schedutils/uclampset.c @@ -31,7 +31,7 @@ #include "sched_attr.h" #include "strutils.h" -#define NOT_SET -2U +#define NOT_SET 0xdeadbeef struct uclampset { unsigned int util_min; @@ -211,14 +211,6 @@ static void set_uclamp_system(struct uclampset *ctl) write_uclamp_sysfs(_PATH_PROC_UCLAMP_MAX, ctl->util_max); } -static void validate_util(int val) -{ - if (val > 1024 || val < -1) { - errno = EINVAL; - err(EXIT_FAILURE, _("%d out of range"), val); - } -} - int main(int argc, char **argv) { struct uclampset _ctl = { @@ -268,12 +260,10 @@ int main(int argc, char **argv) case 'm': ctl->util_min = strtos32_or_err(optarg, _("invalid util_min argument")); ctl->util_min_set = 1; - validate_util(ctl->util_min); break; case 'M': ctl->util_max = strtos32_or_err(optarg, _("invalid util_max argument")); ctl->util_max_set = 1; - validate_util(ctl->util_max); break; case 'V': print_version(EXIT_SUCCESS); -- 2.47.3