Skip to content

Commit b70b073

Browse files
t-8chborkmann
authored andcommitted
tools/resolve_btfids: Add --fatal_warnings option
Currently warnings emitted by resolve_btfids are buried in the build log and are slipping into mainline frequently. Add an option to elevate warnings to hard errors so the CI bots can catch any new warnings. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 4d33dc1 commit b70b073

File tree

1 file changed

+10
-2
lines changed
  • tools/bpf/resolve_btfids

1 file changed

+10
-2
lines changed

tools/bpf/resolve_btfids/main.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ struct object {
141141
};
142142

143143
static int verbose;
144+
static int warnings;
144145

145146
static int eprintf(int level, int var, const char *fmt, ...)
146147
{
@@ -604,6 +605,7 @@ static int symbols_resolve(struct object *obj)
604605
if (id->id) {
605606
pr_info("WARN: multiple IDs found for '%s': %d, %d - using %d\n",
606607
str, id->id, type_id, id->id);
608+
warnings++;
607609
} else {
608610
id->id = type_id;
609611
(*nr)--;
@@ -625,8 +627,10 @@ static int id_patch(struct object *obj, struct btf_id *id)
625627
int i;
626628

627629
/* For set, set8, id->id may be 0 */
628-
if (!id->id && !id->is_set && !id->is_set8)
630+
if (!id->id && !id->is_set && !id->is_set8) {
629631
pr_err("WARN: resolve_btfids: unresolved symbol %s\n", id->name);
632+
warnings++;
633+
}
630634

631635
for (i = 0; i < id->addr_cnt; i++) {
632636
unsigned long addr = id->addr[i];
@@ -782,13 +786,16 @@ int main(int argc, const char **argv)
782786
.funcs = RB_ROOT,
783787
.sets = RB_ROOT,
784788
};
789+
bool fatal_warnings = false;
785790
struct option btfid_options[] = {
786791
OPT_INCR('v', "verbose", &verbose,
787792
"be more verbose (show errors, etc)"),
788793
OPT_STRING(0, "btf", &obj.btf, "BTF data",
789794
"BTF data"),
790795
OPT_STRING('b', "btf_base", &obj.base_btf_path, "file",
791796
"path of file providing base BTF"),
797+
OPT_BOOLEAN(0, "fatal_warnings", &fatal_warnings,
798+
"turn warnings into errors"),
792799
OPT_END()
793800
};
794801
int err = -1;
@@ -823,7 +830,8 @@ int main(int argc, const char **argv)
823830
if (symbols_patch(&obj))
824831
goto out;
825832

826-
err = 0;
833+
if (!(fatal_warnings && warnings))
834+
err = 0;
827835
out:
828836
if (obj.efile.elf) {
829837
elf_end(obj.efile.elf);

0 commit comments

Comments
 (0)