[all-commits] [llvm/llvm-project] 43ff05: [llvm-objcopy] IHexELFBuilder::addDataSections - f...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Tue Aug 3 04:28:21 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 43ff058e78d9e4fa47080b61fc3811da80db1b3f
      https://github.com/llvm/llvm-project/commit/43ff058e78d9e4fa47080b61fc3811da80db1b3f
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-08-03 (Tue, 03 Aug 2021)

  Changed paths:
    M llvm/tools/llvm-objcopy/ELF/Object.cpp

  Log Message:
  -----------
  [llvm-objcopy] IHexELFBuilder::addDataSections - fix evaluation ordering static analyzer warning

As detailed on https://pvs-studio.com/en/blog/posts/cpp/0771/ and raised on D62583, the SecNo++ increment is not guaranteed to occur before the second use of SecNo in the same addSection() call.

This patch pulls out the increment (just for clarity) and replaces the second use of SecNo with a constant zero value (we're using stable_sort so the value isn't critical).

Differential Revision: https://reviews.llvm.org/D107273




More information about the All-commits mailing list