summaryrefslogtreecommitdiff
path: root/include/dlt/dlt_user_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/dlt/dlt_user_macros.h')
-rw-r--r--include/dlt/dlt_user_macros.h124
1 files changed, 70 insertions, 54 deletions
diff --git a/include/dlt/dlt_user_macros.h b/include/dlt/dlt_user_macros.h
index eec63de..23a6f49 100644
--- a/include/dlt/dlt_user_macros.h
+++ b/include/dlt/dlt_user_macros.h
@@ -82,6 +82,9 @@
* Create an object for a new context.
* This macro has to be called first for every.
* @param CONTEXT object containing information about one special logging context
+ * @note To avoid the MISRA warning "Null statement is located close to other code or comments"
+ * remove the semicolon when using the macro.
+ * Example: DLT_DECLARE_CONTEXT(hContext)
*/
#define DLT_DECLARE_CONTEXT(CONTEXT) \
DltContext CONTEXT;
@@ -90,6 +93,9 @@ DltContext CONTEXT;
* Use an object of a new context created in another module.
* This macro has to be called first for every.
* @param CONTEXT object containing information about one special logging context
+ * @note To avoid the MISRA warning "Null statement is located close to other code or comments"
+ * remove the semicolon when using the macro.
+ * Example: DLT_IMPORT_CONTEXT(hContext)
*/
#define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
@@ -100,15 +106,15 @@ extern DltContext CONTEXT;
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_APP(APPID,DESCRIPTION) do {\
- dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \
- dlt_register_app( APPID, DESCRIPTION);} while(0)
+ (void)dlt_check_library_version(_DLT_PACKAGE_MAJOR_VERSION, _DLT_PACKAGE_MINOR_VERSION ); \
+ (void)dlt_register_app( APPID, DESCRIPTION);} while(0)
/**
* Unregister application.
*/
#define DLT_UNREGISTER_APP() do{\
- dlt_unregister_app();} while(0)
+ (void)dlt_unregister_app();} while(0)
/**
* Register context (with default log level and default trace status)
@@ -117,7 +123,7 @@ extern DltContext CONTEXT;
* @param DESCRIPTION ASCII string containing description
*/
#define DLT_REGISTER_CONTEXT(CONTEXT,CONTEXTID,DESCRIPTION) do{\
- dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);} while(0)
+ (void)dlt_register_context(&(CONTEXT), CONTEXTID, DESCRIPTION);} while(0)
/**
* Register context with pre-defined log level and pre-defined trace status.
@@ -130,14 +136,14 @@ extern DltContext CONTEXT;
(DLT_TRACE_STATUS_DEFAULT is not allowed here)
*/
#define DLT_REGISTER_CONTEXT_LL_TS(CONTEXT,CONTEXTID,DESCRIPTION,LOGLEVEL,TRACESTATUS) do{\
- dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);} while(0)
+ (void)dlt_register_context_ll_ts(&(CONTEXT), CONTEXTID, DESCRIPTION, LOGLEVEL, TRACESTATUS);} while(0)
/**
* Unregister context.
* @param CONTEXT object containing information about one special logging context
*/
#define DLT_UNREGISTER_CONTEXT(CONTEXT) do{\
- dlt_unregister_context(&(CONTEXT));} while(0)
+ (void)dlt_unregister_context(&(CONTEXT));} while(0)
/**
* Register callback function called when injection message was received
@@ -146,7 +152,7 @@ extern DltContext CONTEXT;
* @param CALLBACK function pointer to callback function
*/
#define DLT_REGISTER_INJECTION_CALLBACK(CONTEXT, SERVICEID, CALLBACK) do{\
- dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);} while(0)
+ (void)dlt_register_injection_callback(&(CONTEXT),SERVICEID, CALLBACK);} while(0)
/**
* Register callback function called when log level of context was changed
@@ -154,13 +160,16 @@ extern DltContext CONTEXT;
* @param CALLBACK function pointer to callback function
*/
#define DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK) do{\
- dlt_register_log_level_changed_callback(&(CONTEXT),CALLBACK);} while(0)
+ (void)dlt_register_log_level_changed_callback(&(CONTEXT),CALLBACK);} while(0)
/**
* Send log message with variable list of messages (intended for verbose mode)
* @param CONTEXT object containing information about one special logging context
* @param LOGLEVEL the log level of the log message
* @param ARGS variable list of arguments
+ * @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
+ * use a semicolon instead of a comma to separate the ARGS.
+ * Example: DLT_LOG(hContext, DLT_LOG_INFO, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG is not supported by MS Visual C++ */
@@ -170,11 +179,13 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- DltContextData log; \
- if (dlt_user_log_write_start(&CONTEXT,&log,LOGLEVEL)>0) \
+ DltContextData log_local; \
+ int dlt_local; \
+ dlt_local = dlt_user_log_write_start(&CONTEXT,&log_local,LOGLEVEL); \
+ if (dlt_local > 0) \
{ \
- ARGS; \
- dlt_user_log_write_finish(&log); \
+ ARGS; \
+ (void)dlt_user_log_write_finish(&log_local); \
} \
} \
} while(0)
@@ -188,6 +199,9 @@ extern DltContext CONTEXT;
* @param ARGS variable list of arguments:
calls to DLT_STRING(), DLT_BOOL(), DLT_FLOAT32(), DLT_FLOAT64(),
DLT_INT(), DLT_UINT(), DLT_RAW()
+ * @note To avoid the MISRA warning "The comma operator has been used outside a for statement"
+ * use a semicolon instead of a comma to separate the ARGS.
+ * Example: DLT_LOG_ID(hContext, DLT_LOG_INFO, 0x1234, DLT_STRING("Hello world"); DLT_INT(123));
*/
#ifdef _MSC_VER
/* DLT_LOG_ID is not supported by MS Visual C++ */
@@ -197,11 +211,13 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- DltContextData log; \
- if (dlt_user_log_write_start_id(&CONTEXT,&log,LOGLEVEL,MSGID)>0) \
+ DltContextData log_local; \
+ int dlt_local; \
+ dlt_local = dlt_user_log_write_start_id(&CONTEXT,&log_local,LOGLEVEL,MSGID); \
+ if (dlt_local > 0) \
{ \
- ARGS; \
- dlt_user_log_write_finish(&log); \
+ ARGS; \
+ (void)dlt_user_log_write_finish(&log_local); \
} \
} \
} while(0)
@@ -212,80 +228,80 @@ extern DltContext CONTEXT;
* @param TEXT ASCII string
*/
#define DLT_STRING(TEXT) \
- dlt_user_log_write_string(&log,TEXT)
+ (void)dlt_user_log_write_string(&log_local,TEXT)
/**
* Add constant string parameter to the log messsage.
* @param TEXT Constant ASCII string
*/
#define DLT_CSTRING(TEXT) \
- dlt_user_log_write_constant_string(&log,TEXT)
+ (void)dlt_user_log_write_constant_string(&log_local,TEXT)
/**
* Add utf8-encoded string parameter to the log messsage.
* @param TEXT UTF8-encoded string
*/
#define DLT_UTF8(TEXT) \
- dlt_user_log_write_utf8_string(&log,TEXT)
+ (void)dlt_user_log_write_utf8_string(&log_local,TEXT)
/**
* Add boolean parameter to the log messsage.
* @param BOOL_VAR Boolean value (mapped to uint8)
*/
#define DLT_BOOL(BOOL_VAR) \
- dlt_user_log_write_bool(&log,BOOL_VAR)
+ (void)dlt_user_log_write_bool(&log_local,BOOL_VAR)
/**
* Add float32 parameter to the log messsage.
* @param FLOAT32_VAR Float32 value (mapped to float)
*/
#define DLT_FLOAT32(FLOAT32_VAR) \
- dlt_user_log_write_float32(&log,FLOAT32_VAR)
+ (void)dlt_user_log_write_float32(&log_local,FLOAT32_VAR)
/**
* Add float64 parameter to the log messsage.
* @param FLOAT64_VAR Float64 value (mapped to double)
*/
#define DLT_FLOAT64(FLOAT64_VAR) \
- dlt_user_log_write_float64(&log,FLOAT64_VAR)
+ (void)dlt_user_log_write_float64(&log_local,FLOAT64_VAR)
/**
* Add integer parameter to the log messsage.
* @param INT_VAR integer value
*/
#define DLT_INT(INT_VAR) \
- dlt_user_log_write_int(&log,INT_VAR)
+ (void)dlt_user_log_write_int(&log_local,INT_VAR)
#define DLT_INT8(INT_VAR) \
- dlt_user_log_write_int8(&log,INT_VAR)
+ (void)dlt_user_log_write_int8(&log_local,INT_VAR)
#define DLT_INT16(INT_VAR) \
- dlt_user_log_write_int16(&log,INT_VAR)
+ (void)dlt_user_log_write_int16(&log_local,INT_VAR)
#define DLT_INT32(INT_VAR) \
- dlt_user_log_write_int32(&log,INT_VAR)
+ (void)dlt_user_log_write_int32(&log_local,INT_VAR)
#define DLT_INT64(INT_VAR) \
- dlt_user_log_write_int64(&log,INT_VAR)
+ (void)dlt_user_log_write_int64(&log_local,INT_VAR)
/**
* Add unsigned integer parameter to the log messsage.
* @param UINT_VAR unsigned integer value
*/
#define DLT_UINT(UINT_VAR) \
- dlt_user_log_write_uint(&log,UINT_VAR)
+ (void)dlt_user_log_write_uint(&log_local,UINT_VAR)
#define DLT_UINT8(UINT_VAR) \
- dlt_user_log_write_uint8(&log,UINT_VAR)
+ (void)dlt_user_log_write_uint8(&log_local,UINT_VAR)
#define DLT_UINT16(UINT_VAR) \
- dlt_user_log_write_uint16(&log,UINT_VAR)
+ (void)dlt_user_log_write_uint16(&log_local,UINT_VAR)
#define DLT_UINT32(UINT_VAR) \
- dlt_user_log_write_uint32(&log,UINT_VAR)
+ (void)dlt_user_log_write_uint32(&log_local,UINT_VAR)
#define DLT_UINT64(UINT_VAR) \
- dlt_user_log_write_uint64(&log,UINT_VAR)
+ (void)dlt_user_log_write_uint64(&log_local,UINT_VAR)
/**
* Add binary memory block to the log messages.
@@ -293,19 +309,19 @@ extern DltContext CONTEXT;
* @param LEN length of memory block
*/
#define DLT_RAW(BUF,LEN) \
- dlt_user_log_write_raw(&log,BUF,LEN)
+ (void)dlt_user_log_write_raw(&log_local,BUF,LEN)
#define DLT_HEX8(UINT_VAR) \
- dlt_user_log_write_uint8_formatted(&log,UINT_VAR,DLT_FORMAT_HEX8)
+ (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX8)
#define DLT_HEX16(UINT_VAR) \
- dlt_user_log_write_uint16_formatted(&log,UINT_VAR,DLT_FORMAT_HEX16)
+ (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX16)
#define DLT_HEX32(UINT_VAR) \
- dlt_user_log_write_uint32_formatted(&log,UINT_VAR,DLT_FORMAT_HEX32)
+ (void)dlt_user_log_write_uint32_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX32)
#define DLT_HEX64(UINT_VAR) \
- dlt_user_log_write_uint64_formatted(&log,UINT_VAR,DLT_FORMAT_HEX64)
+ (void)dlt_user_log_write_uint64_formatted(&log_local,UINT_VAR,DLT_FORMAT_HEX64)
#define DLT_BIN8(UINT_VAR) \
- dlt_user_log_write_uint8_formatted(&log,UINT_VAR,DLT_FORMAT_BIN8)
+ (void)dlt_user_log_write_uint8_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN8)
#define DLT_BIN16(UINT_VAR) \
- dlt_user_log_write_uint16_formatted(&log,UINT_VAR,DLT_FORMAT_BIN16)
+ (void)dlt_user_log_write_uint16_formatted(&log_local,UINT_VAR,DLT_FORMAT_BIN16)
/**
* Trace network message
@@ -320,7 +336,7 @@ extern DltContext CONTEXT;
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
{ \
- dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+ (void)dlt_user_trace_network(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
} \
}while(0)
@@ -337,7 +353,7 @@ extern DltContext CONTEXT;
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
{ \
- dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \
+ (void)dlt_user_trace_network_truncated(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD, 1); \
} \
}while(0)
@@ -354,7 +370,7 @@ extern DltContext CONTEXT;
do { \
if ((CONTEXT).trace_status_ptr && *((CONTEXT).trace_status_ptr)==DLT_TRACE_STATUS_ON) \
{ \
- dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
+ (void)dlt_user_trace_network_segmented(&(CONTEXT),TYPE,HEADERLEN,HEADER,PAYLOADLEN,PAYLOAD); \
} \
}while(0)
@@ -368,7 +384,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
+ (void)dlt_log_string(&(CONTEXT), LOGLEVEL, TEXT); \
} \
} while(0)
@@ -383,7 +399,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
+ (void)dlt_log_string_int(&(CONTEXT), LOGLEVEL, TEXT, INT_VAR); \
} \
} while(0)
@@ -398,7 +414,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
+ (void)dlt_log_string_uint(&(CONTEXT),LOGLEVEL,TEXT,UINT_VAR); \
} \
} while(0)
@@ -412,7 +428,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
+ (void)dlt_log_uint(&(CONTEXT),LOGLEVEL,UINT_VAR); \
} \
} while(0)
@@ -426,7 +442,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
+ (void)dlt_log_int(&(CONTEXT),LOGLEVEL,INT_VAR); \
} \
} while(0)
@@ -441,7 +457,7 @@ extern DltContext CONTEXT;
do { \
if((CONTEXT).log_level_ptr && ((LOGLEVEL)<=(int)*((CONTEXT).log_level_ptr) ) && ((LOGLEVEL)!=0)) \
{ \
- dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
+ (void)dlt_log_raw(&(CONTEXT),LOGLEVEL,BUF,LEN); \
} \
} while(0)
@@ -450,7 +466,7 @@ extern DltContext CONTEXT;
*/
#define DLT_LOG_MARKER() \
do { \
- dlt_log_marker(); \
+ (void)dlt_log_marker(); \
} while(0)
/**
@@ -458,14 +474,14 @@ extern DltContext CONTEXT;
*
*/
#define DLT_VERBOSE_MODE() do { \
- dlt_verbose_mode();} while(0)
+ (void)dlt_verbose_mode();} while(0)
/**
* Switch to non-verbose mode
*
*/
#define DLT_NONVERBOSE_MODE() do {\
- dlt_nonverbose_mode();} while(0)
+ (void)dlt_nonverbose_mode();} while(0)
/**
* Set maximum logged log level and trace status of application
@@ -474,21 +490,21 @@ extern DltContext CONTEXT;
* @param TRACESTATUS This is the trace status to be set for the whole application
*/
#define DLT_SET_APPLICATION_LL_TS_LIMIT(LOGLEVEL, TRACESTATUS) do {\
- dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);} while(0)
+ (void)dlt_set_application_ll_ts_limit(LOGLEVEL, TRACESTATUS);} while(0)
/**
* Enable local printing of messages
*
*/
#define DLT_ENABLE_LOCAL_PRINT() do {\
- dlt_enable_local_print();} while(0)
+ (void)dlt_enable_local_print();} while(0)
/**
* Disable local printing of messages
*
*/
#define DLT_DISABLE_LOCAL_PRINT() do {\
- dlt_disable_local_print();} while(0)
+ (void)dlt_disable_local_print();} while(0)
/**
\}