From: Arnaud Giersch Date: Tue, 28 Jun 2022 12:37:59 +0000 (+0200) Subject: Easy Sonar smells. X-Git-Tag: v3.32~178^2~3 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7594887f006f9732a15803392a7b96e0084833ee Easy Sonar smells. --- diff --git a/examples/sthread/pthread-mutex-simple.c b/examples/sthread/pthread-mutex-simple.c index abe582d5f0..f0e29a6e62 100644 --- a/examples/sthread/pthread-mutex-simple.c +++ b/examples/sthread/pthread-mutex-simple.c @@ -26,7 +26,8 @@ int main(int argc, char* argv[]) pthread_mutex_init(&mutex, NULL); - pthread_t thread1, thread2; + pthread_t thread1; + pthread_t thread2; pthread_create(&thread1, NULL, thread1_fun, NULL); fprintf(stderr, "here\n"); pthread_create(&thread2, NULL, thread2_fun, NULL); diff --git a/examples/sthread/sthread-mutex-simple.c b/examples/sthread/sthread-mutex-simple.c index 213fca842d..5b113955a0 100644 --- a/examples/sthread/sthread-mutex-simple.c +++ b/examples/sthread/sthread-mutex-simple.c @@ -24,7 +24,8 @@ int main(int argc, char* argv[]) { sthread_mutex_init(&mutex, NULL); - sthread_t thread1, thread2; + sthread_t thread1; + sthread_t thread2; sthread_create(&thread1, NULL, thread1_fun, NULL); sthread_create(&thread2, NULL, thread2_fun, NULL); // pthread_join(thread1, NULL); diff --git a/src/sthread/sthread_impl.cpp b/src/sthread/sthread_impl.cpp index b7d89726ff..8062a5c683 100644 --- a/src/sthread/sthread_impl.cpp +++ b/src/sthread/sthread_impl.cpp @@ -23,7 +23,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(sthread, "pthread intercepter"); namespace sg4 = simgrid::s4u; -static sg4::Host* lilibeth = NULL; +static sg4::Host* lilibeth = nullptr; int sthread_main(int argc, char** argv, char** envp, int (*raw_main)(int, char**, char**)) { @@ -62,7 +62,7 @@ static void thread_create_wrapper(void* (*user_function)(void*), void* param) sthread_disable(); } -int sthread_create(unsigned long int* thread, const /*pthread_attr_t*/ void* attr, void* (*start_routine)(void*), +int sthread_create(unsigned long int* thread, const void* /*pthread_attr_t* attr*/, void* (*start_routine)(void*), void* arg) { static int TID = 0; @@ -81,7 +81,7 @@ int sthread_create(unsigned long int* thread, const /*pthread_attr_t*/ void* att *thread = reinterpret_cast(actor.get()); return 0; } -int sthread_join(sthread_t thread, void** retval) +int sthread_join(sthread_t thread, void** /*retval*/) { sg4::ActorPtr actor(reinterpret_cast(thread)); actor->join(); @@ -90,7 +90,7 @@ int sthread_join(sthread_t thread, void** retval) return 0; } -int sthread_mutex_init(sthread_mutex_t* mutex, const /*pthread_mutexattr_t*/ void* attr) +int sthread_mutex_init(sthread_mutex_t* mutex, const void* /*pthread_mutexattr_t* attr*/) { auto m = sg4::Mutex::create(); intrusive_ptr_add_ref(m.get()); diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 9443d05a42..8ee72a4f07 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -56,8 +56,12 @@ int xbt_pagebits = 0; */ static void xbt_preinit() XBT_ATTRIB_CONSTRUCTOR(200); static void xbt_postexit(); -void sthread_enable() {} // These symbols are used from ContextSwapped in any case, but they are only useful -void sthread_disable() {} // when libsthread is LD_PRELOADED. In this case, sthread's implem gets used instead. +void sthread_enable() +{ // These symbols are used from ContextSwapped in any case, but they are only useful +} +void sthread_disable() +{ // when libsthread is LD_PRELOADED. In this case, sthread's implem gets used instead. +} #ifdef _WIN32 #include @@ -167,4 +171,4 @@ int SMPI_is_inited() { return false; } -#endif \ No newline at end of file +#endif diff --git a/teshsuite/s4u/issue71/issue71.cpp b/teshsuite/s4u/issue71/issue71.cpp index 3952bdce58..6333844281 100644 --- a/teshsuite/s4u/issue71/issue71.cpp +++ b/teshsuite/s4u/issue71/issue71.cpp @@ -36,8 +36,7 @@ int main(int argc, char* argv[]) e.load_platform(platform_file); simgrid::s4u::Actor::create("actor", e.host_by_name("c1_0"), runner); e.run(); - } - catch (simgrid::AssertionError& e) { + } catch (const simgrid::AssertionError& e) { std::cout << e.what() << "\n"; }