On Fri, 2025-06-27 at 15:43 +0100, Mykyta Yatsenko wrote: > From: Mykyta Yatsenko <yatsenko@xxxxxxxx> > > Return error if preset parsing fails. Avoid proceeding with veristat run > if preset does not parse. > Before: > ``` > ./veristat set_global_vars.bpf.o -G "arr[999999999999999999999] = 1" > Failed to parse value '999999999999999999999' > Processing 'set_global_vars.bpf.o'... > File Program Verdict Duration (us) Insns States Program size Jited size > --------------------- ---------------- ------- ------------- ----- ------ ------------ ---------- > set_global_vars.bpf.o test_set_globals success 27 64 0 82 0 > --------------------- ---------------- ------- ------------- ----- ------ ------------ ---------- > Done. Processed 1 files, 0 programs. Skipped 1 files, 0 programs. > ``` > After: > ``` > ./veristat set_global_vars.bpf.o -G "arr[999999999999999999999] = 1" > Failed to parse value '999999999999999999999' > Failed to parse global variable presets: arr[999999999999999999999] = 1 > ``` > > Improve error messages: > * If preset struct member can't be found. > * Array index out of bounds > > Extract rtrim function. > > Signed-off-by: Mykyta Yatsenko <yatsenko@xxxxxxxx> > --- Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> > @@ -1955,6 +1967,8 @@ static int adjust_var_secinfo(struct btf *btf, const struct btf_type *t, > break; > case FIELD_NAME: > err = adjust_var_secinfo_member(btf, base_type, 0, atom->name, sinfo); > + if (err == -ESRCH) > + fprintf(stderr, "Can't find '%s'\n", atom->name); Nit: adjust_var_secinfo_member() already reports a few errors, maybe report this error there as well? > prev_name = atom->name; > break; > default: