aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp2
-rw-r--r--tests/unit_tests/notify.cpp10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index d8c38bf9e..4b806c282 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1716,7 +1716,7 @@ namespace cryptonote
for (size_t n = 0; n < sizeof(seconds)/sizeof(seconds[0]); ++n)
{
unsigned int b = 0;
- for (time_t ts: timestamps) b += ts >= now - seconds[n];
+ for (time_t ts: timestamps) b += ts >= now - static_cast<time_t>(seconds[n]);
const double p = probability(b, seconds[n] / DIFFICULTY_TARGET_V2);
MDEBUG("blocks in the last " << seconds[n] / 60 << " minutes: " << b << " (probability " << p << ")");
if (p < threshold)
diff --git a/tests/unit_tests/notify.cpp b/tests/unit_tests/notify.cpp
index 84861cb45..4daeeddee 100644
--- a/tests/unit_tests/notify.cpp
+++ b/tests/unit_tests/notify.cpp
@@ -44,7 +44,14 @@ TEST(notify, works)
#ifdef __GLIBC__
mode_t prevmode = umask(077);
#endif
- char name_template[] = "/tmp/monero-notify-unit-test-XXXXXX";
+ const char *tmp = getenv("TEMP");
+ if (!tmp)
+ tmp = "/tmp";
+ static const char *filename = "monero-notify-unit-test-XXXXXX";
+ const size_t len = strlen(tmp) + 1 + strlen(filename);
+ char *name_template = (char*)malloc(len + 1);
+ ASSERT_TRUE(name_template != NULL);
+ snprintf(name_template, len + 1, "%s/%s", tmp, filename);
int fd = mkstemp(name_template);
#ifdef __GLIBC__
umask(prevmode);
@@ -68,4 +75,5 @@ TEST(notify, works)
ASSERT_TRUE(s == "1111111111111111111111111111111111111111111111111111111111111111");
boost::filesystem::remove(name_template);
+ free(name_template);
}