X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2ab3abe53dde0026da7545fb7a80f29caf22a39b..d3d508eff04c525b346d8ad648b6661d2783b827:/examples/msg/actions-storage/actions-storage.c diff --git a/examples/msg/actions-storage/actions-storage.c b/examples/msg/actions-storage/actions-storage.c index 0d29d49857..a4e0becd77 100644 --- a/examples/msg/actions-storage/actions-storage.c +++ b/examples/msg/actions-storage/actions-storage.c @@ -1,11 +1,10 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2016. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "simgrid/msg.h" -#include +#include XBT_LOG_NEW_DEFAULT_CATEGORY(storage_actions, "Messages specific for this example"); @@ -31,7 +30,7 @@ static msg_file_t get_file_descriptor(const char *file_name){ char full_name[1024]; msg_file_t file = NULL; - sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); + snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); file = (msg_file_t) xbt_dict_get_or_null(opened_files, full_name); return file; @@ -53,7 +52,7 @@ static void action_open(const char *const *action) { msg_file_t file = NULL; double clock = MSG_get_clock(); - sprintf(full_name, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); + snprintf(full_name,1023, "%s:%s", MSG_process_get_name(MSG_process_self()), file_name); ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name); file = MSG_file_open(file_name, NULL); @@ -93,10 +92,8 @@ static void action_close(const char *const *action) { } int main(int argc, char *argv[]) { - msg_error_t res = MSG_OK; - MSG_init(&argc, argv); - /* Explicit initialization of the action module is required now*/ + /* Explicit initialization of the action module is required */ MSG_action_init(); xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n" @@ -112,10 +109,10 @@ int main(int argc, char *argv[]) { xbt_replay_action_register("read", action_read); xbt_replay_action_register("close", action_close); - if (!opened_files) + if (opened_files == NULL) opened_files = xbt_dict_new_homogeneous(NULL); /* Actually do the simulation using MSG_action_trace_run */ - res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here + msg_error_t res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here XBT_INFO("Simulation time %g", MSG_get_clock());