libsel4: Explicitly casting cap rights

This commit is contained in:
Stephen Sherratt 2016-08-16 17:05:34 +10:00
parent 9c72698655
commit 0a2a9842d2

View file

@ -24,7 +24,7 @@ typedef seL4_CapRights seL4_CapRights_t;
static inline seL4_CapRights_t CONST
seL4_CapRights_new(seL4_Uint32 grant, seL4_Uint32 read, seL4_Uint32 write)
{
seL4_CapRights cap_rights = 0;
unsigned cap_rights = 0;
/* Ensure arguments are either 0 or 1 */
seL4_DebugAssert(grant <= 1);
@ -32,34 +32,34 @@ seL4_CapRights_new(seL4_Uint32 grant, seL4_Uint32 read, seL4_Uint32 write)
seL4_DebugAssert(write <= 1);
if (grant) {
cap_rights |= seL4_CanGrant;
cap_rights |= (unsigned)seL4_CanGrant;
}
if (read) {
cap_rights |= seL4_CanRead;
cap_rights |= (unsigned)seL4_CanRead;
}
if (write) {
cap_rights |= seL4_CanWrite;
cap_rights |= (unsigned)seL4_CanWrite;
}
return cap_rights;
return (seL4_CapRights_t)cap_rights;
}
static inline seL4_Uint32 CONST
seL4_CapRights_get_capAllowGrant(seL4_CapRights_t cap_rights)
{
return !!(cap_rights & seL4_CanGrant);
return !!((unsigned)cap_rights & (unsigned)seL4_CanGrant);
}
static inline seL4_Uint32 CONST
seL4_CapRights_get_capAllowRead(seL4_CapRights_t cap_rights)
{
return !!(cap_rights & seL4_CanRead);
return !!((unsigned)cap_rights & (unsigned)seL4_CanRead);
}
static inline seL4_Uint32 CONST
seL4_CapRights_get_capAllowWrite(seL4_CapRights_t cap_rights)
{
return !!(cap_rights & seL4_CanWrite);
return !!((unsigned)cap_rights & (unsigned)seL4_CanWrite);
}
static inline seL4_CapRights_t CONST
@ -69,9 +69,9 @@ seL4_CapRights_set_capAllowGrant(seL4_CapRights_t cap_rights, seL4_Uint32 value)
seL4_DebugAssert(value <= 1);
if (value) {
return cap_rights | seL4_CanGrant;
return (seL4_CapRights_t)((unsigned)cap_rights | (unsigned)seL4_CanGrant);
} else {
return cap_rights & ~seL4_CanGrant;
return (seL4_CapRights_t)((unsigned)cap_rights & ~(unsigned)seL4_CanGrant);
}
}
@ -82,9 +82,9 @@ seL4_CapRights_set_capAllowRead(seL4_CapRights_t cap_rights, seL4_Uint32 value)
seL4_DebugAssert(value <= 1);
if (value) {
return cap_rights | seL4_CanRead;
return (seL4_CapRights_t)((unsigned)cap_rights | (unsigned)seL4_CanRead);
} else {
return cap_rights & ~seL4_CanRead;
return (seL4_CapRights_t)((unsigned)cap_rights & ~(unsigned)seL4_CanRead);
}
}
@ -95,8 +95,8 @@ seL4_CapRights_set_capAllowWrite(seL4_CapRights_t cap_rights, seL4_Uint32 value)
seL4_DebugAssert(value <= 1);
if (value) {
return cap_rights | seL4_CanWrite;
return (seL4_CapRights_t)((unsigned)cap_rights | (unsigned)seL4_CanWrite);
} else {
return cap_rights & ~seL4_CanWrite;
return (seL4_CapRights_t)((unsigned)cap_rights & ~(unsigned)seL4_CanWrite);
}
}