From 3495689e26efb8f9690945d3c7f4cd68eaeaaf86 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 26 Feb 2019 09:08:21 +0100 Subject: fix /tmp/rps directory creation, fix linkage, DCE --- src/rps/Makefile.am | 1 - src/rps/rps-test_util.c | 56 ++++++++----------------------------------------- src/rps/rps-test_util.h | 5 ++--- 3 files changed, 11 insertions(+), 51 deletions(-) (limited to 'src/rps') diff --git a/src/rps/Makefile.am b/src/rps/Makefile.am index a356d3dbc..b391eb8ae 100644 --- a/src/rps/Makefile.am +++ b/src/rps/Makefile.am @@ -60,7 +60,6 @@ gnunet_service_rps_SOURCES = \ gnunet-service-rps_sampler.h gnunet-service-rps_sampler.c \ gnunet-service-rps_custommap.h gnunet-service-rps_custommap.c \ gnunet-service-rps_view.h gnunet-service-rps_view.c \ - rps-test_util.h rps-test_util.c \ gnunet-service-rps.c diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index 85829f247..077750329 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -414,44 +414,6 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key) return name_buf; } - - -char * -create_file (const char *name) -{ - int size; - size_t name_buf_size; - char *name_buf; - char *prefix; - char *file_name; - - prefix = "/tmp/rps/"; - name_buf_size = (strlen (prefix) + strlen (name) + 2) * sizeof (char); - name_buf = GNUNET_malloc (name_buf_size); - - size = GNUNET_snprintf (name_buf, name_buf_size, "%s%s", prefix, name); - if (0 > size) - LOG (GNUNET_ERROR_TYPE_WARNING, "Failed to create name_buf\n"); - - if (GNUNET_YES != GNUNET_DISK_directory_create (prefix)) - { - LOG (GNUNET_ERROR_TYPE_WARNING, - "Could not create directory %s.\n", - prefix); - } - - if (NULL == strstr (name, "sampler_el")) - {/* only append random string to sampler */ - if (NULL == (file_name = GNUNET_DISK_mktemp (name_buf))) - LOG (GNUNET_ERROR_TYPE_WARNING, "Could not create file\n"); - - GNUNET_free (name_buf); - return file_name; - } - - return name_buf; -} - #endif /* TO_FILE */ @@ -479,23 +441,23 @@ string_to_auth_key (const char *str) * @return #GNUNET_YES on success * #GNUNET_SYSERR on failure */ -static int ensure_folder_exist (void) +static int +ensure_folder_exist (void) { - if (GNUNET_NO == GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO)) - { - GNUNET_DISK_directory_create ("/tmp/rps"); - } - if (GNUNET_YES != GNUNET_DISK_directory_test ("/tmp/rps/", GNUNET_NO)) + if (GNUNET_OK != + GNUNET_DISK_directory_create ("/tmp/rps")) { - LOG (GNUNET_ERROR_TYPE_ERROR, "Could not create directory `/tmp/rps'\n"); + LOG (GNUNET_ERROR_TYPE_ERROR, + "Could not create directory `/tmp/rps'\n"); return GNUNET_SYSERR; } return GNUNET_YES; } + char * store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, - const char *prefix) + const char *prefix) { int len_file_name; int out_size; diff --git a/src/rps/rps-test_util.h b/src/rps/rps-test_util.h index 78d1e0a26..ace833034 100644 --- a/src/rps/rps-test_util.h +++ b/src/rps/rps-test_util.h @@ -37,8 +37,6 @@ auth_key_to_string (struct GNUNET_CRYPTO_AuthKey auth_key); struct GNUNET_CRYPTO_AuthKey string_to_auth_key (const char *str); -char * -create_file (const char *name); /** * @brief Get file handle @@ -64,9 +62,10 @@ close_all_files (); * This function is used to facilitate writing important information to disk */ #ifdef TO_FILE -#define to_file(file_name, ...) do { if (NULL == file_name) { GNUNET_break(0); return;} \ +#define to_file(file_name, ...) do { \ char tmp_buf[512] = "";\ int size;\ + if (NULL == file_name) return; \ size = GNUNET_snprintf(tmp_buf,sizeof(tmp_buf),__VA_ARGS__);\ if (0 > size)\ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,\ -- cgit v1.2.3