mirror of
https://github.com/SELinuxProject/selinux
synced 2025-04-09 11:12:13 +00:00
libsepol/cil: introduce intermediate cast to silence -Wvoid-pointer-to-enum-cast
clang 11.0.0 reports the following warning several times (when building with "make CC=clang" from libsepol directory, in the default configuration of the git repository): ../cil/src/cil_binary.c:1980:8: error: cast to smaller integer type 'enum cil_flavor' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast] op = (enum cil_flavor)curr->data; ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Silence this warning by casting the pointer to an integer the cast to enum cil_flavor. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
4662bdc11c
commit
32f8ed3d6b
@ -1977,7 +1977,7 @@ static void __cil_expr_to_string(struct cil_list *expr, enum cil_flavor flavor,
|
|||||||
curr = expr->head;
|
curr = expr->head;
|
||||||
|
|
||||||
if (curr->flavor == CIL_OP) {
|
if (curr->flavor == CIL_OP) {
|
||||||
op = (enum cil_flavor)curr->data;
|
op = (enum cil_flavor)(uintptr_t)curr->data;
|
||||||
|
|
||||||
if (op == CIL_ALL) {
|
if (op == CIL_ALL) {
|
||||||
*out = cil_strdup(CIL_KEY_ALL);
|
*out = cil_strdup(CIL_KEY_ALL);
|
||||||
@ -2076,7 +2076,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list
|
|||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
} else if (item->flavor == CIL_OP) {
|
} else if (item->flavor == CIL_OP) {
|
||||||
enum cil_flavor cil_op = (enum cil_flavor)item->data;
|
enum cil_flavor cil_op = (enum cil_flavor)(uintptr_t)item->data;
|
||||||
|
|
||||||
op = cil_malloc(sizeof(*op));
|
op = cil_malloc(sizeof(*op));
|
||||||
op->bool = 0;
|
op->bool = 0;
|
||||||
@ -2562,7 +2562,7 @@ int __cil_constrain_expr_leaf_to_sepol_expr(policydb_t *pdb, const struct cil_db
|
|||||||
struct cil_list_item *l_item = op_item->next;
|
struct cil_list_item *l_item = op_item->next;
|
||||||
struct cil_list_item *r_item = op_item->next->next;
|
struct cil_list_item *r_item = op_item->next->next;
|
||||||
|
|
||||||
enum cil_flavor l_operand = (enum cil_flavor)l_item->data;
|
enum cil_flavor l_operand = (enum cil_flavor)(uintptr_t)l_item->data;
|
||||||
|
|
||||||
switch (l_operand) {
|
switch (l_operand) {
|
||||||
case CIL_CONS_U1:
|
case CIL_CONS_U1:
|
||||||
@ -2593,7 +2593,7 @@ int __cil_constrain_expr_leaf_to_sepol_expr(policydb_t *pdb, const struct cil_db
|
|||||||
expr->attr = CEXPR_TYPE | CEXPR_XTARGET;
|
expr->attr = CEXPR_TYPE | CEXPR_XTARGET;
|
||||||
break;
|
break;
|
||||||
case CIL_CONS_L1: {
|
case CIL_CONS_L1: {
|
||||||
enum cil_flavor r_operand = (enum cil_flavor)r_item->data;
|
enum cil_flavor r_operand = (enum cil_flavor)(uintptr_t)r_item->data;
|
||||||
|
|
||||||
if (r_operand == CIL_CONS_L2) {
|
if (r_operand == CIL_CONS_L2) {
|
||||||
expr->attr = CEXPR_L1L2;
|
expr->attr = CEXPR_L1L2;
|
||||||
@ -2608,7 +2608,7 @@ int __cil_constrain_expr_leaf_to_sepol_expr(policydb_t *pdb, const struct cil_db
|
|||||||
expr->attr = CEXPR_L2H2;
|
expr->attr = CEXPR_L2H2;
|
||||||
break;
|
break;
|
||||||
case CIL_CONS_H1: {
|
case CIL_CONS_H1: {
|
||||||
enum cil_flavor r_operand = (enum cil_flavor)r_item->data;
|
enum cil_flavor r_operand = (enum cil_flavor)(uintptr_t)r_item->data;
|
||||||
if (r_operand == CIL_CONS_L2) {
|
if (r_operand == CIL_CONS_L2) {
|
||||||
expr->attr = CEXPR_H1L2;
|
expr->attr = CEXPR_H1L2;
|
||||||
} else {
|
} else {
|
||||||
@ -2672,7 +2672,7 @@ int __cil_constrain_expr_to_sepol_expr_helper(policydb_t *pdb, const struct cil_
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum cil_flavor cil_op = (enum cil_flavor)item->data;
|
enum cil_flavor cil_op = (enum cil_flavor)(uintptr_t)item->data;
|
||||||
switch (cil_op) {
|
switch (cil_op) {
|
||||||
case CIL_NOT:
|
case CIL_NOT:
|
||||||
op->expr_type = CEXPR_NOT;
|
op->expr_type = CEXPR_NOT;
|
||||||
|
@ -285,7 +285,7 @@ static void cil_cond_expr_to_policy(FILE *out, struct cil_list *expr, int first)
|
|||||||
struct cil_list_item *i1 = expr->head;
|
struct cil_list_item *i1 = expr->head;
|
||||||
|
|
||||||
if (i1->flavor == CIL_OP) {
|
if (i1->flavor == CIL_OP) {
|
||||||
enum cil_flavor op = (enum cil_flavor)i1->data;
|
enum cil_flavor op = (enum cil_flavor)(uintptr_t)i1->data;
|
||||||
fprintf(out, "(");
|
fprintf(out, "(");
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case CIL_NOT:
|
case CIL_NOT:
|
||||||
@ -385,7 +385,7 @@ static size_t __cil_cons_leaf_operand_len(struct cil_db *db, struct cil_list_ite
|
|||||||
|
|
||||||
static size_t __cil_cons_leaf_op_len(struct cil_list_item *op)
|
static size_t __cil_cons_leaf_op_len(struct cil_list_item *op)
|
||||||
{
|
{
|
||||||
enum cil_flavor flavor = (enum cil_flavor)op->data;
|
enum cil_flavor flavor = (enum cil_flavor)(uintptr_t)op->data;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
switch (flavor) {
|
switch (flavor) {
|
||||||
@ -420,7 +420,7 @@ static size_t cil_cons_expr_len(struct cil_db *db, struct cil_list *cons_expr)
|
|||||||
|
|
||||||
i1 = cons_expr->head;
|
i1 = cons_expr->head;
|
||||||
|
|
||||||
op = (enum cil_flavor)i1->data;
|
op = (enum cil_flavor)(uintptr_t)i1->data;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case CIL_NOT:
|
case CIL_NOT:
|
||||||
len = 6; /* "(not )" */
|
len = 6; /* "(not )" */
|
||||||
@ -472,7 +472,7 @@ static char *__cil_cons_leaf_operand_to_string(struct cil_db *db, struct cil_lis
|
|||||||
size_t o_len;
|
size_t o_len;
|
||||||
|
|
||||||
if (flavor == CIL_CONS_OPERAND) {
|
if (flavor == CIL_CONS_OPERAND) {
|
||||||
enum cil_flavor o_flavor = (enum cil_flavor)operand->data;
|
enum cil_flavor o_flavor = (enum cil_flavor)(uintptr_t)operand->data;
|
||||||
switch (o_flavor) {
|
switch (o_flavor) {
|
||||||
case CIL_CONS_U1:
|
case CIL_CONS_U1:
|
||||||
o_str = "u1";
|
o_str = "u1";
|
||||||
@ -555,7 +555,7 @@ static char *__cil_cons_leaf_operand_to_string(struct cil_db *db, struct cil_lis
|
|||||||
|
|
||||||
static char *__cil_cons_leaf_op_to_string(struct cil_list_item *op, char *new)
|
static char *__cil_cons_leaf_op_to_string(struct cil_list_item *op, char *new)
|
||||||
{
|
{
|
||||||
enum cil_flavor flavor = (enum cil_flavor)op->data;
|
enum cil_flavor flavor = (enum cil_flavor)(uintptr_t)op->data;
|
||||||
const char *op_str;
|
const char *op_str;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -599,7 +599,7 @@ static char *__cil_cons_expr_to_string(struct cil_db *db, struct cil_list *cons_
|
|||||||
|
|
||||||
i1 = cons_expr->head;
|
i1 = cons_expr->head;
|
||||||
|
|
||||||
op = (enum cil_flavor)i1->data;
|
op = (enum cil_flavor)(uintptr_t)i1->data;
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case CIL_NOT:
|
case CIL_NOT:
|
||||||
*new++ = '(';
|
*new++ = '(';
|
||||||
|
@ -1301,7 +1301,7 @@ static int __cil_expr_to_bitmap(struct cil_list *expr, ebitmap_t *out, int max,
|
|||||||
flavor = expr->flavor;
|
flavor = expr->flavor;
|
||||||
|
|
||||||
if (curr->flavor == CIL_OP) {
|
if (curr->flavor == CIL_OP) {
|
||||||
enum cil_flavor op = (enum cil_flavor)curr->data;
|
enum cil_flavor op = (enum cil_flavor)(uintptr_t)curr->data;
|
||||||
|
|
||||||
if (op == CIL_ALL) {
|
if (op == CIL_ALL) {
|
||||||
ebitmap_init(&b1); /* all zeros */
|
ebitmap_init(&b1); /* all zeros */
|
||||||
|
@ -3355,7 +3355,7 @@ static int __cil_evaluate_tunable_expr(struct cil_list_item *curr)
|
|||||||
return CIL_FALSE;
|
return CIL_FALSE;
|
||||||
} else if (curr->flavor == CIL_OP) {
|
} else if (curr->flavor == CIL_OP) {
|
||||||
uint16_t v1, v2;
|
uint16_t v1, v2;
|
||||||
enum cil_flavor op_flavor = (enum cil_flavor)curr->data;
|
enum cil_flavor op_flavor = (enum cil_flavor)(uintptr_t)curr->data;
|
||||||
|
|
||||||
v1 = __cil_evaluate_tunable_expr_helper(curr->next);
|
v1 = __cil_evaluate_tunable_expr_helper(curr->next);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user