From: Arnaud Giersch Date: Fri, 3 May 2019 09:44:35 +0000 (+0200) Subject: [sonar] Add attribute "noreturn" to non-returning functions. X-Git-Tag: v3.22.2~11 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bd031688c75b0120d21a705ae3ee325ca0718530 [sonar] Add attribute "noreturn" to non-returning functions. --- diff --git a/include/simgrid/Exception.hpp b/include/simgrid/Exception.hpp index 08ccf09fa3..0012ee0de7 100644 --- a/include/simgrid/Exception.hpp +++ b/include/simgrid/Exception.hpp @@ -196,7 +196,7 @@ public: ~ForcefulKillException(); const char* what() const noexcept { return msg_.c_str(); } - static void do_throw(); + XBT_ATTRIB_NORETURN static void do_throw(); static bool try_n_catch(const std::function& try_block); private: diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index e68ce22491..d4de670021 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -66,7 +66,7 @@ public: void handle_events(int fd, short events); void wait_for_requests(); void handle_simcall(Transition const& transition); - void exit(int status); + XBT_ATTRIB_NORETURN void exit(int status); bool checkDeadlock(); diff --git a/src/mc/remote/Client.hpp b/src/mc/remote/Client.hpp index d28987dc0e..ddbdb979bc 100644 --- a/src/mc/remote/Client.hpp +++ b/src/mc/remote/Client.hpp @@ -37,7 +37,7 @@ private: public: Channel const& getChannel() const { return channel_; } Channel& getChannel() { return channel_; } - void mainLoop(); + XBT_ATTRIB_NORETURN void mainLoop(); void reportAssertionFailure(); void ignoreMemory(void* addr, std::size_t size); void ignoreHeap(void* addr, std::size_t size); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 461b844559..cca99ec5ab 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -33,7 +33,7 @@ std::unique_ptr simix_global; void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr; bool _sg_do_verbose_exit = true; -static void inthandler(int) +XBT_ATTRIB_NORETURN static void inthandler(int) { if ( _sg_do_verbose_exit ) { XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option 'verbose-exit')."); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 2838ee6606..dc56933077 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -7,7 +7,6 @@ #include "mc/mc.h" #include "simgrid/s4u/Engine.hpp" #include "simgrid/sg_config.hpp" -#include "src/internal_config.h" #include "src/simgrid/version.h" #include "src/surf/HostImpl.hpp" #include "src/surf/xml/platf.hpp" diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 82ca23eb82..cd88f89f99 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -6,6 +6,7 @@ #ifndef SURF_MODEL_H_ #define SURF_MODEL_H_ +#include "src/internal_config.h" #include "src/surf/surf_private.hpp" #include @@ -72,6 +73,9 @@ XBT_PUBLIC void surf_cpu_model_init_Cas01(); * * @see surf_host_model_init_SMPI() */ +#if !HAVE_SMPI +XBT_ATTRIB_NORETURN +#endif XBT_PUBLIC void surf_network_model_init_SMPI(); /** @ingroup SURF_models @@ -82,6 +86,9 @@ XBT_PUBLIC void surf_network_model_init_SMPI(); * * @see surf_host_model_init_IB() */ +#if !HAVE_SMPI +XBT_ATTRIB_NORETURN +#endif XBT_PUBLIC void surf_network_model_init_IB(); /** @ingroup SURF_models @@ -121,6 +128,9 @@ XBT_PUBLIC void surf_network_model_init_CM02(); * * @see surf_host_model_init_NS3() */ +#if !SIMGRID_HAVE_NS3 +XBT_ATTRIB_NORETURN +#endif XBT_PUBLIC void surf_network_model_init_NS3(); /** @ingroup SURF_models diff --git a/src/surf/xml/simgrid_dtd.h b/src/surf/xml/simgrid_dtd.h index 20f21d8525..15ee454bb4 100644 --- a/src/surf/xml/simgrid_dtd.h +++ b/src/surf/xml/simgrid_dtd.h @@ -74,7 +74,7 @@ XBT_PUBLIC void STag_surfxml_host(void); XBT_PUBLIC void ETag_surfxml_host(void); XBT_PUBLIC void STag_surfxml_host___link(void); XBT_PUBLIC void ETag_surfxml_host___link(void); -XBT_PUBLIC void STag_surfxml_include(void); +XBT_ATTRIB_NORETURN XBT_PUBLIC void STag_surfxml_include(void); XBT_PUBLIC void ETag_surfxml_include(void); XBT_PUBLIC void STag_surfxml_link(void); XBT_PUBLIC void ETag_surfxml_link(void); diff --git a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp index 756efd7f53..8c21ecc80f 100644 --- a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp +++ b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp @@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example"); -static void usage(const char* binaryName, const char* defaultSend, const char* defaultRecv) +XBT_ATTRIB_NORETURN static void usage(const char* binaryName, const char* defaultSend, const char* defaultRecv) { std::fprintf(stderr, "Usage: %s examples/platforms/cluster_backbone.xml \n" "where spec is a list of letters giving the kind of tests you want to see.\n" diff --git a/tools/cmake/MaintainerMode.cmake b/tools/cmake/MaintainerMode.cmake index 4765bd44df..000cc6feca 100644 --- a/tools/cmake/MaintainerMode.cmake +++ b/tools/cmake/MaintainerMode.cmake @@ -162,6 +162,7 @@ if(enable_maintainer_mode AND NOT WIN32) set(string1 "'s/extern /XBT_PUBLIC_DATA /'") set(string2 "'s/XBT_PUBLIC_DATA \\([^(]*\\)(/XBT_PUBLIC \\1(/'") + set(string3 "'s/XBT_PUBLIC void STag_surfxml_include/XBT_ATTRIB_NORETURN &/'") # remove with v5 of the dtd set(string5 "'s/SET(DOCTYPE)/SET(ROOT_dax__adag)/'") set(string9 "'s/#include /#if defined(_WIN32)\\n# ifndef __STRICT_ANSI__\\n# include \\n# include \\n# endif\\n#else\\n# include \\n#endif/g'") set(string14 "'\\!^ \\* Generated [0-9/]\\{10\\} [0-9:]\\{8\\}\\.$$!d'") @@ -193,6 +194,7 @@ if(enable_maintainer_mode AND NOT WIN32) COMMAND ${FLEXML_EXE} --root-tags platform -P surfxml --sysid=https://simgrid.org/simgrid.dtd -H src/surf/xml/simgrid_dtd.h -L src/surf/xml/simgrid.dtd COMMAND ${SED_EXE} -i ${string1} src/surf/xml/simgrid_dtd.h COMMAND ${SED_EXE} -i ${string2} src/surf/xml/simgrid_dtd.h + COMMAND ${SED_EXE} -i ${string3} src/surf/xml/simgrid_dtd.h COMMAND ${SED_EXE} -i ${string14} src/surf/xml/simgrid_dtd.h COMMAND ${CMAKE_COMMAND} -E echo " Generated src/surf/xml/simgrid_dtd.h"