[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH] lib/ukdebug: Separate condition string from format in UK_ASSERT, UK_WARNIF



Hi Simon,

Please add an example to clarify the reason behind this fix.

Thanks,
Costin

On 03/19/2018 11:04 AM, Simon Kuenzer wrote:
> Whenever a condition expression for UK_ASSERT() and UK_WARNIF()
> is not fulfilled, the macros stringify the condition and print
> it with uk_printd(). Because this string was handed over with
> the format, the modulo operator (%) in the expression causes
> formatting errors.
> This patch hands over this condition string as separate argument
> which will not be processed by uk_printd().
> 
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
>  lib/ukdebug/include/uk/assert.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ukdebug/include/uk/assert.h b/lib/ukdebug/include/uk/assert.h
> index 70e9e72..8569cdc 100644
> --- a/lib/ukdebug/include/uk/assert.h
> +++ b/lib/ukdebug/include/uk/assert.h
> @@ -48,7 +48,8 @@
>  #define UK_ASSERT(x)                                                 \
>       do {                                                            \
>               if (unlikely(!(x))) {                                   \
> -                     uk_printd(DLVL_CRIT, "Assertion failure: " STRINGIFY(x) 
> "\n"); \
> +                     uk_printd(DLVL_CRIT, "Assertion failure: %s\n", \
> +                               STRINGIFY(x));                        \
>                       /* TODO: stack trace */                         \
>                       ukplat_terminate(UKPLAT_CRASH);                 \
>               }                                                       \
> @@ -57,7 +58,8 @@
>  #define UK_WARNIF(x)                                                 \
>       do {                                                            \
>               if (unlikely(x)) {                                      \
> -                     uk_printd(DLVL_WARN, "Condition warning: " STRINGIFY(x) 
> "\n"); \
> +                     uk_printd(DLVL_WARN, "Condition warning: %s\n", \
> +                               STRINGIFY(x));                        \
>               }                                                       \
>       } while (0)
>  
> 

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.