From patchwork Thu Oct 11 12:35:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Carter X-Patchwork-Id: 10636609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5932E16B1 for ; Thu, 11 Oct 2018 12:37:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E6452B461 for ; Thu, 11 Oct 2018 12:37:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 429152B469; Thu, 11 Oct 2018 12:37:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from USFB19PA12.eemsg.mail.mil (uphb19pa09.eemsg.mail.mil [214.24.26.83]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA256 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B6A42B45A for ; Thu, 11 Oct 2018 12:37:29 +0000 (UTC) X-EEMSG-check-008: 222198996|USFB19PA12_EEMSG_MP8.csd.disa.mil Received: from emsm-gh1-uea10.ncsc.mil ([214.29.60.2]) by USFB19PA12.eemsg.mail.mil with ESMTP; 11 Oct 2018 12:37:28 +0000 X-IronPort-AV: E=Sophos;i="5.54,368,1534809600"; d="scan'208";a="16722933" IronPort-PHdr: 9a23:tZAXXRw0bveI3oTXCy+O+j09IxM/srCxBDY+r6Qd1uoVKvad9pjvdHbS+e9qxAeQG9mDtLQc06L/iOPJYSQ4+5GPsXQPItRndiQuroEopTEmG9OPEkbhLfTnPGQQFcVGU0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xc78woDlaeVXPkQBWQKv0pqAPihEdUd94vk9MH3i8OGQg6DrbBuxpi/yKBfgU9CiDZrIBXl8uMS5kRR6xnpJ0dOiHh/dC50FPmy5m6NMjySBrXlPouzLnrrgRgxo86bq4s3MHonUDQeKAxXSbQW5fxegH2P9PQ03p7kaxNTxZNIY= X-IPAS-Result: A2AuAABbQ79b/wHyM5BiGgEBAQEBAgEBAQEHAgEBAQGBVAIBAQEBCwGBWSqBZSiMaotXTAEBAQEBAQaKNYkXhH2BYikTAYkXITcKDQEDAQEBAQEBAgFsKII2JIJgAwMBAjcUIAsDAwkBAUAICAMBLRURDgsFGASCQD+BdQ2nT4R3hGKHJYQggRCBB4ESh10BEgGFdwKBKAGHOIYSjx0GA5BJCxeQESyXPiJkcSsIAhgpSoEegU6CJheONFN7AQGJJoI+AQE Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by EMSM-GH1-UEA10.NCSC.MIL with ESMTP; 11 Oct 2018 12:37:27 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id w9BCbQBp028218; Thu, 11 Oct 2018 08:37:27 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id w9BCZNs3030954 for ; Thu, 11 Oct 2018 08:35:23 -0400 Received: from moss-lions.infosec.tycho.ncsc.mil (moss-lions [192.168.25.4]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id w9BCZNWp028160; Thu, 11 Oct 2018 08:35:23 -0400 From: James Carter To: selinux@vger.kernel.org Date: Thu, 11 Oct 2018 08:35:46 -0400 Message-Id: <20181011123549.14875-2-jwcart2@tycho.nsa.gov> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011123549.14875-1-jwcart2@tycho.nsa.gov> References: <20181011123549.14875-1-jwcart2@tycho.nsa.gov> Subject: [PATCH 1/4] libsepol: Rename kernel_to_common.c stack functions X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Cc: selinux@tycho.nsa.gov MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP Want to make use of selinux_sid_to_str[] and xen_sid_to_str[] from kernel_to_common.h in module_to_cil.c, but stack functions with the same names exist in module_to_cil.c and kernel_to_common.c (with the function prototypes in kernel_to_common.h). Since the stack functions in kernel_to_common.c are less general and only work with strings, rename those functions from stack_* to strs_stack_*. Signed-off-by: James Carter --- libsepol/src/kernel_to_cil.c | 36 ++++++++++++++++----------------- libsepol/src/kernel_to_common.c | 10 ++++----- libsepol/src/kernel_to_common.h | 10 ++++----- libsepol/src/kernel_to_conf.c | 36 ++++++++++++++++----------------- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c index b1eb66d6..c2a733ee 100644 --- a/libsepol/src/kernel_to_cil.c +++ b/libsepol/src/kernel_to_cil.c @@ -36,7 +36,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) char *str = NULL; int rc; - rc = stack_init(&stack); + rc = strs_stack_init(&stack); if (rc != 0) { goto exit; } @@ -65,13 +65,13 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) } if (num_params == 2) { - val2 = stack_pop(stack); + val2 = strs_stack_pop(stack); if (!val2) { sepol_log_err("Invalid conditional expression"); goto exit; } } - val1 = stack_pop(stack); + val1 = strs_stack_pop(stack); if (!val1) { sepol_log_err("Invalid conditional expression"); free(val2); @@ -89,29 +89,29 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) sepol_log_err("Invalid conditional expression"); goto exit; } - rc = stack_push(stack, new_val); + rc = strs_stack_push(stack, new_val); if (rc != 0) { sepol_log_err("Out of memory"); goto exit; } } - new_val = stack_pop(stack); - if (!new_val || !stack_empty(stack)) { + new_val = strs_stack_pop(stack); + if (!new_val || !strs_stack_empty(stack)) { sepol_log_err("Invalid conditional expression"); goto exit; } str = new_val; - stack_destroy(&stack); + strs_stack_destroy(&stack); return str; exit: - while ((new_val = stack_pop(stack)) != NULL) { + while ((new_val = strs_stack_pop(stack)) != NULL) { free(new_val); } - stack_destroy(&stack); + strs_stack_destroy(&stack); return NULL; } @@ -127,7 +127,7 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr *use_mls = 0; - rc = stack_init(&stack); + rc = strs_stack_init(&stack); if (rc != 0) { goto exit; } @@ -208,13 +208,13 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr } if (num_params == 2) { - val2 = stack_pop(stack); + val2 = strs_stack_pop(stack); if (!val2) { sepol_log_err("Invalid constraint expression"); goto exit; } } - val1 = stack_pop(stack); + val1 = strs_stack_pop(stack); if (!val1) { sepol_log_err("Invalid constraint expression"); goto exit; @@ -231,30 +231,30 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr if (!new_val) { goto exit; } - rc = stack_push(stack, new_val); + rc = strs_stack_push(stack, new_val); if (rc != 0) { sepol_log_err("Out of memory"); goto exit; } } - new_val = stack_pop(stack); - if (!new_val || !stack_empty(stack)) { + new_val = strs_stack_pop(stack); + if (!new_val || !strs_stack_empty(stack)) { sepol_log_err("Invalid constraint expression"); goto exit; } str = new_val; - stack_destroy(&stack); + strs_stack_destroy(&stack); return str; exit: - while ((new_val = stack_pop(stack)) != NULL) { + while ((new_val = strs_stack_pop(stack)) != NULL) { free(new_val); } - stack_destroy(&stack); + strs_stack_destroy(&stack); return NULL; } diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c index 7c5699c5..891e139c 100644 --- a/libsepol/src/kernel_to_common.c +++ b/libsepol/src/kernel_to_common.c @@ -400,27 +400,27 @@ exit: return str; } -int stack_init(struct strs **stack) +int strs_stack_init(struct strs **stack) { return strs_init(stack, STACK_SIZE); } -void stack_destroy(struct strs **stack) +void strs_stack_destroy(struct strs **stack) { return strs_destroy(stack); } -int stack_push(struct strs *stack, char *s) +int strs_stack_push(struct strs *stack, char *s) { return strs_add(stack, s); } -char *stack_pop(struct strs *stack) +char *strs_stack_pop(struct strs *stack) { return strs_remove_last(stack); } -int stack_empty(struct strs *stack) +int strs_stack_empty(struct strs *stack) { return strs_num_items(stack) == 0; } diff --git a/libsepol/src/kernel_to_common.h b/libsepol/src/kernel_to_common.h index 992929ae..7c5edbd6 100644 --- a/libsepol/src/kernel_to_common.h +++ b/libsepol/src/kernel_to_common.h @@ -105,10 +105,10 @@ int hashtab_ordered_to_strs(char *key, void *data, void *args); int ebitmap_to_strs(struct ebitmap *map, struct strs *strs, char **val_to_name); char *ebitmap_to_str(struct ebitmap *map, char **val_to_name, int sort); -int stack_init(struct strs **stack); -void stack_destroy(struct strs **stack); -int stack_push(struct strs *stack, char *s); -char *stack_pop(struct strs *stack); -int stack_empty(struct strs *stack); +int strs_stack_init(struct strs **stack); +void strs_stack_destroy(struct strs **stack); +int strs_stack_push(struct strs *stack, char *s); +char *strs_stack_pop(struct strs *stack); +int strs_stack_empty(struct strs *stack); int sort_ocontexts(struct policydb *pdb); diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c index 95405207..a98b5ca9 100644 --- a/libsepol/src/kernel_to_conf.c +++ b/libsepol/src/kernel_to_conf.c @@ -35,7 +35,7 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) char *str = NULL; int rc; - rc = stack_init(&stack); + rc = strs_stack_init(&stack); if (rc != 0) { goto exit; } @@ -63,13 +63,13 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) } if (num_params == 2) { - val2 = stack_pop(stack); + val2 = strs_stack_pop(stack); if (!val2) { sepol_log_err("Invalid conditional expression"); goto exit; } } - val1 = stack_pop(stack); + val1 = strs_stack_pop(stack); if (!val1) { sepol_log_err("Invalid conditional expression"); free(val2); @@ -87,29 +87,29 @@ static char *cond_expr_to_str(struct policydb *pdb, struct cond_expr *expr) sepol_log_err("Invalid conditional expression"); goto exit; } - rc = stack_push(stack, new_val); + rc = strs_stack_push(stack, new_val); if (rc != 0) { sepol_log_err("Out of memory"); goto exit; } } - new_val = stack_pop(stack); - if (!new_val || !stack_empty(stack)) { + new_val = strs_stack_pop(stack); + if (!new_val || !strs_stack_empty(stack)) { sepol_log_err("Invalid conditional expression"); goto exit; } str = new_val; - stack_destroy(&stack); + strs_stack_destroy(&stack); return str; exit: - while ((new_val = stack_pop(stack)) != NULL) { + while ((new_val = strs_stack_pop(stack)) != NULL) { free(new_val); } - stack_destroy(&stack); + strs_stack_destroy(&stack); return NULL; } @@ -125,7 +125,7 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr *use_mls = 0; - rc = stack_init(&stack); + rc = strs_stack_init(&stack); if (rc != 0) { goto exit; } @@ -204,13 +204,13 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr } if (num_params == 2) { - val2 = stack_pop(stack); + val2 = strs_stack_pop(stack); if (!val2) { sepol_log_err("Invalid constraint expression"); goto exit; } } - val1 = stack_pop(stack); + val1 = strs_stack_pop(stack); if (!val1) { sepol_log_err("Invalid constraint expression"); goto exit; @@ -227,30 +227,30 @@ static char *constraint_expr_to_str(struct policydb *pdb, struct constraint_expr if (!new_val) { goto exit; } - rc = stack_push(stack, new_val); + rc = strs_stack_push(stack, new_val); if (rc != 0) { sepol_log_err("Out of memory"); goto exit; } } - new_val = stack_pop(stack); - if (!new_val || !stack_empty(stack)) { + new_val = strs_stack_pop(stack); + if (!new_val || !strs_stack_empty(stack)) { sepol_log_err("Invalid constraint expression"); goto exit; } str = new_val; - stack_destroy(&stack); + strs_stack_destroy(&stack); return str; exit: - while ((new_val = stack_pop(stack)) != NULL) { + while ((new_val = strs_stack_pop(stack)) != NULL) { free(new_val); } - stack_destroy(&stack); + strs_stack_destroy(&stack); return NULL; }