Skip to content

Commit c9f2b8d

Browse files
committed
modpost: remove unreachable code after fatal()
Now compilers can recognize fatal() never returns. While GCC 4.5 dropped support for -Wunreachable-code, Clang is capable of detecting the unreachable code. $ make HOSTCC=clang HOSTCFLAGS=-Wunreachable-code-return [snip] HOSTCC scripts/mod/modpost.o scripts/mod/modpost.c:520:11: warning: 'return' will never be executed [-Wunreachable-code-return] return 0; ^ scripts/mod/modpost.c:477:10: warning: 'return' will never be executed [-Wunreachable-code-return] return 0; ^ 2 warnings generated. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
1 parent 5cac96f commit c9f2b8d

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

scripts/mod/modpost.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,9 @@ static int parse_elf(struct elf_info *info, const char *filename)
476476
fatal("%s: not relocatable object.", filename);
477477

478478
/* Check if file offset is correct */
479-
if (hdr->e_shoff > info->size) {
479+
if (hdr->e_shoff > info->size)
480480
fatal("section header offset=%lu in file '%s' is bigger than filesize=%zu\n",
481481
(unsigned long)hdr->e_shoff, filename, info->size);
482-
return 0;
483-
}
484482

485483
if (hdr->e_shnum == SHN_UNDEF) {
486484
/*
@@ -518,12 +516,11 @@ static int parse_elf(struct elf_info *info, const char *filename)
518516
const char *secname;
519517
int nobits = sechdrs[i].sh_type == SHT_NOBITS;
520518

521-
if (!nobits && sechdrs[i].sh_offset > info->size) {
519+
if (!nobits && sechdrs[i].sh_offset > info->size)
522520
fatal("%s is truncated. sechdrs[i].sh_offset=%lu > sizeof(*hrd)=%zu\n",
523521
filename, (unsigned long)sechdrs[i].sh_offset,
524522
sizeof(*hdr));
525-
return 0;
526-
}
523+
527524
secname = secstrings + sechdrs[i].sh_name;
528525
if (strcmp(secname, ".modinfo") == 0) {
529526
if (nobits)

0 commit comments

Comments
 (0)