[1/3] log: choose EAL log type on registration failure

Message ID 20210310140107.2730088-2-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series cleanup drivers log registration |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon March 10, 2021, 2:01 p.m. UTC
  In the unlikely case where something goes wrong
while registering a log type,
the fallback is to use the log type 0, assigned to EAL.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/include/rte_log.h | 1 +
 1 file changed, 1 insertion(+)
  

Comments

David Marchand March 23, 2021, 6:22 p.m. UTC | #1
On Wed, Mar 10, 2021 at 3:01 PM Thomas Monjalon <thomas@monjalon.net> wrote:
>
> In the unlikely case where something goes wrong
> while registering a log type,
> the fallback is to use the log type 0, assigned to EAL.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
>  lib/librte_eal/include/rte_log.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
> index e6192892c3..178a265c3f 100644
> --- a/lib/librte_eal/include/rte_log.h
> +++ b/lib/librte_eal/include/rte_log.h
> @@ -392,6 +392,7 @@ RTE_INIT(__##type)                                                  \
>  {                                                                      \
>         type = rte_log_register_type_and_pick_level(RTE_STR(name),      \
>                                                     RTE_LOG_##level);   \
> +       type = RTE_MAX(0, type);                                        \
>  }

Hard to read and to grep, can we use explicit logtype?

if (type < 0)
    type = RTE_LOGTYPE_EAL;
  
Thomas Monjalon March 23, 2021, 6:43 p.m. UTC | #2
23/03/2021 19:22, David Marchand:
> On Wed, Mar 10, 2021 at 3:01 PM Thomas Monjalon <thomas@monjalon.net> wrote:
> >
> > In the unlikely case where something goes wrong
> > while registering a log type,
> > the fallback is to use the log type 0, assigned to EAL.
> >
> > Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
[...]
> >  {                                                                      \
> >         type = rte_log_register_type_and_pick_level(RTE_STR(name),      \
> >                                                     RTE_LOG_##level);   \
> > +       type = RTE_MAX(0, type);                                        \
> >  }
> 
> Hard to read and to grep, can we use explicit logtype?
> 
> if (type < 0)
>     type = RTE_LOGTYPE_EAL;

Yes I agree it is better because we can grep the explicit name.
  

Patch

diff --git a/lib/librte_eal/include/rte_log.h b/lib/librte_eal/include/rte_log.h
index e6192892c3..178a265c3f 100644
--- a/lib/librte_eal/include/rte_log.h
+++ b/lib/librte_eal/include/rte_log.h
@@ -392,6 +392,7 @@  RTE_INIT(__##type)							\
 {									\
 	type = rte_log_register_type_and_pick_level(RTE_STR(name),	\
 						    RTE_LOG_##level);	\
+	type = RTE_MAX(0, type);                                        \
 }
 
 #ifdef __cplusplus