Commit ebd19b36 by Marcus Winter

Merge branch 'embb558_c_pointer_checks' into development

parents 25efcf87 f9cb0a92
......@@ -249,6 +249,8 @@ int embb_duration_as_seconds(
/**
* Compares two durations.
*
* \pre \c lhs and \c rhs are not NULL and properly initialized.
*
* \return -1 if \c lhs < \c rhs \n
* 0 if \c lhs == \c rhs \n
* 1 if \c lhs > \c rhs
......
......@@ -67,6 +67,7 @@ typedef void(*embb_log_function_t)(void * context, char const * message);
/**
* Default logging function.
* Writes to the given file (context needs to be a FILE*).
* \pre \c context is not NULL.
* \ingroup C_LOG
* \threadsafe
*/
......
......@@ -89,6 +89,8 @@ int embb_time_in(
/**
* Compares two time points.
*
* \pre \c lhs and \c rhs are not NULL and properly initialized.
*
* \return -1 if \c lhs < \c rhs \n
* 0 if \c lhs == \c rhs \n
* 1 if \c lhs > \c rhs
......
......@@ -201,7 +201,6 @@ int embb_duration_as_seconds(const embb_duration_t* duration,
if (duration->nanoseconds % 1000000000 > 0) {
return EMBB_UNDERFLOW;
}
assert(duration->nanoseconds % 1000000000 == 0);
if (duration->seconds > ULLONG_MAX) {
return EMBB_OVERFLOW;
}
......@@ -211,12 +210,8 @@ int embb_duration_as_seconds(const embb_duration_t* duration,
int embb_duration_compare(const embb_duration_t* lhs,
const embb_duration_t* rhs) {
if (lhs == NULL || rhs == NULL) {
return EMBB_ERROR;
}
if (lhs->nanoseconds >= 1000000000 || rhs->nanoseconds >= 1000000000) {
return EMBB_ERROR;
}
assert(lhs != NULL && rhs != NULL);
assert(lhs->nanoseconds < 1000000000 && rhs->nanoseconds < 1000000000);
if (lhs->seconds > rhs->seconds) {
return 1;
} else if (lhs->seconds < rhs->seconds) {
......
......@@ -27,6 +27,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <embb/base/c/log.h>
......@@ -35,6 +36,7 @@
void embb_log_write_file(
void * context,
char const * message) {
assert(context != NULL);
FILE * ff = (FILE*)context;
fprintf(ff, "%s", message);
fflush(ff);
......
......@@ -33,13 +33,8 @@ void embb_time_now(embb_time_t* time) {
}
int embb_time_compare(const embb_time_t* lhs, const embb_time_t* rhs) {
if (lhs == NULL || rhs == NULL) {
return EMBB_ERROR;
}
if (lhs->nanoseconds >= 1000000000 || rhs->nanoseconds >= 1000000000) {
return EMBB_ERROR;
}
assert(lhs != NULL && rhs != NULL);
assert(lhs->nanoseconds < 1000000000 && rhs->nanoseconds < 1000000000);
if (lhs->seconds > rhs->seconds) {
return 1;
} else if (lhs->seconds < rhs->seconds) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment