diff mbox

[Xen-devel,RFC,08/14] xen/xsm: flask: Rename variable "bool" in "b"

Message ID 1394640969-25583-9-git-send-email-julien.grall@linaro.org
State Accepted, archived
Commit 17822abf74ac7f029f55439584b13173e1d13225
Headers show

Commit Message

Julien Grall March 12, 2014, 4:16 p.m. UTC
On ARM, the compilation is failing with the following error:
In file included from flask_op.c:21:0:
./include/conditional.h:24:43: error: two or more data types in declaration specifiers
./include/conditional.h:25:42: error: two or more data types in declaration specifiers

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---
 xen/xsm/flask/include/conditional.h |    4 ++--
 xen/xsm/flask/ss/services.c         |   14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

Comments

Andrew Cooper March 12, 2014, 4:26 p.m. UTC | #1
On 12/03/14 16:16, Julien Grall wrote:
> On ARM, the compilation is failing with the following error:
> In file included from flask_op.c:21:0:
> ./include/conditional.h:24:43: error: two or more data types in declaration specifiers
> ./include/conditional.h:25:42: error: two or more data types in declaration specifiers
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>

I am curious as to why this works on x86.  The name 'bool' is specified
as an alias for '_Bool' by C99/stdboot.h

~Andrew

> ---
>  xen/xsm/flask/include/conditional.h |    4 ++--
>  xen/xsm/flask/ss/services.c         |   14 +++++++-------
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/xen/xsm/flask/include/conditional.h b/xen/xsm/flask/include/conditional.h
> index 043cfd8..9055340 100644
> --- a/xen/xsm/flask/include/conditional.h
> +++ b/xen/xsm/flask/include/conditional.h
> @@ -21,7 +21,7 @@ int security_set_bools(int len, int *values);
>  
>  int security_find_bool(const char *name);
>  
> -char *security_get_bool_name(unsigned int bool);
> -int security_get_bool_value(unsigned int bool);
> +char *security_get_bool_name(unsigned int b);
> +int security_get_bool_value(unsigned int b);
>  
>  #endif
> diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c
> index aebbec7..59234ff 100644
> --- a/xen/xsm/flask/ss/services.c
> +++ b/xen/xsm/flask/ss/services.c
> @@ -1958,7 +1958,7 @@ out:
>      return rc;
>  }
>  
> -int security_get_bool_value(unsigned int bool)
> +int security_get_bool_value(unsigned int b)
>  {
>      int rc = 0;
>      unsigned int len;
> @@ -1966,19 +1966,19 @@ int security_get_bool_value(unsigned int bool)
>      POLICY_RDLOCK;
>  
>      len = policydb.p_bools.nprim;
> -    if ( bool >= len )
> +    if ( b >= len )
>      {
>          rc = -ENOENT;
>          goto out;
>      }
>  
> -    rc = policydb.bool_val_to_struct[bool]->state;
> +    rc = policydb.bool_val_to_struct[b]->state;
>  out:
>      POLICY_RDUNLOCK;
>      return rc;
>  }
>  
> -char *security_get_bool_name(unsigned int bool)
> +char *security_get_bool_name(unsigned int b)
>  {
>      unsigned int len;
>      char *rv = NULL;
> @@ -1986,16 +1986,16 @@ char *security_get_bool_name(unsigned int bool)
>      POLICY_RDLOCK;
>  
>      len = policydb.p_bools.nprim;
> -    if ( bool >= len )
> +    if ( b >= len )
>      {
>          goto out;
>      }
>  
> -    len = strlen(policydb.p_bool_val_to_name[bool]) + 1;
> +    len = strlen(policydb.p_bool_val_to_name[b]) + 1;
>      rv = xmalloc_array(char, len);
>      if ( !rv )
>          goto out;
> -    memcpy(rv, policydb.p_bool_val_to_name[bool], len);
> +    memcpy(rv, policydb.p_bool_val_to_name[b], len);
>  out:
>      POLICY_RDUNLOCK;
>      return rv;
Julien Grall March 13, 2014, 1:17 p.m. UTC | #2
Hi Andrew,

On 03/12/2014 04:26 PM, Andrew Cooper wrote:
> On 12/03/14 16:16, Julien Grall wrote:
>> On ARM, the compilation is failing with the following error:
>> In file included from flask_op.c:21:0:
>> ./include/conditional.h:24:43: error: two or more data types in declaration specifiers
>> ./include/conditional.h:25:42: error: two or more data types in declaration specifiers
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
> 
> I am curious as to why this works on x86.  The name 'bool' is specified
> as an alias for '_Bool' by C99/stdboot.h

It's because ARM include indirectly stdbool.h via xen/device_tree.h.
I've tried to add "#include <xen/stdbool.h>" in conditional.h and I get
the same compilation error.

Regards,
Jan Beulich March 13, 2014, 1:57 p.m. UTC | #3
>>> On 13.03.14 at 14:17, Julien Grall <julien.grall@linaro.org> wrote:
> Hi Andrew,
> 
> On 03/12/2014 04:26 PM, Andrew Cooper wrote:
>> On 12/03/14 16:16, Julien Grall wrote:
>>> On ARM, the compilation is failing with the following error:
>>> In file included from flask_op.c:21:0:
>>> ./include/conditional.h:24:43: error: two or more data types in declaration 
> specifiers
>>> ./include/conditional.h:25:42: error: two or more data types in declaration 
> specifiers
>>>
>>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
>> 
>> I am curious as to why this works on x86.  The name 'bool' is specified
>> as an alias for '_Bool' by C99/stdboot.h
> 
> It's because ARM include indirectly stdbool.h via xen/device_tree.h.
> I've tried to add "#include <xen/stdbool.h>" in conditional.h and I get
> the same compilation error.

And (at least so far) this isn't intended to be included by arbitrary
code, it exists solely to support code shared with the tools (e.g.
common/libelf/). Which isn't to say that I mind the change - it's
valid cleanup after all.

Jan
Daniel De Graaf March 13, 2014, 2:27 p.m. UTC | #4
On 03/12/2014 12:16 PM, Julien Grall wrote:
> On ARM, the compilation is failing with the following error:
> In file included from flask_op.c:21:0:
> ./include/conditional.h:24:43: error: two or more data types in declaration specifiers
> ./include/conditional.h:25:42: error: two or more data types in declaration specifiers
>
> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>

Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

> ---
>   xen/xsm/flask/include/conditional.h |    4 ++--
>   xen/xsm/flask/ss/services.c         |   14 +++++++-------
>   2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/xen/xsm/flask/include/conditional.h b/xen/xsm/flask/include/conditional.h
> index 043cfd8..9055340 100644
> --- a/xen/xsm/flask/include/conditional.h
> +++ b/xen/xsm/flask/include/conditional.h
> @@ -21,7 +21,7 @@ int security_set_bools(int len, int *values);
>
>   int security_find_bool(const char *name);
>
> -char *security_get_bool_name(unsigned int bool);
> -int security_get_bool_value(unsigned int bool);
> +char *security_get_bool_name(unsigned int b);
> +int security_get_bool_value(unsigned int b);
>
>   #endif
> diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c
> index aebbec7..59234ff 100644
> --- a/xen/xsm/flask/ss/services.c
> +++ b/xen/xsm/flask/ss/services.c
> @@ -1958,7 +1958,7 @@ out:
>       return rc;
>   }
>
> -int security_get_bool_value(unsigned int bool)
> +int security_get_bool_value(unsigned int b)
>   {
>       int rc = 0;
>       unsigned int len;
> @@ -1966,19 +1966,19 @@ int security_get_bool_value(unsigned int bool)
>       POLICY_RDLOCK;
>
>       len = policydb.p_bools.nprim;
> -    if ( bool >= len )
> +    if ( b >= len )
>       {
>           rc = -ENOENT;
>           goto out;
>       }
>
> -    rc = policydb.bool_val_to_struct[bool]->state;
> +    rc = policydb.bool_val_to_struct[b]->state;
>   out:
>       POLICY_RDUNLOCK;
>       return rc;
>   }
>
> -char *security_get_bool_name(unsigned int bool)
> +char *security_get_bool_name(unsigned int b)
>   {
>       unsigned int len;
>       char *rv = NULL;
> @@ -1986,16 +1986,16 @@ char *security_get_bool_name(unsigned int bool)
>       POLICY_RDLOCK;
>
>       len = policydb.p_bools.nprim;
> -    if ( bool >= len )
> +    if ( b >= len )
>       {
>           goto out;
>       }
>
> -    len = strlen(policydb.p_bool_val_to_name[bool]) + 1;
> +    len = strlen(policydb.p_bool_val_to_name[b]) + 1;
>       rv = xmalloc_array(char, len);
>       if ( !rv )
>           goto out;
> -    memcpy(rv, policydb.p_bool_val_to_name[bool], len);
> +    memcpy(rv, policydb.p_bool_val_to_name[b], len);
>   out:
>       POLICY_RDUNLOCK;
>       return rv;
>
Ian Campbell March 14, 2014, 5:24 p.m. UTC | #5
On Thu, 2014-03-13 at 10:27 -0400, Daniel De Graaf wrote:
> On 03/12/2014 12:16 PM, Julien Grall wrote:
> > On ARM, the compilation is failing with the following error:
> > In file included from flask_op.c:21:0:
> > ./include/conditional.h:24:43: error: two or more data types in declaration specifiers
> > ./include/conditional.h:25:42: error: two or more data types in declaration specifiers
> >
> > Signed-off-by: Julien Grall <julien.grall@linaro.org>
> > Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
> 
> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

Acked-by: Ian Campbell <ian.campbell@citrix.com>
diff mbox

Patch

diff --git a/xen/xsm/flask/include/conditional.h b/xen/xsm/flask/include/conditional.h
index 043cfd8..9055340 100644
--- a/xen/xsm/flask/include/conditional.h
+++ b/xen/xsm/flask/include/conditional.h
@@ -21,7 +21,7 @@  int security_set_bools(int len, int *values);
 
 int security_find_bool(const char *name);
 
-char *security_get_bool_name(unsigned int bool);
-int security_get_bool_value(unsigned int bool);
+char *security_get_bool_name(unsigned int b);
+int security_get_bool_value(unsigned int b);
 
 #endif
diff --git a/xen/xsm/flask/ss/services.c b/xen/xsm/flask/ss/services.c
index aebbec7..59234ff 100644
--- a/xen/xsm/flask/ss/services.c
+++ b/xen/xsm/flask/ss/services.c
@@ -1958,7 +1958,7 @@  out:
     return rc;
 }
 
-int security_get_bool_value(unsigned int bool)
+int security_get_bool_value(unsigned int b)
 {
     int rc = 0;
     unsigned int len;
@@ -1966,19 +1966,19 @@  int security_get_bool_value(unsigned int bool)
     POLICY_RDLOCK;
 
     len = policydb.p_bools.nprim;
-    if ( bool >= len )
+    if ( b >= len )
     {
         rc = -ENOENT;
         goto out;
     }
 
-    rc = policydb.bool_val_to_struct[bool]->state;
+    rc = policydb.bool_val_to_struct[b]->state;
 out:
     POLICY_RDUNLOCK;
     return rc;
 }
 
-char *security_get_bool_name(unsigned int bool)
+char *security_get_bool_name(unsigned int b)
 {
     unsigned int len;
     char *rv = NULL;
@@ -1986,16 +1986,16 @@  char *security_get_bool_name(unsigned int bool)
     POLICY_RDLOCK;
 
     len = policydb.p_bools.nprim;
-    if ( bool >= len )
+    if ( b >= len )
     {
         goto out;
     }
 
-    len = strlen(policydb.p_bool_val_to_name[bool]) + 1;
+    len = strlen(policydb.p_bool_val_to_name[b]) + 1;
     rv = xmalloc_array(char, len);
     if ( !rv )
         goto out;
-    memcpy(rv, policydb.p_bool_val_to_name[bool], len);
+    memcpy(rv, policydb.p_bool_val_to_name[b], len);
 out:
     POLICY_RDUNLOCK;
     return rv;