Who knows what kind of mount shenanigans people employ, let's gracefully
handle parse failures of proc files, like we alway do otherwsie.
int set_oom_score_adjust(int value) {
char t[DECIMAL_STR_MAX(int)];
+ if (!oom_score_adjust_is_valid(value))
+ return -EINVAL;
+
xsprintf(t, "%i", value);
return write_string_file("/proc/self/oom_score_adj", t,
delete_trailing_chars(t, WHITESPACE);
- assert_se(safe_atoi(t, &a) >= 0);
- assert_se(oom_score_adjust_is_valid(a));
+ r = safe_atoi(t, &a);
+ if (r < 0)
+ return r;
+
+ if (!oom_score_adjust_is_valid(a))
+ return -ENODATA;
if (ret)
*ret = a;
+
return 0;
}