Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Put parentheses around macro parameters.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Sep 2019 08:20:59 +0000 (10:20 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 26 Sep 2019 13:04:23 +0000 (15:04 +0200)
29 files changed:
include/simgrid/msg.h
include/simgrid/plugins/energy.h
include/simgrid/plugins/file_system.h
include/simgrid/plugins/live_migration.h
include/simgrid/simdag.h
include/simgrid/smpi/replay.hpp
include/smpi/sampi.h
include/smpi/smpi.h
include/smpi/smpi_helpers.h
include/xbt/asserts.h
include/xbt/base.h
include/xbt/dict.h
include/xbt/dynar.h
include/xbt/ex.h
include/xbt/log.h
src/bindings/java/jxbt_utilities.hpp
src/bindings/lua/lua_private.hpp
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_file.cpp
src/smpi/include/private.hpp
src/smpi/internals/smpi_memory.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_op.cpp
src/surf/surf_interface.hpp
src/xbt/mmalloc/mmprivate.h
src/xbt/xbt_log_layout_format.cpp
teshsuite/surf/lmm_usage/lmm_usage.cpp
teshsuite/xbt/mmalloc/mmalloc_test.cpp

index 91c438d..60aad3b 100644 (file)
@@ -279,7 +279,7 @@ XBT_PUBLIC void MSG_config(const char* key, const char* value);
 #define MSG_init(argc, argv)                                                                                           \
   do {                                                                                                                 \
     sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);                             \
-    MSG_init_nocheck(argc, argv);                                                                                      \
+    MSG_init_nocheck((argc), (argv));                                                                                  \
   } while (0)
 
 XBT_PUBLIC void MSG_init_nocheck(int* argc, char** argv);
@@ -369,7 +369,7 @@ XBT_ATTRIB_DEPRECATED_v325("Getting a task from a specific host is no longer sup
 XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
 
 XBT_PUBLIC msg_error_t MSG_task_receive(msg_task_t* task, const char* alias);
-#define MSG_task_recv(t,a) MSG_task_receive(t,a)
+#define MSG_task_recv(t, a) MSG_task_receive((t), (a))
 
 XBT_PUBLIC msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, double timeout,
                                                     msg_host_t host, double rate);
@@ -377,7 +377,7 @@ XBT_PUBLIC msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char
 XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* alias, double timeout,
                                                              double rate);
 XBT_PUBLIC msg_error_t MSG_task_receive_bounded(msg_task_t* task, const char* alias, double rate);
-#define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
+#define MSG_task_recv_bounded(t, a, r) MSG_task_receive_bounded((t), (a), (r))
 
 XBT_PUBLIC msg_comm_t MSG_task_isend(msg_task_t task, const char* alias);
 XBT_PUBLIC msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char* alias, double maxrate);
index cfd6840..041e4bd 100644 (file)
@@ -26,8 +26,8 @@ XBT_PUBLIC int sg_link_energy_is_inited();
 
 #define MSG_host_energy_plugin_init() sg_host_energy_plugin_init()
 #define MSG_host_get_consumed_energy(host) sg_host_get_consumed_energy(host)
-#define MSG_host_get_wattmin_at(host,pstate) sg_host_get_wattmin_at(host,pstate)
-#define MSG_host_get_wattmax_at(host,pstate) sg_host_get_wattmax_at(host,pstate)
+#define MSG_host_get_wattmin_at(host, pstate) sg_host_get_wattmin_at((host), (pstate))
+#define MSG_host_get_wattmax_at(host, pstate) sg_host_get_wattmax_at((host), (pstate))
 #define MSG_host_get_current_consumption(host) sg_host_get_current_consumption(host)
 
 SG_END_DECL()
index 8f8b4d5..76cf0f7 100644 (file)
@@ -53,21 +53,21 @@ XBT_PUBLIC xbt_dict_t sg_storage_get_content(sg_storage_t storage);
 
 XBT_PUBLIC xbt_dict_t sg_host_get_storage_content(sg_host_t host);
 
-#define MSG_file_open(fullpath, data) sg_file_open(fullpath, data)
-#define MSG_file_read(fd, size) sg_file_read(fd, size)
-#define MSG_file_write(fd, size) sg_file_write(fd, size)
+#define MSG_file_open(fullpath, data) sg_file_open((fullpath), (data))
+#define MSG_file_read(fd, size) sg_file_read((fd), (size))
+#define MSG_file_write(fd, size) sg_file_write((fd), (size))
 #define MSG_file_close(fd) sg_file_close(fd)
 #define MSG_file_get_name(fd) sg_file_get_name(fd)
 #define MSG_file_get_size(fd) sg_file_get_size(fd)
 #define MSG_file_dump(fd) sg_file_dump(fd)
 #define MSG_file_get_data(fd) sg_file_get_data(fd)
-#define MSG_file_set_data(fd, data) sg_file_set_data(fd, data)
-#define MSG_file_seek(fd, offset, origin) sg_file_seek(fd, offset, origin)
+#define MSG_file_set_data(fd, data) sg_file_set_data((fd), (data))
+#define MSG_file_seek(fd, offset, origin) sg_file_seek((fd), (offset), (origin))
 #define MSG_file_tell(fd) sg_file_tell(fd)
-#define MSG_file_move(fd, fullpath) sg_file_get_size(fd, fullpath)
+#define MSG_file_move(fd, fullpath) sg_file_get_size((fd), (fullpath))
 #define MSG_file_unlink(fd) sg_file_unlink(fd)
-#define MSG_file_rcopy(file, host, fullpath) sg_file_rcopy(file, host, fullpath)
-#define MSG_file_rmove(file, host, fullpath) sg_file_rmove(file, host, fullpath)
+#define MSG_file_rcopy(file, host, fullpath) sg_file_rcopy((file), (host), (fullpath))
+#define MSG_file_rmove(file, host, fullpath) sg_file_rmove((file), (host), (fullpath))
 
 #define MSG_storage_file_system_init() sg_storage_file_system_init()
 #define MSG_storage_get_free_size(st) sg_storage_get_size_free(st)
