From 5c5b48df7534ee73f162a93fc789d37c60fcb284 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 8 Mar 2018 16:42:24 +0100 Subject: [PATCH] Break nested condinationalsi (sonar). --- src/mc/mc_snapshot.cpp | 10 ++++++---- src/xbt/cunit.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 7823e430a6..09e9e17bef 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -121,10 +121,12 @@ int MC_snapshot_region_memcmp( // Using alloca() for large allocations may trigger stack overflow: // use malloc if the buffer is too big. bool stack_alloc = size < 64; - const bool region1_need_buffer = region1==nullptr || region1->storage_type()==simgrid::mc::StorageType::Flat; - const bool region2_need_buffer = region2==nullptr || region2->storage_type()==simgrid::mc::StorageType::Flat; - void* buffer1a = region1_need_buffer ? nullptr : stack_alloc ? alloca(size) : ::operator new(size); - void* buffer2a = region2_need_buffer ? nullptr : stack_alloc ? alloca(size) : ::operator new(size); + void* buffer1a = nullptr; + void* buffer2a = nullptr; + if (region1 != nullptr && region1->storage_type() != simgrid::mc::StorageType::Flat) + buffer1a = stack_alloc ? alloca(size) : ::operator new(size); + if (region2 != nullptr && region2->storage_type() != simgrid::mc::StorageType::Flat) + buffer2a = stack_alloc ? alloca(size) : ::operator new(size); const void* buffer1 = MC_region_read(region1, buffer1a, addr1, size); const void* buffer2 = MC_region_read(region2, buffer2a, addr2, size); int res; diff --git a/src/xbt/cunit.cpp b/src/xbt/cunit.cpp index 7cdedb856c..f6d6ee0ba6 100644 --- a/src/xbt/cunit.cpp +++ b/src/xbt/cunit.cpp @@ -1,6 +1,6 @@ /* cunit - A little C Unit facility */ -/* Copyright (c) 2005-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2005-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -322,10 +322,11 @@ int s_xbt_test_suite::run(int verbosity) if (this->enabled_) { bool first = true; /* for result pretty printing */ - _xbt_test_out << " =====================================================================" - << (this->nb_units_ ? (this->unit_failed_ ? "== FAILED" : "====== OK") - : (this->unit_disabled_ ? " DISABLED" : "==== SKIP")) - << "\n"; + _xbt_test_out << " ====================================================================="; + if (this->nb_units_) + _xbt_test_out << (this->unit_failed_ ? "== FAILED\n" : "====== OK\n"); + else + _xbt_test_out << (this->unit_disabled_ ? " DISABLED\n" : "==== SKIP\n"); _xbt_test_out.setf(std::ios::fixed); _xbt_test_out.precision(0); _xbt_test_out << " Summary: Units: " -- 2.20.1