From patchwork Mon Nov 14 20:10:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042779 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00E48C4332F for ; Mon, 14 Nov 2022 20:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236152AbiKNULH (ORCPT ); Mon, 14 Nov 2022 15:11:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237515AbiKNUKv (ORCPT ); Mon, 14 Nov 2022 15:10:51 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00AE91CB29 for ; Mon, 14 Nov 2022 12:10:49 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id bj12so30980507ejb.13 for ; Mon, 14 Nov 2022 12:10:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=587qEsaR1mpGvlHQmhJbzOygiLuJmaGFsN85HEqniJw=; b=ZndzQqc3jFTdEWbKnA3n35fJ1cq7r+3doBt94C0o7hT6xFreHNIv5w5xu12JA2d6Ey uk5S7Nl5OIzDwM4lAA0GuVmy1wSd5qOg5wyULBeT4yQD8P+J3FdNm4AePWPCOuqxZG7z wPZdnH1vppQnS+F+ym2hzGN18zIDWa/JjRULSbg+0zo7tB1lWXi6k+oBFJjmu/IyvVE4 HafVd01+NMc3DoijXK128wjqq10ELFQ3pkyR6ho7Nz3j9+c5nc5WAeouasNf1LO2a7KC Rrr8EAiXqSnR5Gvo0hiqIzzlDJTaGZjM0ew1a6Lh9Ir+a8yHbTZXXG6dSCIol32d8yhn gAcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=587qEsaR1mpGvlHQmhJbzOygiLuJmaGFsN85HEqniJw=; b=mN/nDJ0J71Wott8u+G8rIs5LesGxL1qvKpAjjGI3Tp4zqGfWYNgzNK/+h4TpbVqV8G uzsXeEUlhr4BOyUfa1OSBbjYoWKVP5IztatmmqQXtiKaZRIvhVkceSkEJBUlTLhhmPmu lSG2AjbmJhFwUcmei6dudbw3L1oMndHJ8vuD+puAH5vnoQvcU1kA6DOApDDcu1QDQcon RG4VP6jYGHHYwAQ9Sn8KI1xRooin/W6QqWdo96i/U52fYgrMoUNAB9DOaSZFotptVS6O jZ9vL0gRuypLnCOG4B7xhwl3X1paO50KRQ3do9JBrFH2MT8mehwB43F5G/RvwFnRkMFN VWDg== X-Gm-Message-State: ANoB5pmFv1BwsHL+/vTW3dhxHfbPhX26eWt3IoSr0M92/q3/w+12LFSa afyG5DI6zDfw1sZLhP8XFen1Soe8efs= X-Google-Smtp-Source: AA0mqf6PIekGEMq0bkbZlcnhd+qK7ytbv7i+Bmk2r7SGq6Bd/fVf/jLlok2/TyvQVmskLileI2TRvw== X-Received: by 2002:a17:906:b45:b0:78d:b65a:aabe with SMTP id v5-20020a1709060b4500b0078db65aaabemr11694609ejg.5.1668456648306; Mon, 14 Nov 2022 12:10:48 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:47 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 1/6] libsepol: rename struct member Date: Mon, 14 Nov 2022 21:10:37 +0100 Message-Id: <20221114201042.17773-1-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Avoid using the identifier `bool` to improve support with future C standards. C23 is about to make `bool` a predefined macro (see N2654). Since the struct cond_expr_t is part of the public API it will break client applications. A quick code search of the Debian code shows only usage in checkpolicy and setools. Define a new macro signaling the renaming to simplify support of client applications for new and older versions of libsepol. Signed-off-by: Christian Göttsche --- libsepol/cil/src/cil_binary.c | 6 +++--- libsepol/include/sepol/policydb/conditional.h | 4 +++- libsepol/src/conditional.c | 14 +++++++------- libsepol/src/expand.c | 6 +++--- libsepol/src/kernel_to_cil.c | 2 +- libsepol/src/kernel_to_conf.c | 2 +- libsepol/src/link.c | 6 +++--- libsepol/src/module_to_cil.c | 2 +- libsepol/src/policydb_validate.c | 2 +- libsepol/src/write.c | 2 +- libsepol/tests/debug.c | 2 +- libsepol/tests/test-linker-cond-map.c | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-) diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c index 40615db2..ef7f4d70 100644 --- a/libsepol/cil/src/cil_binary.c +++ b/libsepol/cil/src/cil_binary.c @@ -2123,7 +2123,7 @@ static int __cil_cond_item_to_sepol_expr(policydb_t *pdb, struct cil_list_item * *head = cil_malloc(sizeof(cond_expr_t)); (*head)->next = NULL; (*head)->expr_type = COND_BOOL; - (*head)->bool = sepol_bool->s.value; + (*head)->boolean = sepol_bool->s.value; *tail = *head; } else if (item->flavor == CIL_LIST) { struct cil_list *l = item->data; @@ -2159,7 +2159,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list enum cil_flavor cil_op = (enum cil_flavor)(uintptr_t)item->data; op = cil_malloc(sizeof(*op)); - op->bool = 0; + op->boolean = 0; op->next = NULL; switch (cil_op) { @@ -2226,7 +2226,7 @@ static int __cil_cond_expr_to_sepol_expr_helper(policydb_t *pdb, struct cil_list goto exit; } op = cil_malloc(sizeof(*op)); - op->bool = 0; + op->boolean = 0; op->next = NULL; op->expr_type = COND_OR; t1->next = h2; diff --git a/libsepol/include/sepol/policydb/conditional.h b/libsepol/include/sepol/policydb/conditional.h index 49c0d766..8d4741d3 100644 --- a/libsepol/include/sepol/policydb/conditional.h +++ b/libsepol/include/sepol/policydb/conditional.h @@ -54,7 +54,9 @@ typedef struct cond_expr { #define COND_NEQ 7 /* bool != bool */ #define COND_LAST COND_NEQ uint32_t expr_type; - uint32_t bool; + /* The member `boolean` was renamed from `bool` in version 3.5 */ +#define COND_EXPR_T_RENAME_BOOL_BOOLEAN + uint32_t boolean; struct cond_expr *next; } cond_expr_t; diff --git a/libsepol/src/conditional.c b/libsepol/src/conditional.c index a620451d..24380ea0 100644 --- a/libsepol/src/conditional.c +++ b/libsepol/src/conditional.c @@ -125,7 +125,7 @@ int cond_expr_equal(cond_node_t * a, cond_node_t * b) if (cur_a->expr_type != cur_b->expr_type) return 0; if (cur_a->expr_type == COND_BOOL) { - if (cur_a->bool != cur_b->bool) + if (cur_a->boolean != cur_b->boolean) return 0; } cur_a = cur_a->next; @@ -223,7 +223,7 @@ int cond_evaluate_expr(policydb_t * p, cond_expr_t * expr) if (sp == (COND_EXPR_MAXDEPTH - 1)) return -1; sp++; - s[sp] = p->bool_val_to_struct[cur->bool - 1]->state; + s[sp] = p->bool_val_to_struct[cur->boolean - 1]->state; break; case COND_NOT: if (sp < 0) @@ -279,7 +279,7 @@ cond_expr_t *cond_copy_expr(cond_expr_t * expr) memset(new_expr, 0, sizeof(cond_expr_t)); new_expr->expr_type = cur->expr_type; - new_expr->bool = cur->bool; + new_expr->boolean = cur->boolean; if (!head) head = new_expr; @@ -388,10 +388,10 @@ int cond_normalize_expr(policydb_t * p, cond_node_t * cn) switch (e->expr_type) { case COND_BOOL: /* see if we've already seen this bool */ - if (!bool_present(e->bool, cn->bool_ids, cn->nbools)) { + if (!bool_present(e->boolean, cn->bool_ids, cn->nbools)) { /* count em all but only record up to COND_MAX_BOOLS */ if (cn->nbools < COND_MAX_BOOLS) - cn->bool_ids[cn->nbools++] = e->bool; + cn->bool_ids[cn->nbools++] = e->boolean; else cn->nbools++; } @@ -737,7 +737,7 @@ static int expr_isvalid(policydb_t * p, cond_expr_t * expr) return 0; } - if (expr->bool > p->p_bools.nprim) { + if (expr->boolean > p->p_bools.nprim) { WARN(NULL, "security: conditional expressions uses unknown bool."); return 0; } @@ -775,7 +775,7 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp) memset(expr, 0, sizeof(cond_expr_t)); expr->expr_type = le32_to_cpu(buf[0]); - expr->bool = le32_to_cpu(buf[1]); + expr->boolean = le32_to_cpu(buf[1]); if (!expr_isvalid(p, expr)) { free(expr); diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c index 8d19850e..1337c32f 100644 --- a/libsepol/src/expand.c +++ b/libsepol/src/expand.c @@ -2025,8 +2025,8 @@ static int cond_node_map_bools(expand_state_t * state, cond_node_t * cn) cur = cn->expr; while (cur) { - if (cur->bool) - cur->bool = state->boolmap[cur->bool - 1]; + if (cur->boolean) + cur->boolean = state->boolmap[cur->boolean - 1]; cur = cur->next; } @@ -2899,7 +2899,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol) cur_expr = cur_expr->next) { if (cur_expr->expr_type != COND_BOOL) continue; - booldatum = pol->bool_val_to_struct[cur_expr->bool - 1]; + booldatum = pol->bool_val_to_struct[cur_expr->boolean - 1]; if (booldatum->flags & COND_BOOL_FLAGS_TUNABLE) tmp[tunables++] = booldatum; else diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c index ad4121d5..e9cd89c2 100644 --- a/libsepol/src/kernel_to_cil.c +++ b/libsepol/src/kernel_to_cil.c @@ -43,7 +43,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) for (curr = expr; curr != NULL; curr = curr->next) { if (curr->expr_type == COND_BOOL) { - char *val1 = pdb->p_bool_val_to_name[curr->bool - 1]; + char *val1 = pdb->p_bool_val_to_name[curr->boolean - 1]; new_val = create_str("%s", 1, val1); } else { const char *op; diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c index 63dffd9b..59083479 100644 --- a/libsepol/src/kernel_to_conf.c +++ b/libsepol/src/kernel_to_conf.c @@ -42,7 +42,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) for (curr = expr; curr != NULL; curr = curr->next) { if (curr->expr_type == COND_BOOL) { - char *val1 = pdb->p_bool_val_to_name[curr->bool - 1]; + char *val1 = pdb->p_bool_val_to_name[curr->boolean - 1]; new_val = create_str("%s", 1, val1); } else { const char *op; diff --git a/libsepol/src/link.c b/libsepol/src/link.c index cbe4cea4..3b7742bc 100644 --- a/libsepol/src/link.c +++ b/libsepol/src/link.c @@ -1524,9 +1524,9 @@ static int copy_cond_list(cond_node_t * list, cond_node_t ** dst, /* expression nodes don't have a bool value of 0 - don't map them */ if (cur_expr->expr_type != COND_BOOL) continue; - assert(module->map[SYM_BOOLS][cur_expr->bool - 1] != 0); - cur_expr->bool = - module->map[SYM_BOOLS][cur_expr->bool - 1]; + assert(module->map[SYM_BOOLS][cur_expr->boolean - 1] != 0); + cur_expr->boolean = + module->map[SYM_BOOLS][cur_expr->boolean - 1]; } new_node->nbools = cur->nbools; /* FIXME should COND_MAX_BOOLS be used here? */ diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index b900290a..4e15f8e4 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -1272,7 +1272,7 @@ static int cond_expr_to_cil(int indent, struct policydb *pdb, struct cond_expr * for (curr = cond_expr; curr != NULL; curr = curr->next) { if (curr->expr_type == COND_BOOL) { - val1 = pdb->p_bool_val_to_name[curr->bool - 1]; + val1 = pdb->p_bool_val_to_name[curr->boolean - 1]; // length of boolean + 2 parens + null terminator len = strlen(val1) + 2 + 1; new_val = malloc(len); diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c index 521ea4ff..d1bc7f03 100644 --- a/libsepol/src/policydb_validate.c +++ b/libsepol/src/policydb_validate.c @@ -957,7 +957,7 @@ static int validate_cond_expr(sepol_handle_t *handle, const struct cond_expr *ex for (; expr; expr = expr->next) { switch(expr->expr_type) { case COND_BOOL: - if (validate_value(expr->bool, boolean)) + if (validate_value(expr->boolean, boolean)) goto bad; if (depth == (COND_EXPR_MAXDEPTH - 1)) goto bad; diff --git a/libsepol/src/write.c b/libsepol/src/write.c index a9fdf93a..024fe628 100644 --- a/libsepol/src/write.c +++ b/libsepol/src/write.c @@ -834,7 +834,7 @@ static int cond_write_node(policydb_t * p, for (cur_expr = node->expr; cur_expr != NULL; cur_expr = cur_expr->next) { items = 0; buf[items++] = cpu_to_le32(cur_expr->expr_type); - buf[items++] = cpu_to_le32(cur_expr->bool); + buf[items++] = cpu_to_le32(cur_expr->boolean); items2 = put_entry(buf, sizeof(uint32_t), items, fp); if (items2 != items) return POLICYDB_ERROR; diff --git a/libsepol/tests/debug.c b/libsepol/tests/debug.c index 90aa6e0a..8494dd25 100644 --- a/libsepol/tests/debug.c +++ b/libsepol/tests/debug.c @@ -41,7 +41,7 @@ void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp) for (cur = exp; cur != NULL; cur = cur->next) { switch (cur->expr_type) { case COND_BOOL: - fprintf(fp, "%s ", p->p_bool_val_to_name[cur->bool - 1]); + fprintf(fp, "%s ", p->p_bool_val_to_name[cur->boolean - 1]); break; case COND_NOT: fprintf(fp, "! "); diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c index 694a7346..6ea0e4c2 100644 --- a/libsepol/tests/test-linker-cond-map.c +++ b/libsepol/tests/test-linker-cond-map.c @@ -70,7 +70,7 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_ CU_ASSERT(expr->expr_type == bools[i].expr_type); if (bools[i].bool) { - CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->bool - 1], bools[i].bool) == 0); + CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0); } expr = expr->next; } From patchwork Mon Nov 14 20:10:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042778 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51975C433FE for ; Mon, 14 Nov 2022 20:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235917AbiKNULG (ORCPT ); Mon, 14 Nov 2022 15:11:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237518AbiKNUKv (ORCPT ); Mon, 14 Nov 2022 15:10:51 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711AF1D649 for ; Mon, 14 Nov 2022 12:10:50 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id f7so18941625edc.6 for ; Mon, 14 Nov 2022 12:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GbEaiuHOg89TOj36PvnjmKIN/U1WC+yt3QoCnJWruPI=; b=Xh+lzuS6XN7FkchfO9J2tZ51sctVqNK+gFJ6ZvEf0yAuLEJobnBHnedBeub+E1ZEdh Tg0zEH5YFI+PN9E1SM6huBzVG2NhdHwQKPWOehc45SnQejOd38uzG9YQPoe2Mg2TsZy4 U008y2xqAmTP8+bIkvTVIvjfRlJ3kf97MzKwGge9+sjp0Qolwp6WJyNvnaQBN1LaE/nB VOWP3KrERGLI0sheu3wo4nWiEvhACkX6eN+5RYp4KciUUpSRaI9qVLCbDOuEoErJK2ky kWxDYYKwoepVQ3dYLZQoIQAeVYsd4RDWISdBGmxrNDO3CJYKitRsprbl76Y0NjaWhM3a bojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GbEaiuHOg89TOj36PvnjmKIN/U1WC+yt3QoCnJWruPI=; b=ejv15plGqRKsAZhXJYXwgBaZ59R9bTVLeM/2WigJnpbbMRzWzybkd0wdRZAyZ5YD5e lZC/MVIIr9W9lkQVPVq0KcZxBrcuGhHI0arSwf0g7FIOdBwO82eN2sVoKk2Y92dpV4Bh xKcVA1PSHtGLfY9M/gwQ2milqDSCKZHYfyigw+vDV+MlUSTJ5IGVWcCkyFzzAQQ/ZP67 6b9wv4192Dt13YHEAR3lfQPZ4bBXD2rn9FrYR21NNJ9mMni2rghgfgLSibuoh4yvP2H9 OHyjK3NIJipSTI/fqKA1T2/braPHZ6mNKby6JPI71Zu9NOZRaO8YIIgffcBWicP5UiPj KB5Q== X-Gm-Message-State: ANoB5pmMuatyzVlzX81Xhz6eOszdS8CbLfaWwBIWoaFXD/boW9ulygc2 H/e2LX8cnV9JQBK6/HG6vYNV/rtXsF8= X-Google-Smtp-Source: AA0mqf63/YHyUVq+kLwZEtrdawVjik5OUpcsycXYGTaAhY6iuup8URvPQdaj44XHbAdhz8687j8Mgg== X-Received: by 2002:a05:6402:43ce:b0:461:5d0a:78e1 with SMTP id p14-20020a05640243ce00b004615d0a78e1mr12504119edc.425.1668456648939; Mon, 14 Nov 2022 12:10:48 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:48 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 2/6] checkpolicy: update cond_expr_t struct member name Date: Mon, 14 Nov 2022 21:10:38 +0100 Message-Id: <20221114201042.17773-2-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114201042.17773-1-cgzones@googlemail.com> References: <20221114201042.17773-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Signed-off-by: Christian Göttsche --- checkpolicy/checkpolicy.c | 2 +- checkpolicy/policy_define.c | 2 +- checkpolicy/test/dismod.c | 2 +- checkpolicy/test/dispol.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index 926ce72c..a1406e7b 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -313,7 +313,7 @@ static void display_expr(const cond_expr_t * exp) switch (cur->expr_type) { case COND_BOOL: printf("%s ", - policydbp->p_bool_val_to_name[cur->bool - 1]); + policydbp->p_bool_val_to_name[cur->boolean - 1]); break; case COND_NOT: printf("! "); diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c index 54bb304b..4ff730be 100644 --- a/checkpolicy/policy_define.c +++ b/checkpolicy/policy_define.c @@ -4126,7 +4126,7 @@ cond_expr_t *define_cond_expr(uint32_t expr_type, void *arg1, void *arg2) free(id); return NULL; } - expr->bool = bool_var->s.value; + expr->boolean = bool_var->s.value; free(id); return expr; default: diff --git a/checkpolicy/test/dismod.c b/checkpolicy/test/dismod.c index ec2a3e9a..51b68433 100644 --- a/checkpolicy/test/dismod.c +++ b/checkpolicy/test/dismod.c @@ -400,7 +400,7 @@ static void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp) switch (cur->expr_type) { case COND_BOOL: fprintf(fp, "%s ", - p->p_bool_val_to_name[cur->bool - 1]); + p->p_bool_val_to_name[cur->boolean - 1]); break; case COND_NOT: fprintf(fp, "! "); diff --git a/checkpolicy/test/dispol.c b/checkpolicy/test/dispol.c index 8ddefb04..c396bef7 100644 --- a/checkpolicy/test/dispol.c +++ b/checkpolicy/test/dispol.c @@ -197,7 +197,7 @@ static void display_expr(policydb_t * p, cond_expr_t * exp, FILE * fp) switch (cur->expr_type) { case COND_BOOL: fprintf(fp, "%s ", - p->p_bool_val_to_name[cur->bool - 1]); + p->p_bool_val_to_name[cur->boolean - 1]); break; case COND_NOT: fprintf(fp, "! "); From patchwork Mon Nov 14 20:10:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042781 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E79EC4321E for ; Mon, 14 Nov 2022 20:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236257AbiKNULI (ORCPT ); Mon, 14 Nov 2022 15:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237527AbiKNUKx (ORCPT ); Mon, 14 Nov 2022 15:10:53 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17F7A1B1DD for ; Mon, 14 Nov 2022 12:10:51 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id f5so31088306ejc.5 for ; Mon, 14 Nov 2022 12:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WXAfckhMZX5FPBpzJH3trrjSpdwktmQzBeAcL+wEFYc=; b=WX+vQPGjSyj4gxP/mZ4cqSV1umEyUJOKqGN0OY5l1WqvdRjsFg4oieFD/DCDWSGfsK RbQzHbzMlzdv0BMslWJe9oJx+ex96QCYAnOvFrEusSBgy96zBaWMJt7n6FZQPWozpWQF SVhT8JtaGteznO39QmqucBOuyMXy+YAEwswWgtyPaPp92EdIH+mY6divTNS7Y25+TQVa Cg0GxdZb2mj4rUpG3v8//FVyRFddbaP9M+8SiaVSPpvuz980ieHWJP+Sgss5sLKPOILD ibJ53xmIpyV7BlxQZ4RlE9RFuIj3U14hGLncmGzKsnPiykMEg4pYW62tIJ259rqL1k+7 g2LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WXAfckhMZX5FPBpzJH3trrjSpdwktmQzBeAcL+wEFYc=; b=sUOsZnze6Ll/B3pw19MbF9JUyBJ3zAqSGsYgasdXsdpM8tsp5xaC9tqAodI78aFzPX fRkYLWK6Uaggt+1MAt/LxxQPx0h/1tr7s1VAp9Vb/XPds+50uLp2pWZcCjj3eEPx78F+ /D5G+AaJ/B4A4fcjBdMzerPIED9WHk7C3Oi+q38kjP9+YLhyVJ4cKJ73dSgK0AilG3Sf SyS7DyeblkIt8cx8guqaaRR+XeKudAe3TNF+SHW2xF7Py1d4w4MKeTX0M/8yYPkeM02A LA4qSofNq7kZRM0Y14yIREHg7mX3IkkjprWpz3zIq3JXM1z84kTtnuQksnetwdSJwHBT M/fQ== X-Gm-Message-State: ANoB5pnAWwChkQ3kLoHHf9ZfYyqHNYkG78rQT1xXrGhN06utUn1t6RsX rlHrYuBaOC2+ZLteAIoBexysiAJqYcE= X-Google-Smtp-Source: AA0mqf5TbtBxeEVUK/ze51sDCNJZhXbcXSGpWDOMlJwfrIESldpC/pROGiy9eGeTfGDOYtKyjON5mg== X-Received: by 2002:a17:906:6057:b0:7a0:b505:cae5 with SMTP id p23-20020a170906605700b007a0b505cae5mr11524657ejj.648.1668456649535; Mon, 14 Nov 2022 12:10:49 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:49 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 3/6] libsepol/tests: rename bool indentifiers Date: Mon, 14 Nov 2022 21:10:39 +0100 Message-Id: <20221114201042.17773-3-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114201042.17773-1-cgzones@googlemail.com> References: <20221114201042.17773-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Avoid using the identifier `bool` to improve support with future C standards. C23 is about to make `bool` a predefined macro (see N2654). Signed-off-by: Christian Göttsche --- libsepol/tests/test-linker-cond-map.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libsepol/tests/test-linker-cond-map.c b/libsepol/tests/test-linker-cond-map.c index 6ea0e4c2..14206666 100644 --- a/libsepol/tests/test-linker-cond-map.c +++ b/libsepol/tests/test-linker-cond-map.c @@ -51,7 +51,7 @@ */ typedef struct test_cond_expr { - const char *bool; + const char *boolean; uint32_t expr_type; } test_cond_expr_t; @@ -69,18 +69,18 @@ static void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_ CU_ASSERT_FATAL(expr != NULL); CU_ASSERT(expr->expr_type == bools[i].expr_type); - if (bools[i].bool) { - CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].bool) == 0); + if (bools[i].boolean) { + CU_ASSERT(strcmp(p->sym_val_to_name[SYM_BOOLS][expr->boolean - 1], bools[i].boolean) == 0); } expr = expr->next; } } -static void test_bool_state(policydb_t * p, const char *bool, int state) +static void test_bool_state(policydb_t * p, const char *boolean, int state) { cond_bool_datum_t *b; - b = hashtab_search(p->p_bools.table, bool); + b = hashtab_search(p->p_bools.table, boolean); CU_ASSERT_FATAL(b != NULL); CU_ASSERT(b->state == state); } @@ -100,7 +100,7 @@ void base_cond_tests(policydb_t * base) test_sym_presence(base, "g_b_bool_1", SYM_BOOLS, SCOPE_DECL, decls, 1); test_bool_state(base, "g_b_bool_1", 0); /* conditional expression mapped correctly */ - bools[0].bool = "g_b_bool_1"; + bools[0].boolean = "g_b_bool_1"; bools[0].expr_type = COND_BOOL; test_cond_expr_mapping(base, d, bools, 1); @@ -110,7 +110,7 @@ void base_cond_tests(policydb_t * base) test_sym_presence(base, "o1_b_bool_1", SYM_BOOLS, SCOPE_DECL, decls, 1); test_bool_state(base, "o1_b_bool_1", 1); /* conditional expression mapped correctly */ - bools[0].bool = "o1_b_bool_1"; + bools[0].boolean = "o1_b_bool_1"; bools[0].expr_type = COND_BOOL; test_cond_expr_mapping(base, d, bools, 1); @@ -128,7 +128,7 @@ void module_cond_tests(policydb_t * base) test_sym_presence(base, "g_m1_bool_1", SYM_BOOLS, SCOPE_DECL, decls, 1); test_bool_state(base, "g_m1_bool_1", 1); /* conditional expression mapped correctly */ - bools[0].bool = "g_m1_bool_1"; + bools[0].boolean = "g_m1_bool_1"; bools[0].expr_type = COND_BOOL; test_cond_expr_mapping(base, d, bools, 1); @@ -138,7 +138,7 @@ void module_cond_tests(policydb_t * base) test_sym_presence(base, "o1_m1_bool_1", SYM_BOOLS, SCOPE_DECL, decls, 1); test_bool_state(base, "o1_m1_bool_1", 0); /* conditional expression mapped correctly */ - bools[0].bool = "o1_m1_bool_1"; + bools[0].boolean = "o1_m1_bool_1"; bools[0].expr_type = COND_BOOL; test_cond_expr_mapping(base, d, bools, 1); @@ -150,11 +150,11 @@ void module_cond_tests(policydb_t * base) test_bool_state(base, "g_m2_bool_1", 1); test_bool_state(base, "g_m2_bool_2", 0); /* conditional expression mapped correctly */ - bools[0].bool = "g_m2_bool_1"; + bools[0].boolean = "g_m2_bool_1"; bools[0].expr_type = COND_BOOL; - bools[1].bool = "g_m2_bool_2"; + bools[1].boolean = "g_m2_bool_2"; bools[1].expr_type = COND_BOOL; - bools[2].bool = NULL; + bools[2].boolean = NULL; bools[2].expr_type = COND_AND; test_cond_expr_mapping(base, d, bools, 3); } From patchwork Mon Nov 14 20:10:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042782 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD9BDC433FE for ; Mon, 14 Nov 2022 20:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236454AbiKNULJ (ORCPT ); Mon, 14 Nov 2022 15:11:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237528AbiKNUKx (ORCPT ); Mon, 14 Nov 2022 15:10:53 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B02161A809 for ; Mon, 14 Nov 2022 12:10:51 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id v17so18924763edc.8 for ; Mon, 14 Nov 2022 12:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qh0HU+tAShCKgs/+4QsOgiWqbnxR91OhcOH1V/c5j4Y=; b=XLgSIEty0IBGpJO0dDD1QT/3+PeGupRjK8b0P97xVm1ZwCc1C0pwvphx6tEfIR7Ynt 8XOFEhPNsn+eYZSp/bSDapWnz6HMOFCxB8EX34y8yM+gnZhKRM33+1KOrno4DQ+Z4iP6 4QmUby02jXJtg/D2cx4NZCPA2JvsrKXWL7or1rIyYnTY7Gpp4xJBVIPKu7RlpuWUisQJ nMIyhtrEsvdQqgoY/Q9r1xOMARNdokZAZABWfMd0awJwohZTv0uRngMgK+Ilm7My6lfl HZAR94CZn7CFCPAW2eVF3pUDGiqQ2vZWs2re0cNQPBoa9gBAsS1FFclrK1krlYhnjrq5 mYrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qh0HU+tAShCKgs/+4QsOgiWqbnxR91OhcOH1V/c5j4Y=; b=Zmmli5pC/Glwbck7kpZ8WZsobuVxx7kXw80S4tz+DUgcQvVnw19S9/PIqM7cWHDAuE hs+hGB8KHRcA1p9YAtnSMTwR58MeOANVmYGWou4KsvxKVyeAgIuHlA76QzkYGCD7HDrW nYZ7MLhibYEUk+Jw1GU3EHW6h1ybHV8TSfOytI/AKPJYvSOkf//UdtA2biXGEmMsu2Fw ZwTbOQYI0u1zWqEv03GFi6wSmB+v1SbpB2wtoUOpGZWHrTz0eNH+kI3Z73yERvSXsST0 oZwQPvaN+luNbjX55RqLZr7HfYgNED5ZMxDVW/rASL5YfTBMd7ln6/VLYtne3MEnxgXw 6RkA== X-Gm-Message-State: ANoB5pmtJmu0t2tXwsDklQZzss47Mr+NThKaQiKyLVquiVybKtb5BEzg LxsukZhTIpteG2JkpDF9F0re+GsJcCA= X-Google-Smtp-Source: AA0mqf7H6Z0rIzf6X6Yf7Nbnq4+u7B5wCVv8/vqhJI7ka8g4t4uOS674r6TpsqYPTH9qTzyboFD2DQ== X-Received: by 2002:a05:6402:2b94:b0:467:9976:2e37 with SMTP id fj20-20020a0564022b9400b0046799762e37mr8625058edb.267.1668456650250; Mon, 14 Nov 2022 12:10:50 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:49 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 4/6] checkpolicy: rename bool identifiers Date: Mon, 14 Nov 2022 21:10:40 +0100 Message-Id: <20221114201042.17773-4-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114201042.17773-1-cgzones@googlemail.com> References: <20221114201042.17773-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Avoid using the identifier `bool` to improve support with future C standards. C23 is about to make `bool` a predefined macro (see N2654). Signed-off-by: Christian Göttsche --- checkpolicy/checkpolicy.c | 8 ++++---- checkpolicy/test/dismod.c | 8 ++++---- checkpolicy/test/dispol.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c index a1406e7b..4c1b9b89 100644 --- a/checkpolicy/checkpolicy.c +++ b/checkpolicy/checkpolicy.c @@ -354,14 +354,14 @@ static int display_cond_expressions(void) static int change_bool(const char *name, int state) { - cond_bool_datum_t *bool; + cond_bool_datum_t *boolean; - bool = hashtab_search(policydbp->p_bools.table, name); - if (bool == NULL) { + boolean = hashtab_search(policydbp->p_bools.table, name); + if (boolean == NULL) { printf("Could not find bool %s\n", name); return -1; } - bool->state = state; + boolean->state = state; evaluate_conds(policydbp); return 0; } diff --git a/checkpolicy/test/dismod.c b/checkpolicy/test/dismod.c index 51b68433..6328d326 100644 --- a/checkpolicy/test/dismod.c +++ b/checkpolicy/test/dismod.c @@ -598,14 +598,14 @@ int display_cond_expressions(policydb_t * p, FILE * fp) int change_bool(char *name, int state, policydb_t * p, FILE * fp) { - cond_bool_datum_t *bool; + cond_bool_datum_t *boolean; - bool = hashtab_search(p->p_bools.table, name); - if (bool == NULL) { + boolean = hashtab_search(p->p_bools.table, name); + if (boolean == NULL) { fprintf(fp, "Could not find bool %s\n", name); return -1; } - bool->state = state; + boolean->state = state; evaluate_conds(p); return 0; } diff --git a/checkpolicy/test/dispol.c b/checkpolicy/test/dispol.c index c396bef7..1d619e2c 100644 --- a/checkpolicy/test/dispol.c +++ b/checkpolicy/test/dispol.c @@ -262,14 +262,14 @@ static int display_handle_unknown(policydb_t * p, FILE * out_fp) static int change_bool(char *name, int state, policydb_t * p, FILE * fp) { - cond_bool_datum_t *bool; + cond_bool_datum_t *boolean; - bool = hashtab_search(p->p_bools.table, name); - if (bool == NULL) { + boolean = hashtab_search(p->p_bools.table, name); + if (boolean == NULL) { fprintf(fp, "Could not find bool %s\n", name); return -1; } - bool->state = state; + boolean->state = state; evaluate_conds(p); return 0; } From patchwork Mon Nov 14 20:10:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042783 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 724F3C43217 for ; Mon, 14 Nov 2022 20:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236195AbiKNULH (ORCPT ); Mon, 14 Nov 2022 15:11:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237534AbiKNUKx (ORCPT ); Mon, 14 Nov 2022 15:10:53 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 675AD1A380 for ; Mon, 14 Nov 2022 12:10:52 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id n12so31016489eja.11 for ; Mon, 14 Nov 2022 12:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=J0C74CZiuMElJreyNyS91XeoLenbmQLJo3IkjwDNBW8=; b=WaRHhgoKsbVkQiHlAbIUhSK/c+Zt9Tp0T7yo5TPfUHSGopWP0GMlPovglqZibCB9N6 iuGdudmxe4MEeD50SoUckqzDNpHkEXUg7cny+/RJ8XWK3VLAd0s2BlKu1BOHrRWtRfIo zV0ZYnaS2iZmZb+H1V7tvwJT6a7A4zKmH/34zk/lH/p0p+Fsv80pHDW7Wk2gLN6kEVgd OHnWGj1SaqZ7nGeTqM2t4P5qpf1dx9lnFes1puuFAUUuZrRq1tJoCbHlLRegXfBkQjKR hV+Mv+7qxXOQFggvSO2MLOQbOLit0O1Xky5GaUrcuV33S0RRxrGcHIxGb5IUAaaOqQ4s eJPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J0C74CZiuMElJreyNyS91XeoLenbmQLJo3IkjwDNBW8=; b=6MOSNEy2jfO2XeLED3Cs3l+IUql1wzz1RXA5Kui9kKFDvtekIXt/H6EOpN6DdKmP3P ufOXuPrPwtQ60aCt7tBX+1C0b4+YORZ4w2vB97o28a8jHq2AUHAul1SNYo9qI6nTR08m 0JTfx9ZQroZ+FLEOMOQ4kIu66Mf4DmxVjf89HxODhrGmq8VNnjDsxBA/ba2LP/QhlLGm Ix/DEMCTKKmqaTH+1NEfTJRqNPGoNwe+emorHccoPiOo6/4CXuTzvNEVLblJTWJrLNo6 q0SUJsvCOOU7az+7DQRKbXJKGexqOEWCwUynrEI1nJ/vqwlxH/Q2WcRn7ntDGwCb0ow6 bCUw== X-Gm-Message-State: ANoB5pk20L1VI84VJnojXmga9XkvxFV+NuyOIh2kk8taRFbEvFAzlDKy i056AXd9yLw5HJroqe1qkTgb13R/2K8= X-Google-Smtp-Source: AA0mqf4Vx+D7reuKLvJH/jd1vnpysmGDZsMMa4LiXgw7uf14EP8Ky57oyrgIhnSCHMV3huCJ1d2bJQ== X-Received: by 2002:a17:907:8c06:b0:78d:f3f4:b1a0 with SMTP id ta6-20020a1709078c0600b0078df3f4b1a0mr11428948ejc.489.1668456650966; Mon, 14 Nov 2022 12:10:50 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:50 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 5/6] libsepol: rename bool identifiers Date: Mon, 14 Nov 2022 21:10:41 +0100 Message-Id: <20221114201042.17773-5-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114201042.17773-1-cgzones@googlemail.com> References: <20221114201042.17773-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Avoid using the identifier `bool` to improve support with future C standards. C23 is about to make `bool` a predefined macro (see N2654). Signed-off-by: Christian Göttsche --- libsepol/cil/src/cil_binary.c | 8 ++++---- libsepol/cil/src/cil_policy.c | 12 ++++++------ libsepol/src/expand.c | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/libsepol/cil/src/cil_binary.c b/libsepol/cil/src/cil_binary.c index ef7f4d70..c4ee2380 100644 --- a/libsepol/cil/src/cil_binary.c +++ b/libsepol/cil/src/cil_binary.c @@ -4170,13 +4170,13 @@ static int __cil_user_val_array_insert(hashtab_key_t key, hashtab_datum_t datum, static int __cil_bool_val_array_insert(hashtab_key_t key, hashtab_datum_t datum, void *data) { policydb_t *pdb = data; - cond_bool_datum_t *bool = (cond_bool_datum_t *)datum; + cond_bool_datum_t *boolean = (cond_bool_datum_t *)datum; - if (bool->s.value < 1 || bool->s.value > pdb->p_bools.nprim) { + if (boolean->s.value < 1 || boolean->s.value > pdb->p_bools.nprim) { return -EINVAL; } - pdb->p_bool_val_to_name[bool->s.value - 1] = (char *)key; - pdb->bool_val_to_struct[bool->s.value - 1] = bool; + pdb->p_bool_val_to_name[boolean->s.value - 1] = (char *)key; + pdb->bool_val_to_struct[boolean->s.value - 1] = boolean; return 0; } diff --git a/libsepol/cil/src/cil_policy.c b/libsepol/cil/src/cil_policy.c index 7c543c47..feb97868 100644 --- a/libsepol/cil/src/cil_policy.c +++ b/libsepol/cil/src/cil_policy.c @@ -1008,13 +1008,13 @@ static void cil_validatetrans_to_policy(FILE *out, struct cil_db *db, struct cil static void cil_bools_to_policy(FILE *out, struct cil_list *bools) { struct cil_list_item *i1; - struct cil_bool *bool; + struct cil_bool *boolean; const char *value; cil_list_for_each(i1, bools) { - bool = i1->data; - value = bool->value ? "true" : "false"; - fprintf(out, "bool %s %s;\n", bool->datum.fqn, value); + boolean = i1->data; + value = boolean->value ? "true" : "false"; + fprintf(out, "bool %s %s;\n", boolean->datum.fqn, value); } } @@ -1437,12 +1437,12 @@ static int __cil_te_rules_to_policy_helper(struct cil_tree_node *node, uint32_t *finished = CIL_TREE_SKIP_HEAD; break; case CIL_BOOLEANIF: { - struct cil_booleanif *bool = node->data; + struct cil_booleanif *boolean = node->data; struct cil_tree_node *n; struct cil_condblock *cb; fprintf(args->out, "if "); - cil_cond_expr_to_policy(args->out, bool->datum_expr, CIL_TRUE); + cil_cond_expr_to_policy(args->out, boolean->datum_expr, CIL_TRUE); fprintf(args->out," {\n"); n = node->cl_head; cb = n != NULL ? n->data : NULL; diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c index 1337c32f..c08d3a35 100644 --- a/libsepol/src/expand.c +++ b/libsepol/src/expand.c @@ -1106,11 +1106,11 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, { int ret; expand_state_t *state; - cond_bool_datum_t *bool, *new_bool; + cond_bool_datum_t *boolean, *new_bool; char *id, *new_id; id = key; - bool = (cond_bool_datum_t *) datum; + boolean = (cond_bool_datum_t *) datum; state = (expand_state_t *) data; if (!is_id_enabled(id, state->base, SYM_BOOLS)) { @@ -1118,7 +1118,7 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, return 0; } - if (bool->flags & COND_BOOL_FLAGS_TUNABLE) { + if (boolean->flags & COND_BOOL_FLAGS_TUNABLE) { /* Skip tunables */ return 0; } @@ -1152,10 +1152,10 @@ static int bool_copy_callback(hashtab_key_t key, hashtab_datum_t datum, return -1; } - state->boolmap[bool->s.value - 1] = new_bool->s.value; + state->boolmap[boolean->s.value - 1] = new_bool->s.value; - new_bool->state = bool->state; - new_bool->flags = bool->flags; + new_bool->state = boolean->state; + new_bool->flags = boolean->flags; return 0; } From patchwork Mon Nov 14 20:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_G=C3=B6ttsche?= X-Patchwork-Id: 13042780 X-Patchwork-Delegate: plautrba@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C62C43219 for ; Mon, 14 Nov 2022 20:11:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236238AbiKNULI (ORCPT ); Mon, 14 Nov 2022 15:11:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237536AbiKNUKy (ORCPT ); Mon, 14 Nov 2022 15:10:54 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 197FB1B1EA for ; Mon, 14 Nov 2022 12:10:53 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id n20so10479199ejh.0 for ; Mon, 14 Nov 2022 12:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=McTStY4ftkbj5eldoW2InOIwOrA58RR2T/ju5cLV/Yo=; b=RkbL+BVIpNeOm5ewOvR6U0HZ8J/KJJFrp5mkgEluPh0LgjoTv/uFv3lQQw2tyU4jpK ojO8gzn2TQntS1lN6P2o5Bo5bCfY1kb7H59dK/OBKqul5O6+shd1Eirdmt7Mg9jNtU/V w/dvS1H3m/aRSqGEgJqU1APwyEHqtqCdKDKLGvbt4QwvLlark8Muyyha1TAESSP0EuRM ihSzW/s5n0o/c3nyFmjQyTkR8BPY53bmf3yrBcRQzBt6LdNpa/ztb1iRC1FZAY8ajV+p 4+pqOJmlyLekiEfWCyaQoUXGYOuUymw7Kqt3v30pPODftPlDRFfyNIYG7PEnyzJQqC2A ggCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=McTStY4ftkbj5eldoW2InOIwOrA58RR2T/ju5cLV/Yo=; b=y5HX7e9RRYdqS6jmhTxgfuUS66aOsNdVDNZsEY5Tp8eaqZwR6iUeBjoDbeyLmiDwRD BL27RqCI3DeMdTHLBr3FLdlCpgbMhiqPPnbgg2XbJ2C5SRVGYq5+XLteX5dlBGpZPrG7 UIvbUrgfVKVFLX1krOGdOa6A9KzXxKuC+AouiIxOVlWsSYFLk7n6JlYkyfBxZ8P40Z1z jbiJpqMukHns2rFj7EI77aghbvxwwuh2A9gQhyz06Kgy23JzZGhnsIE+t13WZ8IFktYm MFsmNB7m/+oS6hx2iuV7Kvni4EALne8M5ITPOyZAGuZS2Mhw1lN6IJvNDAkJWH+4UQ2O Dsgw== X-Gm-Message-State: ANoB5pmb1blFvfTsejcQjgewtj+ft640BwPZcBiU4La5LnjwlZzNo3+W xcGPQ31shaFeMXuBypQhS/xPz87b2uI= X-Google-Smtp-Source: AA0mqf5VbV3i2FumGVR9WJ7RFINvXP1ycdpF3kflOOlfMfuKWJN/P8Frws4EncbRQXMP+TIxW6PL5A== X-Received: by 2002:a17:906:d8d:b0:7af:883:ec72 with SMTP id m13-20020a1709060d8d00b007af0883ec72mr3272646eji.727.1668456651574; Mon, 14 Nov 2022 12:10:51 -0800 (PST) Received: from debianHome.localdomain (dynamic-077-003-090-138.77.3.pool.telefonica.de. [77.3.90.138]) by smtp.gmail.com with ESMTPSA id cb13-20020a170906a44d00b007abafe43c3bsm4558377ejb.86.2022.11.14.12.10.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 12:10:51 -0800 (PST) From: =?utf-8?q?Christian_G=C3=B6ttsche?= To: selinux@vger.kernel.org Subject: [RFC PATCH 6/6] libsemanage/tests: rename bool identifiers Date: Mon, 14 Nov 2022 21:10:42 +0100 Message-Id: <20221114201042.17773-6-cgzones@googlemail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114201042.17773-1-cgzones@googlemail.com> References: <20221114201042.17773-1-cgzones@googlemail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: selinux@vger.kernel.org Avoid using the identifier `bool` to improve support with future C standards. C23 is about to make `bool` a predefined macro (see N2654). Signed-off-by: Christian Göttsche --- libsemanage/tests/libsemanage-tests.c | 2 +- libsemanage/tests/test_bool.c | 6 +++--- libsemanage/tests/test_bool.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libsemanage/tests/libsemanage-tests.c b/libsemanage/tests/libsemanage-tests.c index ee176703..1d41a03b 100644 --- a/libsemanage/tests/libsemanage-tests.c +++ b/libsemanage/tests/libsemanage-tests.c @@ -73,7 +73,7 @@ static bool do_tests(int interactive, int verbose) DECLARE_SUITE(semanage_store); DECLARE_SUITE(semanage_utilities); DECLARE_SUITE(handle); - DECLARE_SUITE(bool); + DECLARE_SUITE(boolean); DECLARE_SUITE(fcontext); DECLARE_SUITE(iface); DECLARE_SUITE(ibendport); diff --git a/libsemanage/tests/test_bool.c b/libsemanage/tests/test_bool.c index 672544bb..9356a1ae 100644 --- a/libsemanage/tests/test_bool.c +++ b/libsemanage/tests/test_bool.c @@ -57,7 +57,7 @@ static void test_bool_list_local(void); extern semanage_handle_t *sh; -int bool_test_init(void) +int boolean_test_init(void) { if (create_test_store() < 0) { fprintf(stderr, "Could not create test store\n"); @@ -72,7 +72,7 @@ int bool_test_init(void) return 0; } -int bool_test_cleanup(void) +int boolean_test_cleanup(void) { if (destroy_test_store() < 0) { fprintf(stderr, "Could not destroy test store\n"); @@ -82,7 +82,7 @@ int bool_test_cleanup(void) return 0; } -int bool_add_tests(CU_pSuite suite) +int boolean_add_tests(CU_pSuite suite) { CU_add_test(suite, "bool_key_create", test_bool_key_create); CU_add_test(suite, "bool_key_extract", test_bool_key_extract); diff --git a/libsemanage/tests/test_bool.h b/libsemanage/tests/test_bool.h index b5b5a603..985c1f06 100644 --- a/libsemanage/tests/test_bool.h +++ b/libsemanage/tests/test_bool.h @@ -24,8 +24,8 @@ #include #include "semanage/semanage.h" -int bool_test_init(void); -int bool_test_cleanup(void); -int bool_add_tests(CU_pSuite suite); +int boolean_test_init(void); +int boolean_test_cleanup(void); +int boolean_add_tests(CU_pSuite suite); #endif