index 6b6a4cd..085c03b 100644 (file)
@@ -31,10 +31,10 @@ XBT_PUBLIC sg_vm_t sg_vm_create_migratable(sg_host_t pm, const char* name, int c
 #define MSG_vm_live_migration_plugin_init() sg_vm_live_migration_plugin_init()
 
 #define MSG_vm_create_migratable(pm, name, coreAmount, ramsize, mig_netspeed, dp_intensity)                            \
-  sg_vm_create_migratable(pm, name, coreAmount, ramsize, mig_netspeed, dp_intensity)
+  sg_vm_create_migratable((pm), (name), (coreAmount), (ramsize), (mig_netspeed), (dp_intensity))
 
 #define MSG_vm_is_migrating(vm) sg_vm_is_migrating(vm)
-#define MSG_vm_migrate(vm, dst_pm) sg_vm_migrate(vm, dst_pm)
+#define MSG_vm_migrate(vm, dst_pm) sg_vm_migrate((vm), (dst_pm))
 
 SG_END_DECL()
 
index fc162d6..5031939 100644 (file)
@@ -144,7 +144,7 @@ XBT_PUBLIC int SD_task_dependency_exists(SD_task_t src, SD_task_t dst);
 #define SD_init(argc, argv)                                                                                            \
   do {                                                                                                                 \
     sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);                             \
-    SD_init_nocheck(argc, argv);                                                                                       \
+    SD_init_nocheck((argc), (argv));                                                                                   \
   } while (0)
 
 XBT_PUBLIC void SD_init_nocheck(int* argc, char** argv);
