From 2d876f901f44194d3e67936fd054b192a6b7f097 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Wed, 8 Jun 2016 23:20:59 +0200 Subject: [PATCH] [MSG] NULL -> nullptr substitution I used the following command: (the '**' means recursion in ZSH) sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp We check for the underscore to avoid replacing MPI_*_NULL --- src/msg/instr_msg_task.cpp | 12 +++---- src/msg/msg_actions.cpp | 8 ++--- src/msg/msg_environment.cpp | 4 +-- src/msg/msg_global.cpp | 10 +++--- src/msg/msg_gos.cpp | 68 ++++++++++++++++++------------------- src/msg/msg_host.cpp | 30 ++++++++-------- src/msg/msg_io.cpp | 32 ++++++++--------- src/msg/msg_mailbox.cpp | 6 ++-- src/msg/msg_process.cpp | 64 +++++++++++++++++----------------- src/msg/msg_task.cpp | 42 +++++++++++------------ src/msg/msg_vm.cpp | 34 +++++++++---------- 11 files changed, 155 insertions(+), 155 deletions(-) diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp index 58aad0bb6d..86e05eea44 100644 --- a/src/msg/instr_msg_task.cpp +++ b/src/msg/instr_msg_task.cpp @@ -12,13 +12,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_msg, instr, "MSG"); void TRACE_msg_set_task_category(msg_task_t task, const char *category) { - xbt_assert(task->category == NULL, "Task %p(%s) already has a category (%s).", + xbt_assert(task->category == nullptr, "Task %p(%s) already has a category (%s).", task, task->name, task->category); - //if user provides a NULL category, task is no longer traced - if (category == NULL) { + //if user provides a nullptr category, task is no longer traced + if (category == nullptr) { xbt_free (task->category); - task->category = NULL; + task->category = nullptr; XBT_DEBUG("MSG task %p(%s), category removed", task, task->name); return; } @@ -33,7 +33,7 @@ void TRACE_msg_task_create(msg_task_t task) { static long long counter = 0; task->counter = counter++; - task->category = NULL; + task->category = nullptr; if(MC_is_active()) MC_ignore_heap(&(task->counter), sizeof(task->counter)); @@ -78,7 +78,7 @@ void TRACE_msg_task_destroy(msg_task_t task) //free category xbt_free(task->category); - task->category = NULL; + task->category = nullptr; return; } diff --git a/src/msg/msg_actions.cpp b/src/msg/msg_actions.cpp index 1fd0b4133a..85f009f5a9 100644 --- a/src/msg/msg_actions.cpp +++ b/src/msg/msg_actions.cpp @@ -26,7 +26,7 @@ void MSG_action_exit() /** \ingroup msg_trace_driven * \brief A trace loader * - * If path!=NULL, load a trace file containing actions, and execute them. + * If path!=nullptr, load a trace file containing actions, and execute them. * Else, assume that each process gets the path in its deployment file */ msg_error_t MSG_action_trace_run(char *path) @@ -36,10 +36,10 @@ msg_error_t MSG_action_trace_run(char *path) xbt_dynar_t todo; xbt_dict_cursor_t cursor; - xbt_action_fp=NULL; + xbt_action_fp=nullptr; if (path) { xbt_action_fp = fopen(path, "r"); - xbt_assert(xbt_action_fp != NULL, "Cannot open %s: %s", path, strerror(errno)); + xbt_assert(xbt_action_fp != nullptr, "Cannot open %s: %s", path, strerror(errno)); } res = MSG_main(); @@ -55,7 +55,7 @@ msg_error_t MSG_action_trace_run(char *path) if (path) fclose(xbt_action_fp); xbt_dict_free(&xbt_action_queues); - xbt_action_queues = xbt_dict_new_homogeneous(NULL); + xbt_action_queues = xbt_dict_new_homogeneous(nullptr); return res; } diff --git a/src/msg/msg_environment.cpp b/src/msg/msg_environment.cpp index 2b19c7693d..27a367350f 100644 --- a/src/msg/msg_environment.cpp +++ b/src/msg/msg_environment.cpp @@ -69,8 +69,8 @@ xbt_dict_t MSG_environment_as_get_routing_sons(msg_as_t as) { const char *MSG_environment_as_get_property_value(msg_as_t as, const char *name) { xbt_dict_t dict = (xbt_dict_t) xbt_lib_get_or_null(as_router_lib, MSG_environment_as_get_name(as), ROUTING_PROP_ASR_LEVEL); - if (dict==NULL) - return NULL; + if (dict==nullptr) + return nullptr; return (char*) xbt_dict_get_or_null(dict, name); } diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index d882de4b27..0e45156d05 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -16,7 +16,7 @@ XBT_LOG_NEW_CATEGORY(msg, "All MSG categories"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_kernel, msg, "Logging specific to MSG (kernel)"); -MSG_Global_t msg_global = NULL; +MSG_Global_t msg_global = nullptr; static void MSG_exit(void); /********************************* MSG **************************************/ @@ -51,8 +51,8 @@ void MSG_init_nocheck(int *argc, char **argv) { SIMIX_global_init(argc, argv); msg_global->sent_msg = 0; - msg_global->task_copy_callback = NULL; - msg_global->process_data_cleanup = NULL; + msg_global->task_copy_callback = nullptr; + msg_global->process_data_cleanup = nullptr; SIMIX_function_register_process_create(MSG_process_create_from_SIMIX); SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX); @@ -127,13 +127,13 @@ int MSG_process_killall(int reset_PIDs) } static void MSG_exit(void) { - if (msg_global==NULL) + if (msg_global==nullptr) return; TRACE_surf_resource_utilization_release(); TRACE_end(); free(msg_global); - msg_global = NULL; + msg_global = nullptr; } /** \ingroup msg_simulation diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index becc04b412..6aa14754e6 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -51,7 +51,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) TRACE_msg_task_execute_start(task); xbt_assert((!simdata->compute) && (task->simdata->isused == 0), - "This task is executed somewhere else. Go fix your code! %d", task->simdata->isused!=NULL); + "This task is executed somewhere else. Go fix your code! %d", task->simdata->isused!=nullptr); XBT_DEBUG("Computing on %s", MSG_process_get_name(MSG_process_self())); @@ -87,7 +87,7 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) p_simdata->waiting_action = simdata->compute; comp_state = simcall_execution_wait(simdata->compute); - p_simdata->waiting_action = NULL; + p_simdata->waiting_action = nullptr; if (msg_global->debug_multiple_use && simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)simdata->isused); @@ -108,10 +108,10 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task) } xbt_ex_free(e); } - /* action ended, set comm and compute = NULL, the actions is already destroyed in the main function */ + /* action ended, set comm and compute = nullptr, the actions is already destroyed in the main function */ simdata->flops_amount = 0.0; - simdata->comm = NULL; - simdata->compute = NULL; + simdata->comm = nullptr; + simdata->compute = nullptr; TRACE_msg_task_execute_end(task); MSG_RETURN(status); @@ -208,7 +208,7 @@ msg_error_t MSG_task_receive_bounded(msg_task_t * task, const char *alias, doubl */ msg_error_t MSG_task_receive_with_timeout(msg_task_t * task, const char *alias, double timeout) { - return MSG_task_receive_ext(task, alias, timeout, NULL); + return MSG_task_receive_ext(task, alias, timeout, nullptr); } /** \ingroup msg_task_usage @@ -225,7 +225,7 @@ msg_error_t MSG_task_receive_with_timeout(msg_task_t * task, const char *alias, */ msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias, double timeout,double rate) { - return MSG_task_receive_ext_bounded(task, alias, timeout, NULL, rate); + return MSG_task_receive_ext_bounded(task, alias, timeout, nullptr, rate); } /** \ingroup msg_task_usage @@ -290,7 +290,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al int (*match_fun)(void*,void*, smx_synchro_t), void *match_data, void_f_pvoid_t cleanup, int detached) { - simdata_task_t t_simdata = NULL; + simdata_task_t t_simdata = nullptr; msg_process_t process = MSG_process_self(); msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias); int call_end = TRACE_msg_task_put_start(task); @@ -317,21 +317,21 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al MSG_BT(t_simdata->isused, "Using Backtrace"); else t_simdata->isused = (void*)1; - t_simdata->comm = NULL; + t_simdata->comm = nullptr; msg_global->sent_msg++; /* Send it by calling SIMIX network layer */ smx_synchro_t act = simcall_comm_isend(SIMIX_process_self(), mailbox, t_simdata->bytes_amount, t_simdata->rate, - task, sizeof(void *), match_fun, cleanup, NULL, match_data,detached); + task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached); t_simdata->comm = static_cast(act); /* FIXME: is the field t_simdata->comm still useful? */ msg_comm_t comm; if (detached) { - comm = NULL; + comm = nullptr; } else { comm = xbt_new0(s_msg_comm_t, 1); comm->task_sent = task; - comm->task_received = NULL; + comm->task_received = nullptr; comm->status = MSG_OK; comm->s_comm = act; } @@ -355,7 +355,7 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al */ msg_comm_t MSG_task_isend(msg_task_t task, const char *alias) { - return MSG_task_isend_internal(task, alias, NULL, NULL, NULL, 0); + return MSG_task_isend_internal(task, alias, nullptr, nullptr, nullptr, 0); } /** \ingroup msg_task_usage @@ -372,7 +372,7 @@ msg_comm_t MSG_task_isend(msg_task_t task, const char *alias) msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate) { task->simdata->rate = maxrate; - return MSG_task_isend_internal(task, alias, NULL, NULL, NULL, 0); + return MSG_task_isend_internal(task, alias, nullptr, nullptr, nullptr, 0); } /** \ingroup msg_task_usage @@ -392,7 +392,7 @@ msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double max msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias, int (*match_fun)(void*, void*, smx_synchro_t), void *match_data) { - return MSG_task_isend_internal(task, alias, match_fun, match_data, NULL, 0); + return MSG_task_isend_internal(task, alias, match_fun, match_data, nullptr, 0); } /** \ingroup msg_task_usage @@ -408,11 +408,11 @@ msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias, * \param task a #msg_task_t to send on another location. * \param alias name of the mailbox to sent the task to * \param cleanup a function to destroy the task if the communication fails, e.g. MSG_task_destroy - * (if NULL, no function will be called) + * (if nullptr, no function will be called) */ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup) { - MSG_task_isend_internal(task, alias, NULL, NULL, cleanup, 1); + MSG_task_isend_internal(task, alias, nullptr, nullptr, cleanup, 1); } /** \ingroup msg_task_usage @@ -429,7 +429,7 @@ void MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup) * \param alias name of the mailbox to sent the task to * \param cleanup a function to destroy the task if the * communication fails, e.g. MSG_task_destroy - * (if NULL, no function will be called) + * (if nullptr, no function will be called) * \param maxrate the maximum communication rate for sending this task * */ @@ -474,10 +474,10 @@ msg_comm_t MSG_task_irecv_bounded(msg_task_t *task, const char *name, double rat /* Try to receive it by calling SIMIX network layer */ msg_comm_t comm = xbt_new0(s_msg_comm_t, 1); - comm->task_sent = NULL; + comm->task_sent = nullptr; comm->task_received = task; comm->status = MSG_OK; - comm->s_comm = simcall_comm_irecv(MSG_process_self(), rdv, task, NULL, NULL, NULL, NULL, rate); + comm->s_comm = simcall_comm_irecv(MSG_process_self(), rdv, task, nullptr, nullptr, nullptr, nullptr, rate); return comm; } @@ -498,7 +498,7 @@ int MSG_comm_test(msg_comm_t comm) TRY { finished = simcall_comm_test(comm->s_comm); - if (finished && comm->task_received != NULL) { + if (finished && comm->task_received != nullptr) { /* I am the receiver */ if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused); @@ -537,7 +537,7 @@ int MSG_comm_testany(xbt_dynar_t comms) int finished_index = -1; /* create the equivalent dynar with SIMIX objects */ - xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_synchro_t), NULL); + xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_synchro_t), nullptr); msg_comm_t comm; unsigned int cursor; xbt_dynar_foreach(comms, cursor, comm) { @@ -570,7 +570,7 @@ int MSG_comm_testany(xbt_dynar_t comms) /* the communication is finished */ comm->status = status; - if (status == MSG_OK && comm->task_received != NULL) { + if (status == MSG_OK && comm->task_received != nullptr) { /* I am the receiver */ if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused); @@ -605,7 +605,7 @@ msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout) TRY { simcall_comm_wait(comm->s_comm, timeout); - if (comm->task_received != NULL) { + if (comm->task_received != nullptr) { /* I am the receiver */ if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused); @@ -658,7 +658,7 @@ int MSG_comm_waitany(xbt_dynar_t comms) int finished_index = -1; /* create the equivalent dynar with SIMIX objects */ - xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_synchro_t), NULL); + xbt_dynar_t s_comms = xbt_dynar_new(sizeof(smx_synchro_t), nullptr); msg_comm_t comm; unsigned int cursor; xbt_dynar_foreach(comms, cursor, comm) { @@ -692,7 +692,7 @@ int MSG_comm_waitany(xbt_dynar_t comms) /* the communication is finished */ comm->status = status; - if (comm->task_received != NULL) { + if (comm->task_received != nullptr) { /* I am the receiver */ if (msg_global->debug_multiple_use && (*comm->task_received)->simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)(*comm->task_received)->simdata->isused); @@ -799,7 +799,7 @@ msg_error_t MSG_task_send_bounded(msg_task_t task, const char *alias, double max msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout) { msg_error_t ret = MSG_OK; - simdata_task_t t_simdata = NULL; + simdata_task_t t_simdata = nullptr; msg_process_t process = MSG_process_self(); simdata_process_t p_simdata = (simdata_process_t) SIMIX_process_self_get_data(); msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias); @@ -828,7 +828,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl MSG_BT(t_simdata->isused, "Using Backtrace"); else t_simdata->isused = (void*)1; - t_simdata->comm = NULL; + t_simdata->comm = nullptr; msg_global->sent_msg++; p_simdata->waiting_task = task; @@ -836,9 +836,9 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl xbt_ex_t e; /* Try to send it by calling SIMIX network layer */ TRY { - smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simix call */ + smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simix call */ comm = simcall_comm_isend(SIMIX_process_self(), mailbox,t_simdata->bytes_amount, - t_simdata->rate, task, sizeof(void *), NULL, NULL, NULL, task, 0); + t_simdata->rate, task, sizeof(void *), nullptr, nullptr, nullptr, task, 0); if (TRACE_is_enabled()) simcall_set_category(comm, task->category); t_simdata->comm = static_cast(comm); @@ -867,7 +867,7 @@ msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char *alias, doubl t_simdata->isused = 0; } - p_simdata->waiting_task = NULL; + p_simdata->waiting_task = nullptr; if (call_end) TRACE_msg_task_put_end(); MSG_RETURN(ret); @@ -917,7 +917,7 @@ int MSG_task_listen_from(const char *alias) { msg_task_t task; - if (NULL == (task = MSG_mailbox_front(MSG_mailbox_get_by_alias(alias)))) + if (nullptr == (task = MSG_mailbox_front(MSG_mailbox_get_by_alias(alias)))) return -1; return MSG_process_get_PID(task->simdata->sender); @@ -951,7 +951,7 @@ void MSG_task_set_category (msg_task_t task, const char *category) * * \see MSG_task_set_category * - * \return Returns the name of the tracing category of the given task, NULL otherwise + * \return Returns the name of the tracing category of the given task, nullptr otherwise */ const char *MSG_task_get_category (msg_task_t task) { @@ -963,7 +963,7 @@ const char *MSG_task_get_category (msg_task_t task) * * \param asr the name of a router or AS * \param name a property name - * \return value of a property (or NULL if property not set) + * \return value of a property (or nullptr if property not set) */ const char *MSG_as_router_get_property_value(const char* asr, const char *name) { diff --git a/src/msg/msg_host.cpp b/src/msg/msg_host.cpp index 917421da5c..e8db32ad32 100644 --- a/src/msg/msg_host.cpp +++ b/src/msg/msg_host.cpp @@ -31,9 +31,9 @@ msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our paramete priv->dp_updated_by_deleted_tasks = 0; priv->is_migrating = 0; - priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL); + priv->affinity_mask_db = xbt_dict_new_homogeneous(nullptr); - priv->file_descriptor_table = xbt_dynar_new(sizeof(int), NULL); + priv->file_descriptor_table = xbt_dynar_new(sizeof(int), nullptr); for (int i=1023; i>=0;i--) xbt_dynar_push_as(priv->file_descriptor_table, int, i); @@ -81,7 +81,7 @@ void *MSG_host_get_data(msg_host_t host) { */ msg_host_t MSG_host_self(void) { - return MSG_process_get_host(NULL); + return MSG_process_get_host(nullptr); } /** \ingroup m_host_management @@ -113,7 +113,7 @@ void MSG_host_off(msg_host_t host) */ void __MSG_host_priv_free(msg_host_priv_t priv) { - if (priv == NULL) + if (priv == nullptr) return; unsigned int size = xbt_dict_size(priv->dp_objs); if (size > 0) @@ -177,7 +177,7 @@ int MSG_host_get_core_number(msg_host_t host) { */ xbt_swag_t MSG_host_get_process_list(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters"); + xbt_assert((host != nullptr), "Invalid parameters"); return host->processes(); } @@ -186,7 +186,7 @@ xbt_swag_t MSG_host_get_process_list(msg_host_t host) * * \param host a host * \param name a property name - * \return value of a property (or NULL if property not set) + * \return value of a property (or nullptr if property not set) */ const char *MSG_host_get_property_value(msg_host_t host, const char *name) { @@ -201,7 +201,7 @@ const char *MSG_host_get_property_value(msg_host_t host, const char *name) */ xbt_dict_t MSG_host_get_properties(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); + xbt_assert((host != nullptr), "Invalid parameters (host is nullptr)"); return host->properties(); } @@ -270,7 +270,7 @@ void MSG_host_get_params(msg_host_t host, vm_params_t params) * \return Returns the processor speed associated with pstate_index */ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) { - xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); + xbt_assert((host != nullptr), "Invalid parameters (host is nullptr)"); return host->powerPeakAt(pstate_index); } @@ -281,7 +281,7 @@ double MSG_host_get_power_peak_at(msg_host_t host, int pstate_index) { * \return Returns the current processor speed */ double MSG_host_get_current_power_peak(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters (host is NULL)"); + xbt_assert((host != nullptr), "Invalid parameters (host is nullptr)"); return host->currentPowerPeak(); } @@ -301,7 +301,7 @@ int MSG_host_get_nb_pstates(msg_host_t host) { */ xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters"); + xbt_assert((host != nullptr), "Invalid parameters"); return host->mountedStoragesAsDict(); } @@ -312,7 +312,7 @@ xbt_dict_t MSG_host_get_mounted_storage_list(msg_host_t host) */ xbt_dynar_t MSG_host_get_attached_storage_list(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters"); + xbt_assert((host != nullptr), "Invalid parameters"); return host->attachedStorages(); } @@ -323,19 +323,19 @@ xbt_dynar_t MSG_host_get_attached_storage_list(msg_host_t host) */ xbt_dict_t MSG_host_get_storage_content(msg_host_t host) { - xbt_assert((host != NULL), "Invalid parameters"); - xbt_dict_t contents = xbt_dict_new_homogeneous(NULL); + xbt_assert((host != nullptr), "Invalid parameters"); + xbt_dict_t contents = xbt_dict_new_homogeneous(nullptr); msg_storage_t storage; char* storage_name; char* mount_name; - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; xbt_dict_t storage_list = host->mountedStoragesAsDict(); xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){ storage = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib,storage_name); xbt_dict_t content = simcall_storage_get_content(storage); - xbt_dict_set(contents,mount_name, content,NULL); + xbt_dict_set(contents,mount_name, content,nullptr); } xbt_dict_free(&storage_list); return contents; diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index b5f2a2b21e..7faed3261f 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -101,7 +101,7 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){ /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */ XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size); - msg_host_t *m_host_list = NULL; + msg_host_t *m_host_list = nullptr; m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t)); m_host_list[0] = MSG_host_self(); @@ -110,7 +110,7 @@ sg_size_t MSG_file_read(msg_file_t fd, sg_size_t size) double bytes_amount[] = { 0, 0, (double)read_size, 0 }; msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount, - NULL); + nullptr); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -145,7 +145,7 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) if(strcmp(storage_priv_src->hostname, MSG_host_get_name(MSG_host_self()))){ /* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */ XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size); - msg_host_t *m_host_list = NULL; + msg_host_t *m_host_list = nullptr; m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t)); m_host_list[0] = MSG_host_self(); @@ -154,7 +154,7 @@ sg_size_t MSG_file_write(msg_file_t fd, sg_size_t size) double bytes_amount[] = { 0, (double)size, 0, 0 }; msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, - NULL); + nullptr); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -286,7 +286,7 @@ sg_size_t MSG_file_tell(msg_file_t fd) } const char *MSG_file_get_name(msg_file_t fd) { - xbt_assert((fd != NULL), "Invalid parameters"); + xbt_assert((fd != nullptr), "Invalid parameters"); msg_file_priv_t priv = MSG_file_priv(fd); return priv->fullpath; } @@ -323,8 +323,8 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa read_size = simcall_file_read(file_priv->simdata->smx_file, file_priv->size, attached_host); /* Find the real host destination where the file will be physically stored */ - xbt_dict_cursor_t cursor = NULL; - msg_storage_t storage_dest = NULL; + xbt_dict_cursor_t cursor = nullptr; + msg_storage_t storage_dest = nullptr; msg_host_t host_dest; size_t longest_prefix_length = 0; @@ -357,7 +357,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname, host_name_dest); - msg_host_t *m_host_list = NULL; + msg_host_t *m_host_list = nullptr; m_host_list = (msg_host_t*) calloc(2, sizeof(msg_host_t)); m_host_list[0] = attached_host; @@ -366,7 +366,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa double bytes_amount[] = { 0, (double)read_size, 0, 0 }; msg_task_t task = - MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, NULL); + MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, nullptr); msg_error_t transfer = MSG_parallel_task_execute(task); MSG_task_destroy(task); free(m_host_list); @@ -439,7 +439,7 @@ void __MSG_storage_destroy(msg_storage_priv_t storage) { * This functions checks whether a storage is a valid pointer or not and return its name. */ const char *MSG_storage_get_name(msg_storage_t storage) { - xbt_assert((storage != NULL), "Invalid parameters"); + xbt_assert((storage != nullptr), "Invalid parameters"); return SIMIX_storage_get_name(storage); } @@ -468,7 +468,7 @@ sg_size_t MSG_storage_get_used_size(msg_storage_t storage){ */ xbt_dict_t MSG_storage_get_properties(msg_storage_t storage) { - xbt_assert((storage != NULL), "Invalid parameters (storage is NULL)"); + xbt_assert((storage != nullptr), "Invalid parameters (storage is nullptr)"); return (simcall_storage_get_properties(storage)); } @@ -489,7 +489,7 @@ void MSG_storage_set_property_value(msg_storage_t storage, const char *name, cha * * \param storage a storage * \param name a property name - * \return value of a property (or NULL if property not set) + * \return value of a property (or nullptr if property not set) */ const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name) { @@ -513,10 +513,10 @@ xbt_dynar_t MSG_storages_as_dynar(void) { xbt_lib_cursor_t cursor; char *key; void **data; - xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),NULL); + xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr); xbt_lib_foreach(storage_lib, cursor, key, data) { - if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), MSG_STORAGE_LEVEL) != NULL) { + if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), MSG_STORAGE_LEVEL) != nullptr) { xbt_dictelm_t elm = xbt_dict_cursor_get_elm(cursor); xbt_dynar_push(res, &elm); } @@ -544,7 +544,7 @@ msg_error_t MSG_storage_set_data(msg_storage_t storage, void *data) */ void *MSG_storage_get_data(msg_storage_t storage) { - xbt_assert((storage != NULL), "Invalid parameters"); + xbt_assert((storage != nullptr), "Invalid parameters"); msg_storage_priv_t priv = MSG_storage_priv(storage); return priv->data; } @@ -578,7 +578,7 @@ sg_size_t MSG_storage_get_size(msg_storage_t storage) * This functions checks whether a storage is a valid pointer or not and return its name. */ const char *MSG_storage_get_host(msg_storage_t storage) { - xbt_assert((storage != NULL), "Invalid parameters"); + xbt_assert((storage != nullptr), "Invalid parameters"); msg_storage_priv_t priv = MSG_storage_priv(storage); return priv->hostname; } diff --git a/src/msg/msg_mailbox.cpp b/src/msg/msg_mailbox.cpp index 1594821770..c1285661b3 100644 --- a/src/msg/msg_mailbox.cpp +++ b/src/msg/msg_mailbox.cpp @@ -18,7 +18,7 @@ msg_mailbox_t MSG_mailbox_new(const char *alias) int MSG_mailbox_is_empty(msg_mailbox_t mailbox) { - return (NULL == simcall_mbox_front(mailbox)); + return (nullptr == simcall_mbox_front(mailbox)); } msg_task_t MSG_mailbox_front(msg_mailbox_t mailbox) @@ -26,7 +26,7 @@ msg_task_t MSG_mailbox_front(msg_mailbox_t mailbox) simgrid::simix::Comm* comm = static_cast(simcall_mbox_front(mailbox)); if (!comm) - return NULL; + return nullptr; return (msg_task_t) comm->src_data; } @@ -107,7 +107,7 @@ msg_error_t MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t * /* Try to receive it by calling SIMIX network layer */ TRY { - simcall_comm_recv(MSG_process_self(), mailbox, task, NULL, NULL, NULL, NULL, timeout, rate); + simcall_comm_recv(MSG_process_self(), mailbox, task, nullptr, nullptr, nullptr, nullptr, timeout, rate); XBT_DEBUG("Got task %s from %p",(*task)->name,mailbox); if (msg_global->debug_multiple_use && (*task)->simdata->isused!=0) xbt_ex_free(*(xbt_ex_t*)(*task)->simdata->isused); diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 3ce8d3225e..28c596effa 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -37,10 +37,10 @@ void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc) if (smx_proc == SIMIX_process_self()) { /* avoid a SIMIX request if this function is called by the process itself */ msg_proc = (simdata_process_t) SIMIX_process_self_get_data(); - SIMIX_process_self_set_data(NULL); + SIMIX_process_self_set_data(nullptr); } else { msg_proc = (simdata_process_t) simcall_process_get_data(smx_proc); - simcall_process_set_data(smx_proc, NULL); + simcall_process_set_data(smx_proc, nullptr); } TRACE_msg_process_destroy(smx_proc->name.c_str(), smx_proc->pid); @@ -79,7 +79,7 @@ smx_process_t MSG_process_create_from_SIMIX( */ msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *data, msg_host_t host) { - return MSG_process_create_with_environment(name, code, data, host, 0, NULL, NULL); + return MSG_process_create_with_environment(name, code, data, host, 0, nullptr, nullptr); } /** \ingroup m_process_management @@ -87,14 +87,14 @@ msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *d * A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and * the corresponding thread) is created, and put in the list of ready process. - * \param name a name for the object. It is for user-level information and can be NULL. + * \param name a name for the object. It is for user-level information and can be nullptr. * \param code is a function describing the behavior of the process. It should then only use functions described * in \ref m_process_management (to create a new #msg_process_t for example), in \ref m_host_management (only the read-only functions i.e. whose name contains the word get), in \ref m_task_management (to create or destroy some #msg_task_t for example) and in \ref msg_task_usage (to handle file transfers and task processing). * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and - * can be NULL. It can be retrieved with the function \ref MSG_process_get_data. + * can be nullptr. It can be retrieved with the function \ref MSG_process_get_data. * \param host the location where the new process is executed. * \param argc first argument passed to \a code * \param argv second argument passed to \a code @@ -105,7 +105,7 @@ msg_process_t MSG_process_create(const char *name, xbt_main_func_t code, void *d msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_t code, void *data, msg_host_t host, int argc, char **argv) { - return MSG_process_create_with_environment(name, code, data, host, argc, argv, NULL); + return MSG_process_create_with_environment(name, code, data, host, argc, argv, nullptr); } /** \ingroup m_process_management @@ -113,14 +113,14 @@ msg_process_t MSG_process_create_with_arguments(const char *name, xbt_main_func_ * A constructor for #msg_process_t taking four arguments and returning the corresponding object. The structure (and * the corresponding thread) is created, and put in the list of ready process. - * \param name a name for the object. It is for user-level information and can be NULL. + * \param name a name for the object. It is for user-level information and can be nullptr. * \param code is a function describing the behavior of the process. It should then only use functions described * in \ref m_process_management (to create a new #msg_process_t for example), in \ref m_host_management (only the read-only functions i.e. whose name contains the word get), in \ref m_task_management (to create or destroy some #msg_task_t for example) and in \ref msg_task_usage (to handle file transfers and task processing). * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and - * can be NULL. It can be retrieved with the function \ref MSG_process_get_data. + * can be nullptr. It can be retrieved with the function \ref MSG_process_get_data. * \param host the location where the new process is executed. * \param argc first argument passed to \a code * \param argv second argument passed to \a code. WARNING, these strings are freed by the SimGrid kernel when the @@ -146,13 +146,13 @@ msg_process_t MSG_process_create_with_environment( const char *name, std::function code, void *data, msg_host_t host, xbt_dict_t properties) { - xbt_assert(code != NULL && host != NULL, "Invalid parameters: host and code params must not be NULL"); + xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr"); simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1); msg_process_t process; /* Simulator data for MSG */ - simdata->waiting_action = NULL; - simdata->waiting_task = NULL; + simdata->waiting_action = nullptr; + simdata->waiting_task = nullptr; simdata->m_host = host; simdata->data = data; simdata->last_errno = MSG_OK; @@ -165,7 +165,7 @@ msg_process_t MSG_process_create_with_environment( if (!process) { /* Undo everything we have just changed */ xbt_free(simdata); - return NULL; + return nullptr; } else { simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process); @@ -188,19 +188,19 @@ static int MSG_maestro(int argc, char** argv) */ msg_process_t MSG_process_attach(const char *name, void *data, msg_host_t host, xbt_dict_t properties) { - xbt_assert(host != NULL, "Invalid parameters: host and code params must not be NULL"); + xbt_assert(host != nullptr, "Invalid parameters: host and code params must not be nullptr"); simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1); msg_process_t process; /* Simulator data for MSG */ - simdata->waiting_action = NULL; - simdata->waiting_task = NULL; + simdata->waiting_action = nullptr; + simdata->waiting_task = nullptr; simdata->m_host = host; simdata->data = data; simdata->last_errno = MSG_OK; /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */ - process = SIMIX_process_attach(name, simdata, sg_host_get_name(host), properties, NULL); + process = SIMIX_process_attach(name, simdata, sg_host_get_name(host), properties, nullptr); if (!process) xbt_die("Could not attach"); simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process); @@ -267,14 +267,14 @@ msg_error_t MSG_process_migrate(msg_process_t process, msg_host_t host) */ void* MSG_process_get_data(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: first parameter must not be NULL!"); + xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!"); /* get from SIMIX the MSG process data, and then the user data */ simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process); if (simdata) return simdata->data; else - return NULL; + return nullptr; } /** \ingroup m_process_management @@ -284,7 +284,7 @@ void* MSG_process_get_data(msg_process_t process) */ msg_error_t MSG_process_set_data(msg_process_t process, void *data) { - xbt_assert(process != NULL, "Invalid parameter: first parameter must not be NULL!"); + xbt_assert(process != nullptr, "Invalid parameter: first parameter must not be nullptr!"); simdata_process_t simdata = (simdata_process_t) simcall_process_get_data(process); simdata->data = data; @@ -294,7 +294,7 @@ msg_error_t MSG_process_set_data(msg_process_t process, void *data) /** \ingroup m_process_management * \brief Sets a cleanup function to be called to free the userdata of a process when a process is destroyed. - * \param data_cleanup a cleanup function for the userdata of a process, or NULL to call no function + * \param data_cleanup a cleanup function for the userdata of a process, or nullptr to call no function */ XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) { msg_global->process_data_cleanup = data_cleanup; @@ -302,19 +302,19 @@ XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) { /** \ingroup m_process_management * \brief Return the location on which a process is running. - * \param process a process (NULL means the current one) + * \param process a process (nullptr means the current one) * \return the msg_host_t corresponding to the location on which \a process is running. */ msg_host_t MSG_process_get_host(msg_process_t process) { simdata_process_t simdata; - if (process == NULL) { + if (process == nullptr) { simdata = (simdata_process_t) SIMIX_process_self_get_data(); } else { simdata = (simdata_process_t) simcall_process_get_data(process); } - return simdata ? simdata->m_host : NULL; + return simdata ? simdata->m_host : nullptr; } /** \ingroup m_process_management @@ -322,7 +322,7 @@ msg_host_t MSG_process_get_host(msg_process_t process) * \brief Return a #msg_process_t given its PID. * * This function search in the list of all the created msg_process_t for a msg_process_t whose PID is equal to \a PID. - * If no host is found, \c NULL is returned. + * If no host is found, \c nullptr is returned. Note that the PID are uniq in the whole simulation, not only on a given host. */ msg_process_t MSG_process_from_PID(int PID) @@ -362,7 +362,7 @@ int MSG_process_get_PID(msg_process_t process) { /* Do not raise an exception here: this function is called by the logs * and the exceptions, so it would be called back again and again */ - if (process == NULL) { + if (process == nullptr) { return 0; } return simcall_process_get_PID(process); @@ -376,7 +376,7 @@ int MSG_process_get_PID(msg_process_t process) */ int MSG_process_get_PPID(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); return simcall_process_get_PPID(process); } @@ -387,7 +387,7 @@ int MSG_process_get_PPID(msg_process_t process) */ const char *MSG_process_get_name(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); return simcall_process_get_name(process); } @@ -396,7 +396,7 @@ const char *MSG_process_get_name(msg_process_t process) * * \param process a process * \param name a property name - * \return value of a property (or NULL if the property is not set) + * \return value of a property (or nullptr if the property is not set) */ const char *MSG_process_get_property_value(msg_process_t process, const char *name) { @@ -410,7 +410,7 @@ const char *MSG_process_get_property_value(msg_process_t process, const char *na */ xbt_dict_t MSG_process_get_properties(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); return simcall_process_get_properties(process); } @@ -451,7 +451,7 @@ msg_process_t MSG_process_self(void) */ msg_error_t MSG_process_suspend(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); TRACE_msg_process_suspend(process); simcall_process_suspend(process); @@ -465,7 +465,7 @@ msg_error_t MSG_process_suspend(msg_process_t process) */ msg_error_t MSG_process_resume(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); TRACE_msg_process_resume(process); simcall_process_resume(process); @@ -479,7 +479,7 @@ msg_error_t MSG_process_resume(msg_process_t process) */ int MSG_process_is_suspended(msg_process_t process) { - xbt_assert(process != NULL, "Invalid parameter: First argument must not be NULL"); + xbt_assert(process != nullptr, "Invalid parameter: First argument must not be nullptr"); return simcall_process_is_suspended(process); } diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index a3b6d203ee..bb76800766 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -24,13 +24,13 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_task, msg, "Logging specific to MSG (task)") * \brief Creates a new #msg_task_t. * * A constructor for #msg_task_t taking four arguments and returning the corresponding object. - * \param name a name for the object. It is for user-level information and can be NULL. + * \param name a name for the object. It is for user-level information and can be nullptr. * \param flop_amount a value of the processing amount (in flop) needed to process this new task. * If 0, then it cannot be executed with MSG_task_execute(). This value has to be >=0. * \param message_size a value of the amount of data (in bytes) needed to transfer this new task. If 0, then it cannot * be transfered with MSG_task_send() and MSG_task_recv(). This value has to be >=0. * \param data a pointer to any data may want to attach to the new object. It is for user-level information and can - * be NULL. It can be retrieved with the function \ref MSG_task_get_data. + * be nullptr. It can be retrieved with the function \ref MSG_task_get_data. * \see msg_task_t * \return The new corresponding object. */ @@ -45,23 +45,23 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_ task->data = data; /* Simulator Data */ - simdata->compute = NULL; - simdata->comm = NULL; + simdata->compute = nullptr; + simdata->comm = nullptr; simdata->bytes_amount = message_size; simdata->flops_amount = flop_amount; - simdata->sender = NULL; - simdata->receiver = NULL; - simdata->source = NULL; + simdata->sender = nullptr; + simdata->receiver = nullptr; + simdata->source = nullptr; simdata->priority = 1.0; simdata->bound = 0; - simdata->affinity_mask_db = xbt_dict_new_homogeneous(NULL); + simdata->affinity_mask_db = xbt_dict_new_homogeneous(nullptr); simdata->rate = -1.0; simdata->isused = 0; simdata->host_nb = 0; - simdata->host_list = NULL; - simdata->flops_parallel_amount = NULL; - simdata->bytes_parallel_amount = NULL; + simdata->host_list = nullptr; + simdata->flops_parallel_amount = nullptr; + simdata->bytes_parallel_amount = nullptr; TRACE_msg_task_create(task); return task; @@ -71,14 +71,14 @@ msg_task_t MSG_task_create(const char *name, double flop_amount, double message_ * \brief Creates a new #msg_task_t (a parallel one....). * * A constructor for #msg_task_t taking six arguments and returning the corresponding object. - * \param name a name for the object. It is for user-level information and can be NULL. + * \param name a name for the object. It is for user-level information and can be nullptr. * \param host_nb the number of hosts implied in the parallel task. * \param host_list an array of \p host_nb msg_host_t. * \param flops_amount an array of \p host_nb doubles. * flops_amount[i] is the total number of operations that have to be performed on host_list[i]. * \param bytes_amount an array of \p host_nb* \p host_nb doubles. * \param data a pointer to any data may want to attach to the new object. - * It is for user-level information and can be NULL. + * It is for user-level information and can be nullptr. * It can be retrieved with the function \ref MSG_task_get_data. * \see msg_task_t * \return The new corresponding object. @@ -109,7 +109,7 @@ msg_task_t MSG_parallel_task_create(const char *name, int host_nb, const msg_hos */ void *MSG_task_get_data(msg_task_t task) { - xbt_assert((task != NULL), "Invalid parameter"); + xbt_assert((task != nullptr), "Invalid parameter"); return (task->data); } @@ -120,7 +120,7 @@ void *MSG_task_get_data(msg_task_t task) */ void MSG_task_set_data(msg_task_t task, void *data) { - xbt_assert((task != NULL), "Invalid parameter"); + xbt_assert((task != nullptr), "Invalid parameter"); task->data = data; } @@ -196,7 +196,7 @@ void MSG_task_set_name(msg_task_t task, const char *name) */ msg_error_t MSG_task_destroy(msg_task_t task) { - xbt_assert((task != NULL), "Invalid parameter"); + xbt_assert((task != nullptr), "Invalid parameter"); if (task->simdata->isused) { /* the task is being sent or executed: cancel it first */ @@ -227,7 +227,7 @@ msg_error_t MSG_task_destroy(msg_task_t task) */ msg_error_t MSG_task_cancel(msg_task_t task) { - xbt_assert((task != NULL), "Cannot cancel a NULL task"); + xbt_assert((task != nullptr), "Cannot cancel a nullptr task"); if (task->simdata->compute) { simcall_execution_cancel(task->simdata->compute); @@ -294,7 +294,7 @@ double MSG_task_get_remaining_communication(msg_task_t task) */ double MSG_task_get_bytes_amount(msg_task_t task) { - xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); + xbt_assert((task != nullptr) && (task->simdata != nullptr), "Invalid parameter"); return task->simdata->bytes_amount; } @@ -304,7 +304,7 @@ double MSG_task_get_bytes_amount(msg_task_t task) */ void MSG_task_set_priority(msg_task_t task, double priority) { - xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); + xbt_assert((task != nullptr) && (task->simdata != nullptr), "Invalid parameter"); task->simdata->priority = 1 / priority; if (task->simdata->compute) simcall_execution_set_priority(task->simdata->compute, @@ -372,10 +372,10 @@ void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask) /* 0 means clear */ /* We need remove_ext() not throwing exception. */ void *ret = xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(msg_host_t)); - if (ret != NULL) + if (ret != nullptr) xbt_dict_remove_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(host)); } else - xbt_dict_set_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(host), (void *)(uintptr_t) mask, NULL); + xbt_dict_set_ext(task->simdata->affinity_mask_db, (char *) host, sizeof(host), (void *)(uintptr_t) mask, nullptr); /* We set affinity data of this task. If the task is being executed, we actually change the affinity setting of the * task. Otherwise, this change will be applied when the task is executed. */ diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 92f3cbd01e..b7321d7f05 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -23,7 +23,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_vm, msg, "Cloud-oriented parts of the MSG AP * * \param vm a vm * \param name a property name - * \return value of a property (or NULL if property not set) + * \return value of a property (or nullptr if property not set) */ const char *MSG_vm_get_property_value(msg_vm_t vm, const char *name) { @@ -38,7 +38,7 @@ const char *MSG_vm_get_property_value(msg_vm_t vm, const char *name) */ xbt_dict_t MSG_vm_get_properties(msg_vm_t vm) { - xbt_assert((vm != NULL), "Invalid parameters (vm is NULL)"); + xbt_assert((vm != nullptr), "Invalid parameters (vm is nullptr)"); return vm->properties(); } @@ -336,7 +336,7 @@ static int migration_rx_fun(int argc, char *argv[]) int ret = 0; for (;;) { - msg_task_t task = NULL; + msg_task_t task = nullptr; ret = MSG_task_recv(&task, ms->mbox); { if (ret != MSG_OK) { @@ -400,7 +400,7 @@ static int migration_rx_fun(int argc, char *argv[]) // Inform the SRC that the migration has been correctly performed { char *task_name = get_mig_task_name(ms->vm, ms->src_pm, ms->dst_pm, 4); - msg_task_t task = MSG_task_create(task_name, 0, 0, NULL); + msg_task_t task = MSG_task_create(task_name, 0, 0, nullptr); msg_error_t ret = MSG_task_send(task, ms->mbox_ctl); // xbt_assert(ret == MSG_OK); if(ret == MSG_HOST_FAILURE){ @@ -425,9 +425,9 @@ static void reset_dirty_pages(msg_vm_t vm) { msg_host_priv_t priv = sg_host_msg(vm); - char *key = NULL; - xbt_dict_cursor_t cursor = NULL; - dirty_page_t dp = NULL; + char *key = nullptr; + xbt_dict_cursor_t cursor = nullptr; + dirty_page_t dp = nullptr; xbt_dict_foreach(priv->dp_objs, cursor, key, dp) { double remaining = MSG_task_get_flops_amount(dp->task); dp->prev_clock = MSG_get_clock(); @@ -467,9 +467,9 @@ static double lookup_computed_flop_counts(msg_vm_t vm, int stage_for_fancy_debug msg_host_priv_t priv = sg_host_msg(vm); double total = 0; - char *key = NULL; - xbt_dict_cursor_t cursor = NULL; - dirty_page_t dp = NULL; + char *key = nullptr; + xbt_dict_cursor_t cursor = nullptr; + dirty_page_t dp = nullptr; xbt_dict_foreach(priv->dp_objs, cursor, key, dp) { double remaining = MSG_task_get_flops_amount(dp->task); @@ -509,8 +509,8 @@ void MSG_host_add_task(msg_host_t host, msg_task_t task) dp->prev_remaining = remaining; } - xbt_assert(xbt_dict_get_or_null(priv->dp_objs, key) == NULL); - xbt_dict_set(priv->dp_objs, key, dp, NULL); + xbt_assert(xbt_dict_get_or_null(priv->dp_objs, key) == nullptr); + xbt_dict_set(priv->dp_objs, key, dp, nullptr); XBT_DEBUG("add %s on %s (remaining %f, dp_enabled %d)", key, sg_host_get_name(host), remaining, priv->dp_enabled); xbt_free(key); @@ -549,7 +549,7 @@ static sg_size_t send_migration_data(msg_vm_t vm, msg_host_t src_pm, msg_host_t { sg_size_t sent = 0; char *task_name = get_mig_task_name(vm, src_pm, dst_pm, stage); - msg_task_t task = MSG_task_create(task_name, 0, (double)size, NULL); + msg_task_t task = MSG_task_create(task_name, 0, (double)size, nullptr); /* TODO: clean up */ @@ -820,13 +820,13 @@ static int do_migration(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm) { char **argv = xbt_new(char *, 2); argv[0] = pr_rx_name; - argv[1] = NULL; + argv[1] = nullptr; /*rx_process = */ MSG_process_create_with_arguments(pr_rx_name, migration_rx_fun, ms, dst_pm, 1, argv); } { char **argv = xbt_new(char *, 2); argv[0] = pr_tx_name; - argv[1] = NULL; + argv[1] = nullptr; /* tx_process = */MSG_process_create_with_arguments(pr_tx_name, migration_tx_fun, ms, src_pm, 1, argv); } #endif @@ -834,7 +834,7 @@ static int do_migration(msg_vm_t vm, msg_host_t src_pm, msg_host_t dst_pm) /* wait until the migration have finished or on error has occurred */ { XBT_DEBUG("wait for reception of the final ACK (i.e. migration has been correctly performed"); - msg_task_t task = NULL; + msg_task_t task = nullptr; msg_error_t ret = MSG_TIMEOUT; while (ret == MSG_TIMEOUT && MSG_host_is_on(dst_pm)) //Wait while you receive the message o ret = MSG_task_receive_with_timeout(&task, ms->mbox_ctl, 4); @@ -1041,7 +1041,7 @@ void MSG_vm_set_affinity(msg_vm_t vm, msg_host_t pm, unsigned long mask) if (mask == 0) xbt_dict_remove_ext(priv->affinity_mask_db, (char *) pm, sizeof(pm)); else - xbt_dict_set_ext(priv->affinity_mask_db, (char *) pm, sizeof(pm), (void *)(uintptr_t) mask, NULL); + xbt_dict_set_ext(priv->affinity_mask_db, (char *) pm, sizeof(pm), (void *)(uintptr_t) mask, nullptr); msg_host_t pm_now = MSG_vm_get_pm(vm); if (pm_now == pm) { -- 2.20.1