[libvirt] [PATCH v2 01/18] security: Unify header conditionals

Daniel P. Berrangé berrange at redhat.com
Thu Dec 6 11:16:54 UTC 2018


On Thu, Nov 29, 2018 at 02:52:16PM +0100, Michal Privoznik wrote:
> To avoid including a header file twice the following pattern is
> used:
> 
>  #ifndef __SOMETHING__
>  # define __SOMETHING__
> 
> where __SOMETHING__ should correspond to the header file name.
> However, some of our header files break that pattern.

Looking at the git tree as a whole, we're all over the place
with the naming of these cnoditionals. There's many othuer
files using a __VIR prefix which don't have 'vir' in the
filename:

$ git grep ifndef  '*.h' | grep VIR | grep -v vir | wc -l
103


So I don't think this is something we should really change here.
I think it points to the need for a syntax-check rule to enforce
a given convention and then a tree-wide fixup to comply.

> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/security/security_apparmor.h | 6 +++---
>  src/security/security_dac.h      | 6 +++---
>  src/security/security_driver.h   | 6 +++---
>  src/security/security_manager.h  | 6 +++---
>  src/security/security_nop.h      | 6 +++---
>  src/security/security_selinux.h  | 6 +++---
>  src/security/security_stack.h    | 6 +++---
>  7 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/src/security/security_apparmor.h b/src/security/security_apparmor.h
> index 7872588f64..6b454d1b5c 100644
> --- a/src/security/security_apparmor.h
> +++ b/src/security/security_apparmor.h
> @@ -19,8 +19,8 @@
>   *   Jamie Strandboge <jamie at canonical.com>
>   *
>   */
> -#ifndef __VIR_SECURITY_APPARMOR_H__
> -# define __VIR_SECURITY_APPARMOR_H__
> +#ifndef __SECURITY_APPARMOR_H__
> +# define __SECURITY_APPARMOR_H__
>  
>  # include "security_driver.h"
>  
> @@ -30,4 +30,4 @@ extern virSecurityDriver virAppArmorSecurityDriver;
>  # define PROFILE_NAME_SIZE  8 + VIR_UUID_STRING_BUFLEN /* AA_PREFIX + uuid */
>  # define MAX_FILE_LEN       (1024*1024*10)  /* 10MB limit for sanity check */
>  
> -#endif /* __VIR_SECURITY_APPARMOR_H__ */
> +#endif /* __SECURITY_APPARMOR_H__ */
> diff --git a/src/security/security_dac.h b/src/security/security_dac.h
> index 97681c9610..8007bde000 100644
> --- a/src/security/security_dac.h
> +++ b/src/security/security_dac.h
> @@ -20,8 +20,8 @@
>  
>  #include "security_driver.h"
>  
> -#ifndef __VIR_SECURITY_DAC
> -# define __VIR_SECURITY_DAC
> +#ifndef __SECURITY_DAC__
> +# define __SECURITY_DAC__
>  
>  extern virSecurityDriver virSecurityDriverDAC;
>  
> @@ -38,4 +38,4 @@ void virSecurityDACSetMountNamespace(virSecurityManagerPtr mgr,
>  void virSecurityDACSetChownCallback(virSecurityManagerPtr mgr,
>                                      virSecurityManagerDACChownCallback chownCallback);
>  
> -#endif /* __VIR_SECURITY_DAC */
> +#endif /* __SECURITY_DAC__ */
> diff --git a/src/security/security_driver.h b/src/security/security_driver.h
> index cd221f1c78..25d49bb0f4 100644
> --- a/src/security/security_driver.h
> +++ b/src/security/security_driver.h
> @@ -19,8 +19,8 @@
>   *     James Morris <jmorris at namei.org>
>   *
>   */
> -#ifndef __VIR_SECURITY_H__
> -# define __VIR_SECURITY_H__
> +#ifndef __SECURITY_DRIVER_H__
> +# define __SECURITY_DRIVER_H__
>  
>  # include "internal.h"
>  # include "domain_conf.h"
> @@ -226,4 +226,4 @@ struct _virSecurityDriver {
>  virSecurityDriverPtr virSecurityDriverLookup(const char *name,
>                                               const char *virtDriver);
>  
> -#endif /* __VIR_SECURITY_H__ */
> +#endif /* __SECURITY_DRIVER_H__ */
> diff --git a/src/security/security_manager.h b/src/security/security_manager.h
> index 7e82304689..139b70ec10 100644
> --- a/src/security/security_manager.h
> +++ b/src/security/security_manager.h
> @@ -20,8 +20,8 @@
>   * Author: Daniel P. Berrange <berrange at redhat.com>
>   */
>  
> -#ifndef VIR_SECURITY_MANAGER_H__
> -# define VIR_SECURITY_MANAGER_H__
> +#ifndef __SECURITY_MANAGER_H__
> +# define __SECURITY_MANAGER_H__
>  
>  # include "domain_conf.h"
>  # include "vircommand.h"
> @@ -210,4 +210,4 @@ void
>  virSecurityManagerMetadataUnlock(virSecurityManagerPtr mgr,
>                                   virSecurityManagerMetadataLockStatePtr *state);
>  
> -#endif /* VIR_SECURITY_MANAGER_H__ */
> +#endif /* __SECURITY_MANAGER_H__ */
> diff --git a/src/security/security_nop.h b/src/security/security_nop.h
> index 514b339467..7b2ded2292 100644
> --- a/src/security/security_nop.h
> +++ b/src/security/security_nop.h
> @@ -17,11 +17,11 @@
>   *
>   */
>  
> -#ifndef __VIR_SECURITY_NOP_H__
> -# define __VIR_SECURITY_NOP_H__
> +#ifndef __SECURITY_NOP_H__
> +# define __SECURITY_NOP_H__
>  
>  # include "security_driver.h"
>  
>  extern virSecurityDriver virSecurityDriverNop;
>  
> -#endif /* __VIR_SECURITY_NOP_H__ */
> +#endif /* __SECURITY_NOP_H__ */
> diff --git a/src/security/security_selinux.h b/src/security/security_selinux.h
> index 1700d8c661..11b62acb52 100644
> --- a/src/security/security_selinux.h
> +++ b/src/security/security_selinux.h
> @@ -19,9 +19,9 @@
>   *     James Morris <jmorris at namei.org>
>   *
>   */
> -#ifndef __VIR_SECURITY_SELINUX_H__
> -# define __VIR_SECURITY_SELINUX_H__
> +#ifndef __SECURITY_SELINUX_H__
> +# define __SECURITY_SELINUX_H__
>  
>  extern virSecurityDriver virSecurityDriverSELinux;
>  
> -#endif /* __VIR_SECURITY_SELINUX_H__ */
> +#endif /* __SECURITY_SELINUX_H__ */
> diff --git a/src/security/security_stack.h b/src/security/security_stack.h
> index b38f9a9481..7e6ab3d93e 100644
> --- a/src/security/security_stack.h
> +++ b/src/security/security_stack.h
> @@ -20,8 +20,8 @@
>  
>  #include "security_driver.h"
>  
> -#ifndef __VIR_SECURITY_STACK
> -# define __VIR_SECURITY_STACK
> +#ifndef __SECURITY_STACK__
> +# define __SECURITY_STACK__
>  
>  extern virSecurityDriver virSecurityDriverStack;
>  
> @@ -35,4 +35,4 @@ virSecurityStackGetPrimary(virSecurityManagerPtr mgr);
>  virSecurityManagerPtr*
>  virSecurityStackGetNested(virSecurityManagerPtr mgr);
>  
> -#endif /* __VIR_SECURITY_STACK */
> +#endif /* __SECURITY_STACK__ */
> -- 
> 2.18.1
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list