index 27aceab..169d71c 100644 (file)
 
 #define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                               \
   {                                                                                                                    \
-    if (action.size() < static_cast<unsigned long>(mandatory + 2)) {                                                   \
+    if ((action).size() < static_cast<unsigned long>((mandatory) + 2)) {                                               \
       std::stringstream ss;                                                                                            \
       ss << __func__ << " replay failed.\n"                                                                            \
-         << action.size() << " items were given on the line. First two should be process_id and action.  "             \
-         << "This action needs after them " << mandatory << " mandatory arguments, and accepts " << optional           \
+         << (action).size() << " items were given on the line. First two should be process_id and action.  "           \
+         << "This action needs after them " << (mandatory) << " mandatory arguments, and accepts " << (optional)       \
          << " optional ones. \n"                                                                                       \
          << "The full line that was given is:\n   ";                                                                   \
-      for (const auto& elem : action) {                                                                                \
+      for (const auto& elem : (action)) {                                                                              \
         ss << elem << " ";                                                                                             \
       }                                                                                                                \
       ss << "\nPlease contact the Simgrid team if support is needed";                                                  \
index a8923b1..e7c7d7c 100644 (file)
@@ -16,8 +16,8 @@
 #ifndef HAVE_SMPI
 // Internally disable these overrides (HAVE_SMPI is only defined when building the library)
 #define malloc(nbytes) _sampi_malloc(nbytes)
-#define calloc(n_elm,elm_size) _sampi_calloc(n_elm,elm_size)
-#define realloc(ptr,nbytes) _sampi_realloc(ptr,nbytes)
+#define calloc(n_elm, elm_size) _sampi_calloc((n_elm), (elm_size))
+#define realloc(ptr, nbytes) _sampi_realloc((ptr), (nbytes))
 #define free(ptr) _sampi_free(ptr)
 #endif
 
index d1ac611..5af6d62 100644 (file)
@@ -1006,27 +1006,31 @@ XBT_PUBLIC void smpi_trace_set_call_location__(const char* file, int* line);
 
 #define SMPI_ITER_NAME1(line) _XBT_CONCAT(iter_count, line)
 #define SMPI_ITER_NAME(line) SMPI_ITER_NAME1(line)
-#define SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, global, iters, thres)\
-  int SMPI_ITER_NAME(__LINE__)=0;\
-  {loop_init;\
-  while(loop_end){\
-    SMPI_ITER_NAME(__LINE__)++;\
-    loop_iter;\
-  }}                                                                         \
-  for(loop_init; \
-      loop_end ? (smpi_sample_1(global, __FILE__, __LINE__, iters, thres), (smpi_sample_2(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__)))) :\
-      smpi_sample_exit(global, __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__));\
-      smpi_sample_3(global, __FILE__, __LINE__),loop_iter)
-#define SMPI_SAMPLE_LOCAL(loop_init, loop_end, loop_iter, iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 0, iters, thres)
-#define SMPI_SAMPLE_GLOBAL(loop_init, loop_end, loop_iter,iters, thres) SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, 1, iters, thres)
+#define SMPI_SAMPLE_LOOP(loop_init, loop_end, loop_iter, global, iters, thres)                                         \
+  int SMPI_ITER_NAME(__LINE__) = 0;                                                                                    \
+  {                                                                                                                    \
+    loop_init;                                                                                                         \
+    while (loop_end) {                                                                                                 \
+      SMPI_ITER_NAME(__LINE__)++;                                                                                      \
+      (loop_iter);                                                                                                     \
+    }                                                                                                                  \
+  }                                                                                                                    \
+  for (loop_init; (loop_end) ? (smpi_sample_1((global), __FILE__, __LINE__, (iters), (thres)),                         \
+                                (smpi_sample_2((global), __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__))))               \
+                             : smpi_sample_exit((global), __FILE__, __LINE__, SMPI_ITER_NAME(__LINE__));               \
+       smpi_sample_3((global), __FILE__, __LINE__), (loop_iter))
+#define SMPI_SAMPLE_LOCAL(loop_init, loop_end, loop_iter, iters, thres)                                                \
+  SMPI_SAMPLE_LOOP(loop_init, (loop_end), (loop_iter), 0, (iters), (thres))
+#define SMPI_SAMPLE_GLOBAL(loop_init, loop_end, loop_iter, iters, thres)                                               \
+  SMPI_SAMPLE_LOOP(loop_init, (loop_end), (loop_iter), 1, (iters), (thres))
 #define SMPI_SAMPLE_DELAY(duration) for(smpi_execute(duration); 0; )
 #define SMPI_SAMPLE_FLOPS(flops) for(smpi_execute_flops(flops); 0; )
 
 XBT_PUBLIC void* smpi_shared_malloc(size_t size, const char* file, int line);
-#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc(size, __FILE__, __LINE__)
+#define SMPI_SHARED_MALLOC(size) smpi_shared_malloc((size), __FILE__, __LINE__)
 XBT_PUBLIC void* smpi_shared_malloc_partial(size_t size, size_t* shared_block_offsets, int nb_shared_blocks);
 #define SMPI_PARTIAL_SHARED_MALLOC(size, shared_block_offsets, nb_shared_blocks)                                       \
-  smpi_shared_malloc_partial(size, shared_block_offsets, nb_shared_blocks)
+  smpi_shared_malloc_partial((size), (shared_block_offsets), (nb_shared_blocks))
 
 XBT_PUBLIC void smpi_shared_free(void* data);
 #define SMPI_SHARED_FREE(data) smpi_shared_free(data)
@@ -1035,9 +1039,9 @@ XBT_PUBLIC int smpi_shared_known_call(const char* func, const char* input);
 XBT_PUBLIC void* smpi_shared_get_call(const char* func, const char* input);
 XBT_PUBLIC void* smpi_shared_set_call(const char* func, const char* input, void* data);
 #define SMPI_SHARED_CALL(func, input, ...)                                                                             \
-  (smpi_shared_known_call(_XBT_STRINGIFY(func), input)                                                                 \
-       ? smpi_shared_get_call(_XBT_STRINGIFY(func), input)                                                             \
-       : smpi_shared_set_call(_XBT_STRINGIFY(func), input, (func(__VA_ARGS__))))
+  (smpi_shared_known_call(_XBT_STRINGIFY(func), (input))                                                               \
+       ? smpi_shared_get_call(_XBT_STRINGIFY(func), (input))                                                           \
+       : smpi_shared_set_call(_XBT_STRINGIFY(func), (input), ((func)(__VA_ARGS__))))
 
 /* Fortran specific stuff */
 
index be15a24..6739870 100644 (file)
 
 #define sleep(x) smpi_sleep(x)
 #define usleep(x) smpi_usleep(x)
-#define gettimeofday(x, y) smpi_gettimeofday(x, 0)
+#define gettimeofday(x, y) smpi_gettimeofday((x), 0)
 #if _POSIX_TIMERS > 0
-#define nanosleep(x, y) smpi_nanosleep(x, y)
-#define clock_gettime(x, y) smpi_clock_gettime(x, y)
+#define nanosleep(x, y) smpi_nanosleep((x), (y))
+#define clock_gettime(x, y) smpi_clock_gettime((x), (y))
 #endif
 
-#define getopt(x,y,z) smpi_getopt(x,y,z)
-#define getopt_long(x,y,z,a,b) smpi_getopt_long(x,y,z,a,b)
-#define getopt_long_only(x,y,z,a,b) smpi_getopt_long_only(x,y,z,a,b)
+#define getopt(x, y, z) smpi_getopt((x), (y), (z))
+#define getopt_long(x, y, z, a, b) smpi_getopt_long((x), (y), (z), (a), (b))
+#define getopt_long_only(x, y, z, a, b) smpi_getopt_long_only((x), (y), (z), (a), (b))
 
 #endif
index b455627..585b123 100644 (file)
@@ -35,8 +35,7 @@ XBT_PUBLIC void xbt_backtrace_display_current();
    @hideinitializer  */
 #define xbt_assert(...) \
   _XBT_IF_ONE_ARG(_xbt_assert_ARG1, _xbt_assert_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _xbt_assert_ARG1(cond) \
-  _xbt_assert_ARGN(cond, "Assertion %s failed", #cond)
+#define _xbt_assert_ARG1(cond) _xbt_assert_ARGN((cond), "Assertion %s failed", #cond)
 #define _xbt_assert_ARGN(cond, ...)                                                                                    \
   do {                                                                                                                 \
     if (!(cond)) {                                                                                                     \
index e0d787e..1f49c1b 100644 (file)
 #ifdef __MINGW32__
 #  include <stdio.h>
 
-#  define XBT_ATTRIB_PRINTF( format_idx, arg_idx )    \
-     __attribute__((__format__ (__MINGW_PRINTF_FORMAT, format_idx, arg_idx)))
-#  define XBT_ATTRIB_SCANF( format_idx, arg_idx )     \
-     __attribute__((__MINGW_SCANF_FORMAT (__scanf__, format_idx, arg_idx)))
+#define XBT_ATTRIB_PRINTF(format_idx, arg_idx)                                                                         \
+  __attribute__((__format__(__MINGW_PRINTF_FORMAT, (format_idx), (arg_idx))))
+#define XBT_ATTRIB_SCANF(format_idx, arg_idx) __attribute__((__MINGW_SCANF_FORMAT(__scanf__, (format_idx), (arg_idx))))
 #else
-#  define XBT_ATTRIB_PRINTF( format_idx, arg_idx )    \
-     __attribute__((__format__ (__printf__, format_idx, arg_idx)))
-#  define XBT_ATTRIB_SCANF( format_idx, arg_idx )     \
-     __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
+#define XBT_ATTRIB_PRINTF(format_idx, arg_idx) __attribute__((__format__(__printf__, (format_idx), (arg_idx))))
+#define XBT_ATTRIB_SCANF(format_idx, arg_idx) __attribute__((__format__(__scanf__, (format_idx), (arg_idx))))
 #endif
 
 #if defined(__cplusplus)
index 589af4a..f27f5d3 100644 (file)
@@ -158,10 +158,9 @@ xbt_dict_foreach(head, cursor, key, data) {
 }
 @endcode
  */
-#  define xbt_dict_foreach(dict,cursor,key,data)                       \
-    for (cursor=NULL, xbt_dict_cursor_first((dict),&(cursor)) ;        \
-         xbt_dict_cursor_get_or_free(&(cursor),(char**)&(key),(void**)(&data));\
-         xbt_dict_cursor_step(cursor) )
+#define xbt_dict_foreach(dict, cursor, key, data)                                                                      \
+  for ((cursor) = NULL, xbt_dict_cursor_first((dict), &(cursor));                                                      \
+       xbt_dict_cursor_get_or_free(&(cursor), (char**)&(key), (void**)&(data)); xbt_dict_cursor_step(cursor))
 
 /** @} */
 
index b7529f3..9df2eca 100644 (file)
@@ -151,26 +151,23 @@ XBT_PUBLIC void* xbt_dynar_pop_ptr(xbt_dynar_t const dynar);
           (*(type*)xbt_dynar_get_ptr((dynar),(idx)))
 /** @brief Quick setting of scalar content
  *  @hideinitializer */
-#  define xbt_dynar_set_as(dynar,idx,type,val) \
-         (*(type*)xbt_dynar_set_at_ptr((dynar),(idx))) = val
-  /** @brief Quick retrieval of scalar content
-   *  @hideinitializer */
+#define xbt_dynar_set_as(dynar, idx, type, val) (*(type*)xbt_dynar_set_at_ptr((dynar), (idx))) = (val)
+/** @brief Quick retrieval of scalar content
+ *  @hideinitializer */
 #  define xbt_dynar_getlast_as(dynar,type) \
           (*(type*)xbt_dynar_get_ptr((dynar),xbt_dynar_length(dynar)-1))
-  /** @brief Quick retrieval of scalar content
  *  @hideinitializer */
+/** @brief Quick retrieval of scalar content
+ *  @hideinitializer */
 #  define xbt_dynar_getfirst_as(dynar,type) \
           (*(type*)xbt_dynar_get_ptr((dynar),0))
-  /** @brief Quick insertion of scalar content
-   *  @hideinitializer */
-#  define xbt_dynar_insert_at_as(dynar,idx,type,value) \
-          *(type*)xbt_dynar_insert_at_ptr(dynar,idx)=value
-  /** @brief Quick insertion of scalar content
-   *  @hideinitializer */
-#  define xbt_dynar_push_as(dynar,type,value) \
-          *(type*)xbt_dynar_push_ptr(dynar)=value
-  /** @brief Quick removal of scalar content
-   *  @hideinitializer */
+/** @brief Quick insertion of scalar content
+ *  @hideinitializer */
+#define xbt_dynar_insert_at_as(dynar, idx, type, value) *(type*)xbt_dynar_insert_at_ptr((dynar), (idx)) = (value)
+/** @brief Quick insertion of scalar content
+ *  @hideinitializer */
+#define xbt_dynar_push_as(dynar, type, value) *(type*)xbt_dynar_push_ptr(dynar) = (value)
+/** @brief Quick removal of scalar content
+ *  @hideinitializer */
 #  define xbt_dynar_pop_as(dynar,type) \
            (*(type*)xbt_dynar_pop_ptr(dynar))
 
@@ -237,21 +234,18 @@ xbt_dynar_foreach (dyn,cpt,str) {
  * Note that underneath, that's a simple for loop with no real black  magic involved. It's perfectly safe to interrupt
  * a foreach with a break or a return statement.
  */
-#define xbt_dynar_foreach(_dynar,_cursor,_data) \
-       for ( (_cursor) = 0      ; \
-             _xbt_dynar_cursor_get(_dynar,_cursor,&_data) ; \
-             (_cursor)++         )
+#define xbt_dynar_foreach(_dynar, _cursor, _data)                                                                      \
+  for ((_cursor) = 0; _xbt_dynar_cursor_get((_dynar), (_cursor), &(_data)); (_cursor)++)
 
 #ifndef __cplusplus
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
-       for ((_cursor) = 0       ; \
-            (_ptr = _cursor < _dynar->used ? xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
-            (_cursor)++         )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr)                                                                   \
+  for ((_cursor) = 0; ((_ptr) = (_cursor) < (_dynar)->used ? xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL);           \
+       (_cursor)++)
 #else
-#define xbt_dynar_foreach_ptr(_dynar,_cursor,_ptr) \
-       for ((_cursor) = 0       ; \
-            (_ptr = _cursor < _dynar->used ? (decltype(_ptr)) xbt_dynar_get_ptr(_dynar,_cursor) : NULL) ; \
-            (_cursor)++         )
+#define xbt_dynar_foreach_ptr(_dynar, _cursor, _ptr)                                                                   \
+  for ((_cursor) = 0;                                                                                                  \
+       ((_ptr) = (_cursor) < (_dynar)->used ? (decltype(_ptr))xbt_dynar_get_ptr((_dynar), (_cursor)) : NULL);          \
+       (_cursor)++)
 #endif
 /** @} */
 SG_END_DECL()
index 0cbbb9d..dc31878 100644 (file)
@@ -30,13 +30,13 @@ XBT_ATTRIB_NORETURN XBT_PUBLIC void _xbt_throw(char* message, int value, const c
  *  @ingroup XBT_ex_c
  *  @hideinitializer
  */
-#define THROW(v) _xbt_throw(NULL, v, __FILE__, __LINE__, __func__)
+#define THROW(v) _xbt_throw(NULL, (v), __FILE__, __LINE__, __func__)
 
 /** Builds and throws an exception with a printf-like formatted message
  *  @ingroup XBT_ex_c
  *  @hideinitializer
  */
-#define THROWF(v, ...) _xbt_throw(bprintf(__VA_ARGS__), v, __FILE__, __LINE__, __func__)
+#define THROWF(v, ...) _xbt_throw(bprintf(__VA_ARGS__), (v), __FILE__, __LINE__, __func__)
 
 XBT_ATTRIB_NORETURN void xbt_throw_impossible(const char* file, int line, const char* func);
 /** Throw an exception because something impossible happened
index 98e04df..1df2b5c 100644 (file)
@@ -117,7 +117,7 @@ typedef enum {
       NULL /* firstChild */,                                                                                           \
       NULL /* nextSibling */,                                                                                          \
       _XBT_STRINGIFY(catName),                                                                                         \
-      desc,                                                                                                            \
+      (desc),                                                                                                          \
       0 /*initialized */,                                                                                              \
       xbt_log_priority_uninitialized /* threshold */,                                                                  \
       1 /* isThreshInherited */,                                                                                       \
@@ -135,9 +135,9 @@ typedef enum {
  *
  * Defines a new subcategory of the parent.
  */
-#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc)    \
-  XBT_LOG_EXTERNAL_CATEGORY(parent);                      \
-  XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc)
+#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc)                                                                 \
+  XBT_LOG_EXTERNAL_CATEGORY(parent);                                                                                   \
+  XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, (desc))
 
 /**
  * @ingroup XBT_log
@@ -147,8 +147,7 @@ typedef enum {
  *
  * Creates a new subcategory of the root category.
  */
-# define XBT_LOG_NEW_CATEGORY(catName,desc)  \
-   XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc)
+#define XBT_LOG_NEW_CATEGORY(catName, desc) XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, (desc))
 
 /**
  * @ingroup XBT_log
@@ -174,9 +173,9 @@ typedef enum {
  * Creates a new subcategory of the root category and makes it the default (used by macros that don't explicitly
  * specify a category).
  */
-# define XBT_LOG_NEW_DEFAULT_CATEGORY(cname,desc)        \
-    XBT_LOG_NEW_CATEGORY(cname,desc);                   \
-    XBT_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_CATEGORY(cname, desc)                                                                      \
+  XBT_LOG_NEW_CATEGORY(cname, (desc));                                                                                 \
+  XBT_LOG_DEFAULT_CATEGORY(cname)
 
 /**
  * @ingroup XBT_log
@@ -188,9 +187,9 @@ typedef enum {
  * Creates a new subcategory of the parent category and makes it the default
  * (used by macros that don't explicitly specify a category).
  */
-#define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc) \
-    XBT_LOG_NEW_SUBCATEGORY(cname, parent, desc);            \
-    XBT_LOG_DEFAULT_CATEGORY(cname)
+#define XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname, parent, desc)                                                           \
+  XBT_LOG_NEW_SUBCATEGORY(cname, parent, (desc));                                                                      \
+  XBT_LOG_DEFAULT_CATEGORY(cname)
 
 /**
  * @ingroup XBT_log
@@ -336,8 +335,7 @@ extern xbt_log_layout_t xbt_log_default_layout;
  * If you have expensive expressions that are computed outside of the log command and used only within it, you should
  * make its evaluation conditional using this macro.
  */
-#define XBT_LOG_ISENABLED(catName, priority) \
-            _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), priority)
+#define XBT_LOG_ISENABLED(catName, priority) _XBT_LOG_ISENABLEDV(_XBT_LOGV(catName), (priority))
 
 /*
  * Helper function that implements XBT_LOG_ISENABLED.
@@ -346,10 +344,9 @@ extern xbt_log_layout_t xbt_log_default_layout;
  * First part is a compile-time constant.
  * Call to xbt_log_cat_init only happens once.
  */
-#define _XBT_LOG_ISENABLEDV(catv, priority)                  \
-       (priority >= XBT_LOG_STATIC_THRESHOLD                 \
-        && ((catv).initialized || _xbt_log_cat_init(&(catv), priority)) \
-        && priority >= (catv).threshold)
+#define _XBT_LOG_ISENABLEDV(catv, priority)                                                                            \
+  ((priority) >= XBT_LOG_STATIC_THRESHOLD && ((catv).initialized || _xbt_log_cat_init(&(catv), (priority))) &&         \
+   (priority) >= (catv).threshold)
 
 /*
  * Internal Macros
@@ -376,7 +373,7 @@ extern xbt_log_layout_t xbt_log_default_layout;
 
 #define XBT_CLOG(category, prio, ...)                                                                                  \
   do {                                                                                                                 \
-    if (_XBT_LOG_ISENABLEDV((category), prio)) {                                                                       \
+    if (_XBT_LOG_ISENABLEDV((category), (prio))) {                                                                     \
       s_xbt_log_event_t _log_ev;                                                                                       \
       _log_ev.cat          = &(category);                                                                              \
       _log_ev.priority     = (prio);                                                                                   \
@@ -387,7 +384,7 @@ extern xbt_log_layout_t xbt_log_default_layout;
     }                                                                                                                  \
   } while (0)
 
-#define XBT_LOG(prio, ...) XBT_CLOG(*_simgrid_log_category__default, prio, __VA_ARGS__)
+#define XBT_LOG(prio, ...) XBT_CLOG(*_simgrid_log_category__default, (prio), __VA_ARGS__)
 
 #endif
 
@@ -468,10 +465,8 @@ extern xbt_log_layout_t xbt_log_default_layout;
 
 #define _XBT_IN_OUT(...) \
   _XBT_IF_ONE_ARG(_XBT_IN_OUT_ARG1, _XBT_IN_OUT_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _XBT_IN_OUT_ARG1(fmt) \
-  XBT_LOG(xbt_log_priority_trace, fmt, __func__)
-#define _XBT_IN_OUT_ARGN(fmt, ...) \
-  XBT_LOG(xbt_log_priority_trace, fmt, __func__, __VA_ARGS__)
+#define _XBT_IN_OUT_ARG1(fmt) XBT_LOG(xbt_log_priority_trace, (fmt), __func__)
+#define _XBT_IN_OUT_ARGN(fmt, ...) XBT_LOG(xbt_log_priority_trace, (fmt), __func__, __VA_ARGS__)
 
 /** @ingroup XBT_log
  *  @hideinitializer
index 177bce3..48b1e70 100644 (file)
@@ -35,16 +35,16 @@ jfieldID jxbt_get_sfield(JNIEnv* env, const char* classname, const char* name, c
 
 #define jxbt_check_res(fun, res, allowed_exceptions, detail)                                                           \
   do {                                                                                                                 \
-    if (res != MSG_OK && (res | allowed_exceptions)) {                                                                 \
-      xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.", fun, res);            \
-    } else if (res == MSG_HOST_FAILURE) {                                                                              \
-      jxbt_throw_host_failure(env, detail);                                                                            \
-    } else if (res == MSG_TRANSFER_FAILURE) {                                                                          \
-      jxbt_throw_transfer_failure(env, detail);                                                                        \
-    } else if (res == MSG_TIMEOUT) {                                                                                   \
-      jxbt_throw_time_out_failure(env, detail);                                                                        \
-    } else if (res == MSG_TASK_CANCELED) {                                                                             \
-      jxbt_throw_task_cancelled(env, detail);                                                                          \
+    if ((res) != MSG_OK && ((res) | (allowed_exceptions))) {                                                           \
+      xbt_die("%s failed with error code %d, which is not an allowed exception. Please fix me.", (fun), (res));        \
+    } else if ((res) == MSG_HOST_FAILURE) {                                                                            \
+      jxbt_throw_host_failure(env, (detail));                                                                          \
+    } else if ((res) == MSG_TRANSFER_FAILURE) {                                                                        \
+      jxbt_throw_transfer_failure(env, (detail));                                                                      \
+    } else if ((res) == MSG_TIMEOUT) {                                                                                 \
+      jxbt_throw_time_out_failure(env, (detail));                                                                      \
+    } else if ((res) == MSG_TASK_CANCELED) {                                                                           \
+      jxbt_throw_task_cancelled(env, (detail));                                                                        \
     }                                                                                                                  \
   } while (0)
 
index 6893f5f..30db85b 100644 (file)
@@ -17,7 +17,7 @@ msg_host_t sglua_check_host(lua_State* L, int index);
 void sglua_register_platf_functions(lua_State* L);
 
 #define lua_ensure(...) _XBT_IF_ONE_ARG(_lua_ensure_ARG1, _lua_ensure_ARGN, __VA_ARGS__)(__VA_ARGS__)
-#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN(cond, "Assertion " _XBT_STRINGIFY(cond) " failed")
+#define _lua_ensure_ARG1(cond) _lua_ensure_ARGN((cond), "Assertion " _XBT_STRINGIFY(cond) " failed")
 #define _lua_ensure_ARGN(cond, ...)                                                                                    \
   do {                                                                                                                 \
     if (!(cond)) {                                                                                                     \
index 00d23f8..8a44988 100644 (file)
@@ -39,12 +39,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, "Logging specific to SMPI ,(mpi)
       char error_string[MPI_MAX_ERROR_STRING];                                                                         \
       int error_size;                                                                                                  \
       PMPI_Error_string(ret, error_string, &error_size);                                                               \
-      if(errhan==nullptr || errhan->errhandler()==MPI_ERRORS_RETURN)                                                                         \
+      if ((errhan) == nullptr || (errhan)->errhandler() == MPI_ERRORS_RETURN)                                          \
         XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                     \
-      else if(errhan->errhandler()==MPI_ERRORS_ARE_FATAL)                                                                 \
+      else if ((errhan)->errhandler() == MPI_ERRORS_ARE_FATAL)                                                         \
         xbt_die("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size, error_string);                      \
       else                                                                                                             \
-        errhan->errhandler()->call(errhan, ret);                                                                \
+        (errhan)->errhandler()->call((errhan), ret);                                                                   \
       MC_assert(not MC_is_active()); /* Only fail in MC mode */                                                        \
     }                                                                                                                  \
     XBT_VERB("SMPI - Leaving %s", __func__);                                                                           \
index b487d2b..7f6f627 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
 #define CHECK_ARGS(test, errcode, ...)                                                                                 \
   if (test) {                                                                                                          \
     XBT_WARN(__VA_ARGS__);                                                                                             \
-    return errcode;                                                                                                    \
+    return (errcode);                                                                                                  \
   }
 
 /* PMPI User level calls */
index 41e1a38..3680ca9 100644 (file)
@@ -38,19 +38,36 @@ int PMPI_File_close(MPI_File *fh){
   smpi_bench_begin();
   return ret;
 }
-#define CHECK_FILE(fh) if(fh==MPI_FILE_NULL) return MPI_ERR_FILE;
-#define CHECK_BUFFER(buf, count)  if (buf==nullptr && count > 0) return MPI_ERR_BUFFER;
-#define CHECK_COUNT(count)  if (count < 0) return MPI_ERR_COUNT;
-#define CHECK_OFFSET(offset)  if (offset < 0) return MPI_ERR_DISP;
-#define CHECK_DATATYPE(datatype, count) if (datatype == MPI_DATATYPE_NULL && count > 0) return MPI_ERR_TYPE;
-#define CHECK_STATUS(status) if (status == nullptr) return MPI_ERR_ARG;
-#define CHECK_FLAGS(fh) if (fh->flags() & MPI_MODE_SEQUENTIAL) return MPI_ERR_AMODE;
-#define CHECK_RDONLY(fh) if (fh->flags() & MPI_MODE_RDONLY ) return MPI_ERR_AMODE;
-
-#define PASS_ZEROCOUNT(count) if (count == 0) {\
-status->count=0;\
-return MPI_SUCCESS;\
-}
+#define CHECK_FILE(fh)                                                                                                 \
+  if ((fh) == MPI_FILE_NULL)                                                                                           \
+    return MPI_ERR_FILE;
+#define CHECK_BUFFER(buf, count)                                                                                       \
+  if ((buf) == nullptr && (count) > 0)                                                                                 \
+    return MPI_ERR_BUFFER;
+#define CHECK_COUNT(count)                                                                                             \
+  if ((count) < 0)                                                                                                     \
+    return MPI_ERR_COUNT;
+#define CHECK_OFFSET(offset)                                                                                           \
+  if ((offset) < 0)                                                                                                    \
+    return MPI_ERR_DISP;
+#define CHECK_DATATYPE(datatype, count)                                                                                \
+  if ((datatype) == MPI_DATATYPE_NULL && (count) > 0)                                                                  \
+    return MPI_ERR_TYPE;
+#define CHECK_STATUS(status)                                                                                           \
+  if ((status) == nullptr)                                                                                             \
+    return MPI_ERR_ARG;
+#define CHECK_FLAGS(fh)                                                                                                \
+  if ((fh)->flags() & MPI_MODE_SEQUENTIAL)                                                                             \
+    return MPI_ERR_AMODE;
+#define CHECK_RDONLY(fh)                                                                                               \
+  if ((fh)->flags() & MPI_MODE_RDONLY)                                                                                 \
+    return MPI_ERR_AMODE;
+
+#define PASS_ZEROCOUNT(count)                                                                                          \
+  if ((count) == 0) {                                                                                                  \
+    status->count = 0;                                                                                                 \
+    return MPI_SUCCESS;                                                                                                \
+  }
 
 int PMPI_File_seek(MPI_File fh, MPI_Offset offset, int whence){
   CHECK_FILE(fh);
index 01e5727..73a6556 100644 (file)
@@ -59,10 +59,11 @@ extern XBT_PUBLIC int mpi_statuses_ignore_;
 #define FORT_ADDR(addr, val, val2)                                         \
   (((void *)(addr) == (void*) &(val2))                  \
    ? (val) : (void *)(addr))
-#define FORT_BOTTOM(addr)          FORT_ADDR(addr, MPI_BOTTOM, mpi_bottom_)
-#define FORT_IN_PLACE(addr)        FORT_ADDR(addr, MPI_IN_PLACE, mpi_in_place_)
-#define FORT_STATUS_IGNORE(addr)   static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUS_IGNORE, mpi_status_ignore_))
-#define FORT_STATUSES_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR(addr, MPI_STATUSES_IGNORE, mpi_statuses_ignore_))
+#define FORT_BOTTOM(addr) FORT_ADDR((addr), MPI_BOTTOM, mpi_bottom_)
+#define FORT_IN_PLACE(addr) FORT_ADDR((addr), MPI_IN_PLACE, mpi_in_place_)
+#define FORT_STATUS_IGNORE(addr) static_cast<MPI_Status*>(FORT_ADDR((addr), MPI_STATUS_IGNORE, mpi_status_ignore_))
+#define FORT_STATUSES_IGNORE(addr)                                                                                     \
+  static_cast<MPI_Status*>(FORT_ADDR((addr), MPI_STATUSES_IGNORE, mpi_statuses_ignore_))
 
 extern XBT_PRIVATE MPI_Comm MPI_COMM_UNINITIALIZED;
 
index de20019..18cdacb 100644 (file)
@@ -107,7 +107,7 @@ static void* asan_safe_memcpy(void* dest, void* src, size_t n)
   return dest;
 }
 #else
-#define asan_safe_memcpy(dest, src, n) memcpy(dest, src, n)
+#define asan_safe_memcpy(dest, src, n) memcpy((dest), (src), (n))
 #endif
 
 /** Map a given SMPI privatization segment (make a SMPI process active)
index a22b3d4..d4257b1 100644 (file)
@@ -18,18 +18,18 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_datatype, smpi, "Logging specific to SMPI (
 static std::unordered_map<std::string, simgrid::smpi::Datatype*> id2type_lookup;
 
 #define CREATE_MPI_DATATYPE(name, id, type)                                                                            \
-  static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), id, sizeof(type), /* size */     \
-                                                         0,                                             /* lb */       \
+  static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), (id), sizeof(type), /* size */   \
+                                                         0,                                               /* lb */     \
                                                          sizeof(type), /* ub = lb + size */                            \
                                                          DT_FLAG_BASIC /* flags */                                     \
                                                          );                                                            \
   const MPI_Datatype name = &_XBT_CONCAT(mpi_, name);
 
 #define CREATE_MPI_DATATYPE_NULL(name, id)                                                                             \
