[lld] r233450 - ELF: make scopes of error code varaibles narrower.

Rui Ueyama ruiu at google.com
Fri Mar 27 16:30:39 PDT 2015


Author: ruiu
Date: Fri Mar 27 18:30:38 2015
New Revision: 233450

URL: http://llvm.org/viewvc/llvm-project?rev=233450&view=rev
Log:
ELF: make scopes of error code varaibles narrower.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h

Modified: lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h?rev=233450&r1=233449&r2=233450&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/OutputELFWriter.h Fri Mar 27 18:30:38 2015
@@ -554,12 +554,10 @@ std::error_code OutputELFWriter<ELFT>::w
                                                    StringRef path) {
   std::unique_ptr<FileOutputBuffer> buffer;
   ScopedTask createOutputTask(getDefaultDomain(), "ELF Writer Create Output");
-  std::error_code ec = FileOutputBuffer::create(path, outputFileSize(), buffer,
-                                                FileOutputBuffer::F_executable);
-  createOutputTask.end();
-
-  if (ec)
+  if (std::error_code ec = FileOutputBuffer::create(
+          path, outputFileSize(), buffer, FileOutputBuffer::F_executable))
     return ec;
+  createOutputTask.end();
 
   ScopedTask writeTask(getDefaultDomain(), "ELF Writer write to memory");
 
@@ -587,14 +585,10 @@ std::error_code OutputELFWriter<ELFT>::w
 template <class ELFT>
 std::error_code OutputELFWriter<ELFT>::writeFile(const File &file,
                                                  StringRef path) {
-  std::error_code ec = buildOutput(file);
-  if (ec)
+  if (std::error_code ec = buildOutput(file))
     return ec;
-
-  ec = setELFHeader();
-  if (ec)
+  if (std::error_code ec = setELFHeader())
     return ec;
-
   return writeOutput(file, path);
 }
 } // namespace elf





More information about the llvm-commits mailing list