From 361d8b9350bb9fc2708df67f3543781ddccbec43 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 12 Oct 2015 15:49:02 +0000 Subject: [PATCH] Early return. llvm-svn: 250054 --- lld/ELF/InputFiles.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index e7d1d42c24f6..99c8704a0493 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -281,19 +281,19 @@ template void SharedFile::parseSoName() { this->initStringTable(); this->SoName = this->getName(); - if (DynamicSec) { - auto *Begin = - reinterpret_cast(Obj.base() + DynamicSec->sh_offset); - const Elf_Dyn *End = Begin + DynamicSec->sh_size / sizeof(Elf_Dyn); + if (!DynamicSec) + return; + auto *Begin = + reinterpret_cast(Obj.base() + DynamicSec->sh_offset); + const Elf_Dyn *End = Begin + DynamicSec->sh_size / sizeof(Elf_Dyn); - for (const Elf_Dyn &Dyn : make_range(Begin, End)) { - if (Dyn.d_tag == DT_SONAME) { - uintX_t Val = Dyn.getVal(); - if (Val >= this->StringTable.size()) - error("Invalid DT_SONAME entry"); - this->SoName = StringRef(this->StringTable.data() + Val); - break; - } + for (const Elf_Dyn &Dyn : make_range(Begin, End)) { + if (Dyn.d_tag == DT_SONAME) { + uintX_t Val = Dyn.getVal(); + if (Val >= this->StringTable.size()) + error("Invalid DT_SONAME entry"); + this->SoName = StringRef(this->StringTable.data() + Val); + return; } } }