diff mbox series

[2/7] xsm/flask: sidtab: Fix MISRA C 2012 Rule 20.7 violations

Message ID 20220819194359.1196539-3-burzalodowa@gmail.com (mailing list archive)
State New, archived
Headers show
Series Fix MISRA C 2012 Rule 20.7 violations | expand

Commit Message

Xenia Ragiadakou Aug. 19, 2022, 7:43 p.m. UTC
In macros SIDTAB_HASH(), INIT_SIDTAB_LOCK(), SIDTAB_LOCK() and SIDTAB_UNLOCK(),
add parentheses around the macro parameter to prevent against unintended
expansions.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---
 xen/xsm/flask/ss/sidtab.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefano Stabellini Aug. 19, 2022, 10:14 p.m. UTC | #1
On Fri, 19 Aug 2022, Xenia Ragiadakou wrote:
> In macros SIDTAB_HASH(), INIT_SIDTAB_LOCK(), SIDTAB_LOCK() and SIDTAB_UNLOCK(),
> add parentheses around the macro parameter to prevent against unintended
> expansions.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/xsm/flask/ss/sidtab.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/xsm/flask/ss/sidtab.c b/xen/xsm/flask/ss/sidtab.c
> index 74babfac9c..69fc3389b3 100644
> --- a/xen/xsm/flask/ss/sidtab.c
> +++ b/xen/xsm/flask/ss/sidtab.c
> @@ -14,11 +14,11 @@
>  #include "security.h"
>  #include "sidtab.h"
>  
> -#define SIDTAB_HASH(sid) (sid & SIDTAB_HASH_MASK)
> +#define SIDTAB_HASH(sid) ((sid) & SIDTAB_HASH_MASK)
>  
> -#define INIT_SIDTAB_LOCK(s) spin_lock_init(&s->lock)
> -#define SIDTAB_LOCK(s) spin_lock(&s->lock)
> -#define SIDTAB_UNLOCK(s) spin_unlock(&s->lock)
> +#define INIT_SIDTAB_LOCK(s) spin_lock_init(&(s)->lock)
> +#define SIDTAB_LOCK(s) spin_lock(&(s)->lock)
> +#define SIDTAB_UNLOCK(s) spin_unlock(&(s)->lock)
>  
>  int sidtab_init(struct sidtab *s)
>  {
> -- 
> 2.34.1
> 
>
Daniel P. Smith Aug. 26, 2022, 1:41 p.m. UTC | #2
On 8/19/22 15:43, Xenia Ragiadakou wrote:
> In macros SIDTAB_HASH(), INIT_SIDTAB_LOCK(), SIDTAB_LOCK() and SIDTAB_UNLOCK(),
> add parentheses around the macro parameter to prevent against unintended
> expansions.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
> ---
>  xen/xsm/flask/ss/sidtab.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/xsm/flask/ss/sidtab.c b/xen/xsm/flask/ss/sidtab.c
> index 74babfac9c..69fc3389b3 100644
> --- a/xen/xsm/flask/ss/sidtab.c
> +++ b/xen/xsm/flask/ss/sidtab.c
> @@ -14,11 +14,11 @@
>  #include "security.h"
>  #include "sidtab.h"
>  
> -#define SIDTAB_HASH(sid) (sid & SIDTAB_HASH_MASK)
> +#define SIDTAB_HASH(sid) ((sid) & SIDTAB_HASH_MASK)
>  
> -#define INIT_SIDTAB_LOCK(s) spin_lock_init(&s->lock)
> -#define SIDTAB_LOCK(s) spin_lock(&s->lock)
> -#define SIDTAB_UNLOCK(s) spin_unlock(&s->lock)
> +#define INIT_SIDTAB_LOCK(s) spin_lock_init(&(s)->lock)
> +#define SIDTAB_LOCK(s) spin_lock(&(s)->lock)
> +#define SIDTAB_UNLOCK(s) spin_unlock(&(s)->lock)
>  
>  int sidtab_init(struct sidtab *s)
>  {

Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
diff mbox series

Patch

diff --git a/xen/xsm/flask/ss/sidtab.c b/xen/xsm/flask/ss/sidtab.c
index 74babfac9c..69fc3389b3 100644
--- a/xen/xsm/flask/ss/sidtab.c
+++ b/xen/xsm/flask/ss/sidtab.c
@@ -14,11 +14,11 @@ 
 #include "security.h"
 #include "sidtab.h"
 
-#define SIDTAB_HASH(sid) (sid & SIDTAB_HASH_MASK)
+#define SIDTAB_HASH(sid) ((sid) & SIDTAB_HASH_MASK)
 
-#define INIT_SIDTAB_LOCK(s) spin_lock_init(&s->lock)
-#define SIDTAB_LOCK(s) spin_lock(&s->lock)
-#define SIDTAB_UNLOCK(s) spin_unlock(&s->lock)
+#define INIT_SIDTAB_LOCK(s) spin_lock_init(&(s)->lock)
+#define SIDTAB_LOCK(s) spin_lock(&(s)->lock)
+#define SIDTAB_UNLOCK(s) spin_unlock(&(s)->lock)
 
 int sidtab_init(struct sidtab *s)
 {