From ad2656051697899e960694bb68ac104fcc5e92f1 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 5 Sep 2016 16:10:48 +0100 Subject: Improve static and const correctness. - Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library. --- toxcore/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toxcore/util.c') diff --git a/toxcore/util.c b/toxcore/util.c index 9f1a7e28..92ad4510 100644 --- a/toxcore/util.c +++ b/toxcore/util.c @@ -38,7 +38,7 @@ static uint64_t unix_time_value; static uint64_t unix_base_time_value; -void unix_time_update() +void unix_time_update(void) { if (unix_base_time_value == 0) { unix_base_time_value = ((uint64_t)time(NULL) - (current_time_monotonic() / 1000ULL)); @@ -47,7 +47,7 @@ void unix_time_update() unix_time_value = (current_time_monotonic() / 1000ULL) + unix_base_time_value; } -uint64_t unix_time() +uint64_t unix_time(void) { return unix_time_value; } -- cgit v1.2.3