-  static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), id, 0, /* size */                \
-                                                         0,                                  /* lb */                  \
-                                                         0,                                  /* ub = lb + size */      \
-                                                         DT_FLAG_BASIC                       /* flags */               \
+  static simgrid::smpi::Datatype _XBT_CONCAT(mpi_, name)((char*)_XBT_STRINGIFY(name), (id), 0, /* size */              \
+                                                         0,                                    /* lb */                \
+                                                         0,                                    /* ub = lb + size */    \
+                                                         DT_FLAG_BASIC                         /* flags */             \
                                                          );                                                            \
   const MPI_Datatype name = &_XBT_CONCAT(mpi_, name);
 
index 008839b..4a18f6e 100644 (file)
@@ -13,17 +13,27 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)");
 #define MAX_OP(a, b)  (b) = (a) < (b) ? (b) : (a)
 #define MIN_OP(a, b)  (b) = (a) < (b) ? (a) : (b)
 #define SUM_OP(a, b)  (b) += (a)
-#define SUM_OP_COMPLEX(a, b) {(b.value) += (a.value);(b.index) += (a.index);}
+#define SUM_OP_COMPLEX(a, b)                                                                                           \
+  {                                                                                                                    \
+    ((b).value) += ((a).value);                                                                                        \
+    ((b).index) += ((a).index);                                                                                        \
+  }
 #define PROD_OP(a, b) (b) *= (a)
