nb/amd/amdht: Use standard coreboot assertions

The amdht code currently relies on an idiosyncratic ASSERT() macro,
which actually doesn't do anything right now, and even it did would only
print a janky error message. Replace this with the normal ASSERT() macro
from <assert.h>. The default behaviour now is to print an error message
but do nothing else, and failed assertions will only halt if you enable
FATAL_ASSERT, in which case, well, you asked for it.

Change-Id: I6db7565171a345f9afbc9fb37cff8fda58f942df
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1402076
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34375
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Jacob Garber
2019-07-16 16:57:50 -06:00
committed by Patrick Georgi
parent bcdb893778
commit 07be67aa4b
6 changed files with 3 additions and 76 deletions

View File

@ -16,25 +16,15 @@
#ifndef COMLIB_H
#define COMLIB_H
#undef FILECODE
#define FILECODE 0xF001
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include "porting.h"
#ifdef AMD_DEBUG
#define ASSERT(x) ((x) ? 0 : ErrorStop(((uint32)FILECODE)*0x10000 + ((__LINE__)%10) + (((__LINE__/10)%10)*0x10) + (((__LINE__/100)%10)*0x100) +(((__LINE__/1000)%10)*0x1000)))
#else
#define ASSERT(x)
#endif
#ifdef AMD_DEBUG_ERROR_STOP
/* Macro to aid debugging, causes program to halt and display the line number of the halt in decimal */
#define STOP_HERE ErrorStop(((uint32)FILECODE)*0x10000 + ((__LINE__)%10) + (((__LINE__/10)%10)*0x10) + (((__LINE__/100)%10)*0x100) +(((__LINE__/1000)%10)*0x1000))
/* Macro to aid debugging, causes program to halt and display the line number of the halt */
#define STOP_HERE ASSERT(0)
#else
/* Macro to aid debugging, causes program to halt and display the line number of the halt in decimal */
/* #define STOP_HERE STOP_HERE_OnlyForDebugUse */
#define STOP_HERE
#endif