]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Simplify. The condition on line 1223 is always true.
authorFlorian Krohm <florian@eich-krohm.de>
Tue, 5 May 2015 06:14:10 +0000 (06:14 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Tue, 5 May 2015 06:14:10 +0000 (06:14 +0000)
Here's why:

The condition

 if (VG_(brk_limit) > VG_(brk_base))   line 1223

is reachable iff

  newbrk < VG_(brk_base)  on line 1201  is false  AND
  newbrk < VG_(brk_limit) on line 1205  is true

Rewrite as

  newbrk >= VG_(brk_base)    is true  AND
  newbrk <  VG_(brk_limit)   is true

Rewrite as

  newbrk >= VG_(brk_base)        is true  AND
  newbrk <= VG_(brk_limit) - 1   is true

Combine

  VG_(brk_base) <= newbrk <= VG_(brk_limit) - 1

Therefore

  VG_(brk_base) <= VG_(brk_limit) - 1

Or

  VG_(brk_base) < VG_(brk_limit)

Which is the same as

  VG_(brk_limit) > VG_(brk_base)

qed.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15181

coregrind/m_syswrap/syswrap-generic.c

index 1d4ae61e7d9ac4ea1e4af48d24f4eef026860c11..a28e50a935d13cb611b6f165664dcbbda9931cd2 100644 (file)
@@ -1220,10 +1220,7 @@ static Addr do_brk ( Addr newbrk, ThreadId tid )
          and that segment is writable. */
       NSegment const * seg2;
 
-      if (VG_(brk_limit) > VG_(brk_base))
-         seg2 = VG_(am_find_nsegment)( VG_(brk_limit)-1 );
-      else
-         seg2 = VG_(am_find_nsegment)( VG_(brk_limit) );
+      seg2 = VG_(am_find_nsegment)( VG_(brk_limit) - 1 );
       vg_assert(seg2);
 
       if (seg == seg2 && seg->hasW)