-#define PROD_OP_COMPLEX(a, b) {(b.value) *= (a.value);(b.index) *= (a.index);}
+#define PROD_OP_COMPLEX(a, b)                                                                                          \
+  {                                                                                                                    \
+    ((b).value) *= ((a).value);                                                                                        \
+    ((b).index) *= ((a).index);                                                                                        \
+  }
 #define LAND_OP(a, b) (b) = (a) && (b)
 #define LOR_OP(a, b)  (b) = (a) || (b)
 #define LXOR_OP(a, b) (b) = (not(a) && (b)) || ((a) && not(b))
 #define BAND_OP(a, b) (b) &= (a)
 #define BOR_OP(a, b)  (b) |= (a)
 #define BXOR_OP(a, b) (b) ^= (a)
-#define MAXLOC_OP(a, b)  (b) = (a.value) < (b.value) ? (b) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (a))
-#define MINLOC_OP(a, b)  (b) = (a.value) < (b.value) ? (a) : ((a.value) == (b.value) ? ((a.index) < (b.index) ? (a) : (b)) : (b))
+#define MAXLOC_OP(a, b)                                                                                                \
+  (b) = ((a).value) < ((b).value) ? (b) : (((a).value) == ((b).value) ? (((a).index) < ((b).index) ? (a) : (b)) : (a))
+#define MINLOC_OP(a, b)                                                                                                \
+  (b) = ((a).value) < ((b).value) ? (a) : (((a).value) == ((b).value) ? (((a).index) < ((b).index) ? (a) : (b)) : (b))
 
 #define APPLY_FUNC(a, b, length, type, func) \
 {                                          \
@@ -35,11 +45,10 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)");
   }                                        \
 }
 
