diff options
author | anryko <a.shvenke@gmail.com> | 2018-01-07 20:20:11 +0100 |
---|---|---|
committer | anryko <a.shvenke@gmail.com> | 2018-01-07 20:20:11 +0100 |
commit | 608c456a6849dadecab156657854f5335d86cb3d (patch) | |
tree | 59c70e6d02412c35b089bc017668f822faa55327 | |
parent | 638642f8a3d750d77c501bcd565c05c2f98bbc2d (diff) | |
download | gnunet-608c456a6849dadecab156657854f5335d86cb3d.tar.gz gnunet-608c456a6849dadecab156657854f5335d86cb3d.zip |
vsprintf returns negative on error.
-rw-r--r-- | src/nse/gnunet-nse-profiler.c | 19 | ||||
-rw-r--r-- | src/util/common_allocation.c | 4 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 4a10022e3..b665812e5 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c | |||
@@ -374,13 +374,14 @@ nse_disconnect_adapter (void *cls, | |||
374 | */ | 374 | */ |
375 | static int | 375 | static int |
376 | stat_iterator (void *cls, | 376 | stat_iterator (void *cls, |
377 | const char *subsystem, | 377 | const char *subsystem, |
378 | const char *name, | 378 | const char *name, |
379 | uint64_t value, int is_persistent) | 379 | uint64_t value, |
380 | int is_persistent) | ||
380 | { | 381 | { |
381 | char *output_buffer; | 382 | char *output_buffer; |
382 | struct GNUNET_TIME_Absolute now; | 383 | struct GNUNET_TIME_Absolute now; |
383 | size_t size; | 384 | int size; |
384 | unsigned int flag; | 385 | unsigned int flag; |
385 | 386 | ||
386 | GNUNET_assert (NULL != data_file); | 387 | GNUNET_assert (NULL != data_file); |
@@ -390,8 +391,14 @@ stat_iterator (void *cls, | |||
390 | flag = 1; | 391 | flag = 1; |
391 | size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n", | 392 | size = GNUNET_asprintf (&output_buffer, "%llu %llu %u\n", |
392 | now.abs_value_us / 1000LL / 1000LL, | 393 | now.abs_value_us / 1000LL / 1000LL, |
393 | value, flag); | 394 | value, flag); |
394 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, size)) | 395 | if (0 > size) |
396 | { | ||
397 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Error formatting output buffer.\n"); | ||
398 | GNUNET_free (output_buffer); | ||
399 | return GNUNET_SYSERR; | ||
400 | } | ||
401 | if (size != GNUNET_DISK_file_write (data_file, output_buffer, (size_t) size)) | ||
395 | { | 402 | { |
396 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); | 403 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Unable to write to file!\n"); |
397 | GNUNET_free (output_buffer); | 404 | GNUNET_free (output_buffer); |
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 80047bb52..1c55d72b5 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -475,8 +475,8 @@ GNUNET_xgrow_ (void **old, | |||
475 | */ | 475 | */ |
476 | int | 476 | int |
477 | GNUNET_asprintf (char **buf, | 477 | GNUNET_asprintf (char **buf, |
478 | const char *format, | 478 | const char *format, |
479 | ...) | 479 | ...) |
480 | { | 480 | { |
481 | int ret; | 481 | int ret; |
482 | va_list args; | 482 | va_list args; |