Skip to content

Commit 091aa11

Browse files
committed
genksyms: reduce indentation in export_symbol()
Modify this function to return earlier when find_symbol() returns NULL, reducing the level of improve readability. No functional changes are intended. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 2b1bd50 commit 091aa11

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

scripts/genksyms/genksyms.c

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -632,54 +632,55 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
632632
void export_symbol(const char *name)
633633
{
634634
struct symbol *sym;
635+
unsigned long crc;
636+
int has_changed = 0;
635637

636638
sym = find_symbol(name, SYM_NORMAL, 0);
637-
if (!sym)
639+
if (!sym) {
638640
error_with_pos("export undefined symbol %s", name);
639-
else {
640-
unsigned long crc;
641-
int has_changed = 0;
641+
return;
642+
}
642643

643-
if (flag_dump_defs)
644-
fprintf(debugfile, "Export %s == <", name);
644+
if (flag_dump_defs)
645+
fprintf(debugfile, "Export %s == <", name);
645646

646-
expansion_trail = (struct symbol *)-1L;
647+
expansion_trail = (struct symbol *)-1L;
647648

648-
sym->expansion_trail = expansion_trail;
649-
expansion_trail = sym;
650-
crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff;
649+
sym->expansion_trail = expansion_trail;
650+
expansion_trail = sym;
651+
crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff;
651652

652-
sym = expansion_trail;
653-
while (sym != (struct symbol *)-1L) {
654-
struct symbol *n = sym->expansion_trail;
653+
sym = expansion_trail;
654+
while (sym != (struct symbol *)-1L) {
655+
struct symbol *n = sym->expansion_trail;
655656

656-
if (sym->status != STATUS_UNCHANGED) {
657-
if (!has_changed) {
658-
print_location();
659-
fprintf(stderr, "%s: %s: modversion "
660-
"changed because of changes "
661-
"in ", flag_preserve ? "error" :
662-
"warning", name);
663-
} else
664-
fprintf(stderr, ", ");
665-
print_type_name(sym->type, sym->name);
666-
if (sym->status == STATUS_DEFINED)
667-
fprintf(stderr, " (became defined)");
668-
has_changed = 1;
669-
if (flag_preserve)
670-
errors++;
657+
if (sym->status != STATUS_UNCHANGED) {
658+
if (!has_changed) {
659+
print_location();
660+
fprintf(stderr,
661+
"%s: %s: modversion changed because of changes in ",
662+
flag_preserve ? "error" : "warning",
663+
name);
664+
} else {
665+
fprintf(stderr, ", ");
671666
}
672-
sym->expansion_trail = 0;
673-
sym = n;
667+
print_type_name(sym->type, sym->name);
668+
if (sym->status == STATUS_DEFINED)
669+
fprintf(stderr, " (became defined)");
670+
has_changed = 1;
671+
if (flag_preserve)
672+
errors++;
674673
}
675-
if (has_changed)
676-
fprintf(stderr, "\n");
674+
sym->expansion_trail = 0;
675+
sym = n;
676+
}
677+
if (has_changed)
678+
fprintf(stderr, "\n");
677679

678-
if (flag_dump_defs)
679-
fputs(">\n", debugfile);
680+
if (flag_dump_defs)
681+
fputs(">\n", debugfile);
680682

681-
printf("#SYMVER %s 0x%08lx\n", name, crc);
682-
}
683+
printf("#SYMVER %s 0x%08lx\n", name, crc);
683684
}
684685

685686
/*----------------------------------------------------------------------*/

0 commit comments

Comments
 (0)