-#define APPLY_OP_LOOP(dtype, type, op) \
-  if (*datatype == dtype) {\
-    APPLY_FUNC(a, b, length, type, op)\
-  } else \
-
+#define APPLY_OP_LOOP(dtype, type, op)                                                                                 \
+  if (*datatype == (dtype)) {                                                                                          \
+    APPLY_FUNC(a, b, length, type, op)                                                                                 \
+  } else
 
 #define APPLY_BASIC_OP_LOOP(op)\
 APPLY_OP_LOOP(MPI_CHAR, char,op)\
index da361ca..ca08c21 100644 (file)
@@ -191,7 +191,7 @@ XBT_PUBLIC void model_help(const char* category, const std::vector<surf_model_de
 #define SIMGRID_REGISTER_PLUGIN(id, desc, init)                                                                        \
   static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _plugin_register)()                               \
   {                                                                                                                    \
-    simgrid_add_plugin_description(_XBT_STRINGIFY(id), desc, init);                                                    \
+    simgrid_add_plugin_description(_XBT_STRINGIFY(id), (desc), (init));                                                \
   }
 
 XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);
index 9e1c9b0..46fe161 100644 (file)
@@ -286,8 +286,8 @@ XBT_PUBLIC void* mmorecore(struct mdesc* mdp, ssize_t size);
  * in a model-checking enabled tree. Without this protection, our malloc
  * implementation will not like multi-threading AT ALL.
  */
