X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7d28d93b90eedd2a49da8b9b990296669e46d05c..c972ddd5a74b83c183357f707e7dfba87d48e750:/src/kernel/resource/profile/Profile.cpp diff --git a/src/kernel/resource/profile/Profile.cpp b/src/kernel/resource/profile/Profile.cpp index 9a85416023..b6167c491d 100644 --- a/src/kernel/resource/profile/Profile.cpp +++ b/src/kernel/resource/profile/Profile.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-2021. 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. */ @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -27,10 +28,8 @@ namespace profile { Profile::Profile() { /* Add the first fake event storing the time at which the trace begins */ - DatedValue val(0, -1); - StochasticDatedValue stoval(0, -1); - event_list.emplace_back(val); - stochastic_event_list.emplace_back(stoval); + event_list.emplace_back(0, -1); + stochastic_event_list.emplace_back(0, -1); } Profile::~Profile() = default; @@ -130,7 +129,7 @@ Profile* Profile::from_string(const std::string& name, const std::string& input, std::vector splittedval((std::istream_iterator(iss)), std::istream_iterator()); - xbt_assert(splittedval.size() > 0, "Invalid profile line"); + xbt_assert(not splittedval.empty(), "Invalid profile line"); if (splittedval[0] == "DET") { stochevent.date_law = Distribution::DET; @@ -182,8 +181,8 @@ Profile* Profile::from_string(const std::string& name, const std::string& input, profile->stochastic_event_list.emplace_back(stochevent); } else { - XBT_ATTRIB_UNUSED int res = sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_); - xbt_assert(res == 2, "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str()); + xbt_assert(sscanf(val.c_str(), "%lg %lg\n", &event.date_, &event.value_) == 2, + "%s:%d: Syntax error in trace\n%s", name.c_str(), linecount, input.c_str()); xbt_assert(last_event->date_ <= event.date_, "%s:%d: Invalid trace: Events must be sorted, but time %g > time %g.\n%s", name.c_str(), linecount, @@ -211,12 +210,11 @@ Profile* Profile::from_file(const std::string& path) xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename"); xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str()); - const std::ifstream* f = surf_ifsopen(path); + auto f = std::unique_ptr(surf_ifsopen(path)); xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str()); std::stringstream buffer; buffer << f->rdbuf(); - delete f; return Profile::from_string(path, buffer.str(), -1); }