[v3,1/4] kni: add define guards to avoid multi-inclusion

Message ID tencent_73F6A73E11363A87DFB62372225531733C08@qq.com (mailing list archive)
State Not Applicable, archived
Delegated to: David Marchand
Headers
Series add define guards to avoid multi-inclusion |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Weiguo Li Feb. 9, 2022, 7:24 a.m. UTC
Supplement define guards to prevent multiple inclusion.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 lib/kni/rte_kni_fifo.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Ferruh Yigit Feb. 9, 2022, 1:52 p.m. UTC | #1
On 2/9/2022 7:24 AM, Weiguo Li wrote:
> Supplement define guards to prevent multiple inclusion.
> 

It is kind of private header and only 'rte_kni.c' includes it,
that is why missing guards doesn't cause trouble but no harm/objection
to have them.

> Signed-off-by: Weiguo Li <liwg06@foxmail.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

> ---
>   lib/kni/rte_kni_fifo.h | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/kni/rte_kni_fifo.h b/lib/kni/rte_kni_fifo.h
> index d2ec82fe87..2ff71554c0 100644
> --- a/lib/kni/rte_kni_fifo.h
> +++ b/lib/kni/rte_kni_fifo.h
> @@ -2,7 +2,8 @@
>    * Copyright(c) 2010-2014 Intel Corporation
>    */
>   
> -
> +#ifndef RTE_KNI_FIFO_H
> +#define RTE_KNI_FIFO_H

It doesn't really differ much but other kni header guards wrapped with '_',
I don't now why.
If there will be a new version can you please apply the same here to have
consistency, like:
#ifndef _RTE_KNI_FIFO_H_

>   
>   /**
>    * @internal when c11 memory model enabled use c11 atomic memory barrier.
> @@ -115,3 +116,5 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
>   	uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read);
>   	return (fifo_read - fifo_write - 1) & (fifo->len - 1);
>   }
> +
> +#endif /* RTE_KNI_FIFO_H */
  
Thomas Monjalon Feb. 22, 2022, 2:48 p.m. UTC | #2
09/02/2022 14:52, Ferruh Yigit:
> On 2/9/2022 7:24 AM, Weiguo Li wrote:
> > +#ifndef RTE_KNI_FIFO_H
> > +#define RTE_KNI_FIFO_H
> 
> It doesn't really differ much but other kni header guards wrapped with '_',
> I don't now why.

No good reason I think.

> If there will be a new version can you please apply the same here to have
> consistency, like:
> #ifndef _RTE_KNI_FIFO_H_

I think consistency is not important here.
We should not add underscores where not needed,
it gives a false impression of reserved keywords.
  

Patch

diff --git a/lib/kni/rte_kni_fifo.h b/lib/kni/rte_kni_fifo.h
index d2ec82fe87..2ff71554c0 100644
--- a/lib/kni/rte_kni_fifo.h
+++ b/lib/kni/rte_kni_fifo.h
@@ -2,7 +2,8 @@ 
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-
+#ifndef RTE_KNI_FIFO_H
+#define RTE_KNI_FIFO_H
 
 /**
  * @internal when c11 memory model enabled use c11 atomic memory barrier.
@@ -115,3 +116,5 @@  kni_fifo_free_count(struct rte_kni_fifo *fifo)
 	uint32_t fifo_read = __KNI_LOAD_ACQUIRE(&fifo->read);
 	return (fifo_read - fifo_write - 1) & (fifo->len - 1);
 }
+
+#endif /* RTE_KNI_FIFO_H */