-#define LOCK(mdp) pthread_mutex_lock(&mdp->mutex)
-#define UNLOCK(mdp) pthread_mutex_unlock(&mdp->mutex)
+#define LOCK(mdp) pthread_mutex_lock(&(mdp)->mutex)
+#define UNLOCK(mdp) pthread_mutex_unlock(&(mdp)->mutex)
 
 XBT_PRIVATE int malloc_use_mmalloc(void);
 
index daec92c..6a675dd 100644 (file)
@@ -40,32 +40,33 @@ static constexpr const char* ERRMSG =
     }                                                                   \
   } else (void)0
 
-#define show_it(data, letter)                                           \
-  if (1) {                                                              \
-    int len;                                                            \
-    int wd;                                                             \
-    if (length == -1) {                                                 \
-      wd = 0;                                                           \
-    } else {                                                            \
-      wd = length;                                                      \
-      length = -1;                                                      \
-    }                                                                   \
-    if (precision == -1) {                                              \
-      len = snprintf(p, rem_size, "%*" letter, wd, data);               \
-    } else {                                                            \
-      len = snprintf(p, rem_size, "%*.*" letter, wd, precision, data);  \
-      precision = -1;                                                   \
-    }                                                                   \
-    check_overflow(len);                                                \
-  } else (void)0
+#define show_it(data, letter)                                                                                          \
+  if (1) {                                                                                                             \
+    int len;                                                                                                           \
+    int wd;                                                                                                            \
+    if (length == -1) {                                                                                                \
+      wd = 0;                                                                                                          \
+    } else {                                                                                                           \
+      wd     = length;                                                                                                 \
+      length = -1;                                                                                                     \
+    }                                                                                                                  \
+    if (precision == -1) {                                                                                             \
+      len = snprintf(p, rem_size, "%*" letter, wd, (data));                                                            \
+    } else {                                                                                                           \
+      len       = snprintf(p, rem_size, "%*.*" letter, wd, precision, (data));                                         \
+      precision = -1;                                                                                                  \
+    }                                                                                                                  \
+    check_overflow(len);                                                                                               \
+  } else                                                                                                               \
+  (void)0
 
 #define show_string(data)                                               \
   if (1) {                                                              \
     const char *show_string_data = (data);                              \
     show_it(show_string_data ? show_string_data : "(null)", "s");       \
   } else (void)0
-#define show_int(data)    show_it(data, "d")
-#define show_double(data) show_it(data, "f")
+#define show_int(data) show_it((data), "d")
+#define show_double(data) show_it((data), "f")
 
 static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, const char* msg_fmt)
 {
index 6e7761c..62b886b 100644 (file)
@@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
 namespace lmm = simgrid::kernel::lmm;
 
 #define PRINT_VAR(var) XBT_DEBUG(_XBT_STRINGIFY(var) " = %g", (var)->get_value())
-#define SHOW_EXPR(expr) XBT_DEBUG(_XBT_STRINGIFY(expr) " = %g", expr)
+#define SHOW_EXPR(expr) XBT_DEBUG(_XBT_STRINGIFY(expr) " = %g", (expr))
 
 /*        ______                 */
 /*  ==l1==  L2  ==L3==           */
index 9b11df4..9217257 100644 (file)
@@ -20,7 +20,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test,"this test");
 constexpr int BUFFSIZE = 204800;
 constexpr int TESTSIZE = 100;
 
-#define size_of_block(i) (((i % 50)+1)* 100)
+#define size_of_block(i) ((((i) % 50) + 1) * 100)
 
 static void check_block(const unsigned char* p, unsigned char b, int n)
 {