aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOvidiu Mihalachi <ovidiu_mihalachi@mentor.com>2018-11-05 12:05:51 +0200
committerJerome Forissier <jerome.forissier@linaro.org>2018-11-13 18:10:15 +0100
commit3f58e4ec10c5df57bad1296bb9a5cbc7bfacaef1 (patch)
tree8fb955cda8cd10bdbc062caf6df4acddc26dcd00 /lib
parent7445d9ac558e1ff385af4773775ed68f61aed0d3 (diff)
trace levels: Redefine TRACE_MIN level to 0
The global `trace_level` session-wise indicator which is set by `trace_set_level()` [1], could get a wrong value in case of an input `level` set to 0, meaning that all logs need to be disabled by user define `CFG_TEE_TA_LOG_LEVEL=0` when building TA applications. This inconsistency is caused by a rather wrong value of `TRACE_MIN` low boundary value set to 1. According to [1] `trace level` will be set to `TRACE_MAX` (4) in case input level is smaller than `TRACE_MIN` and larger than `TRACE_MAX`. In the scenario when the needed log level is 0, `trace level` would be set to `TRACE_MAX` and will cause a lot of flow log level information dumped by trace functions/macros that are using `trace_printf()` primitive. This patch sets the `TRACE_MIN` to 0 in order to assure a proper trace level setting and completely disable all logs in case `CFG_TEE_TA_LOG_LEVEL=0`. [1] void trace_set_level(int level) { if (((int)level >= TRACE_MIN) && (level <= TRACE_MAX)) trace_level = level; else trace_level = TRACE_MAX; } Acked-by: Christoph Gellner <cgellner@de.adit-jv.com> Signed-off-by: Ovidiu Mihalachi <ovidiu_mihalachi@mentor.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libutils/ext/include/trace_levels.h4
-rw-r--r--lib/libutils/ext/trace.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/libutils/ext/include/trace_levels.h b/lib/libutils/ext/include/trace_levels.h
index f717880f..7fd51815 100644
--- a/lib/libutils/ext/include/trace_levels.h
+++ b/lib/libutils/ext/include/trace_levels.h
@@ -23,8 +23,8 @@
*
*/
-#define TRACE_MIN 1
-#define TRACE_ERROR TRACE_MIN
+#define TRACE_MIN 0
+#define TRACE_ERROR 1
#define TRACE_INFO 2
#define TRACE_DEBUG 3
#define TRACE_FLOW 4
diff --git a/lib/libutils/ext/trace.c b/lib/libutils/ext/trace.c
index 6ee433ca..e9258fbf 100644
--- a/lib/libutils/ext/trace.c
+++ b/lib/libutils/ext/trace.c
@@ -15,12 +15,12 @@
#include <util.h>
#include <types_ext.h>
-#if (TRACE_LEVEL > 0)
-
#if (TRACE_LEVEL < TRACE_MIN) || (TRACE_LEVEL > TRACE_MAX)
#error "Invalid value of TRACE_LEVEL"
#endif
+#if (TRACE_LEVEL >= TRACE_ERROR)
+
void trace_set_level(int level)
{
if (((int)level >= TRACE_MIN) && (level <= TRACE_MAX))