diff options
author | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2014-10-30 13:06:17 +0100 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2014-10-30 14:39:02 +0100 |
commit | 8374325527b8165914b6c9677a08b005ff4d4bf1 (patch) | |
tree | 20febac16dcf0e761b533c158f6c5294923cc0bb | |
parent | c8d990b893838b3263ac020b095f1a520908e815 (diff) | |
download | DLT-daemon-8374325527b8165914b6c9677a08b005ff4d4bf1.tar.gz |
Fix dlt_user_log_write_start_id return value
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
-rw-r--r-- | include/dlt/dlt_user.h | 8 | ||||
-rw-r--r-- | src/lib/dlt_user.c | 17 |
2 files changed, 18 insertions, 7 deletions
diff --git a/include/dlt/dlt_user.h b/include/dlt/dlt_user.h index 7126b6a..8b088a8 100644 --- a/include/dlt/dlt_user.h +++ b/include/dlt/dlt_user.h @@ -288,21 +288,25 @@ typedef struct /** * Initialise the generation of a DLT log message (intended for usage in non-verbose mode) * This function has to be called first, when an application wants to send a new log messages. + * Following functions like dlt_user_log_write_string and dlt_user_log_write_finish must only be called, + * when return value is bigger than zero. * @param handle pointer to an object containing information about one special logging context * @param log pointer to an object containing information about logging context data * @param loglevel this is the current log level of the log message to be sent - * @return negative value if there was an error + * @return negative value if there was an error, zero if log level is below current log level, one if log level is matching */ int dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel); /** * Initialise the generation of a DLT log message (intended for usage in verbose mode) * This function has to be called first, when an application wants to send a new log messages. + * Following functions like dlt_user_log_write_string and dlt_user_log_write_finish must only be called, + * when return value is bigger than zero. * @param handle pointer to an object containing information about one special logging context * @param log pointer to an object containing information about logging context data * @param loglevel this is the current log level of the log message to be sent * @param messageid message id of message - * @return negative value if there was an error + * @return negative value if there was an error, zero if log level is below current log level, one if log level is matching */ int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log, DltLogLevelType loglevel, uint32_t messageid); diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index 7dfc913..22283c2 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -1265,10 +1265,14 @@ int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log,DltLogLe return -1; } + /* initialize values */ + log->args_num = 0; + log->log_level = loglevel; + log->size = 0; + + /* check log levels */ if (handle->log_level_ptr && (loglevel<=(int)*(handle->log_level_ptr) ) && (loglevel!=0)) { - log->args_num = 0; - log->log_level = loglevel; /* In non-verbose mode, insert message id */ if (dlt_user.verbose_mode==0) @@ -1284,9 +1288,12 @@ int dlt_user_log_write_start_id(DltContext *handle, DltContextData *log,DltLogLe /* as the message id is part of each message in non-verbose mode, it doesn't increment the argument counter in extended header (if used) */ } - else log->size=0; return 1; } + else + { + return 0; + } return -1; } @@ -2538,10 +2545,10 @@ int dlt_user_trace_network_truncated(DltContext *handle, DltNetworkTraceType nw_ } /** - * Calculate maximum avaialble space in sending buffer after headers. + * Calculate maximum available space in sending buffer after headers. */ - int truncated_payload_len = DLT_USER_BUF_MAX_SIZE - + int truncated_payload_len = DLT_USER_BUF_MAX_SIZE - log.size - sizeof(uint16_t) - sizeof(uint32_t); /* Write truncated payload */ |