From 572319a43dc3faf7fdfe64b92ac82a617e1d7e74 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 23 Nov 2022 15:48:27 +0100 Subject: [PATCH] Use C++ string_view. --- src/sthread/sthread_impl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sthread/sthread_impl.cpp b/src/sthread/sthread_impl.cpp index 433f26a49a..30e9a2a98a 100644 --- a/src/sthread/sthread_impl.cpp +++ b/src/sthread/sthread_impl.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include XBT_LOG_NEW_DEFAULT_CATEGORY(sthread, "pthread intercepter"); @@ -31,7 +32,7 @@ int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char** { /* Do not intercept the main when run from SMPI: it will initialize the simulation properly */ for (int i = 0; envp[i] != nullptr; i++) - if (strncmp(envp[i], "SMPI_GLOBAL_SIZE", strlen("SMPI_GLOBAL_SIZE")) == 0) + if (std::string_view(envp[i]).rfind("SMPI_GLOBAL_SIZE", 0) == 0) return raw_main(argc, argv, envp); /* If not in SMPI, the old main becomes an actor in a newly created simulation */ -- 2.20.1