@@ -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;
}
@@ -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;
}
@@ -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);
@@ -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;
}
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 <jwcart2@tycho.nsa.gov> --- 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(-)