Skip to content

Commit

Permalink
checkpolicy: mark file local functions in policy define static
Browse files Browse the repository at this point in the history
Export the defined and external used functions `init_parser` and
`yyerror2`.

Drop the unused function `avrule_ioctl_freeranges`.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
  • Loading branch information
cgzones committed May 22, 2021
1 parent 030e292 commit 44f8bb1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
45 changes: 17 additions & 28 deletions checkpolicy/policy_define.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ static int set_types(type_set_t * set, char *id, int *add, char starallowed)
return -1;
}

int define_compute_type_helper(int which, avrule_t ** rule)
static int define_compute_type_helper(int which, avrule_t ** rule)
{
char *id;
type_datum_t *datum;
Expand Down Expand Up @@ -1832,7 +1832,7 @@ struct av_ioctl_range_list {
struct av_ioctl_range_list *next;
};

int avrule_sort_ioctls(struct av_ioctl_range_list **rangehead)
static int avrule_sort_ioctls(struct av_ioctl_range_list **rangehead)
{
struct av_ioctl_range_list *r, *r2, *sorted, *sortedhead = NULL;

Expand Down Expand Up @@ -1880,7 +1880,7 @@ int avrule_sort_ioctls(struct av_ioctl_range_list **rangehead)
return -1;
}

int avrule_merge_ioctls(struct av_ioctl_range_list **rangehead)
static int avrule_merge_ioctls(struct av_ioctl_range_list **rangehead)
{
struct av_ioctl_range_list *r, *tmp;
r = *rangehead;
Expand All @@ -1900,7 +1900,7 @@ int avrule_merge_ioctls(struct av_ioctl_range_list **rangehead)
return 0;
}

int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
static int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
{
char *id;
struct av_ioctl_range_list *rnew, *r = NULL;
Expand Down Expand Up @@ -1953,7 +1953,7 @@ int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
}

/* flip to included ranges */
int avrule_omit_ioctls(struct av_ioctl_range_list **rangehead)
static int avrule_omit_ioctls(struct av_ioctl_range_list **rangehead)
{
struct av_ioctl_range_list *rnew, *r, *newhead, *r2;

Expand Down Expand Up @@ -2001,7 +2001,7 @@ int avrule_omit_ioctls(struct av_ioctl_range_list **rangehead)
return -1;
}

int avrule_ioctl_ranges(struct av_ioctl_range_list **rangelist)
static int avrule_ioctl_ranges(struct av_ioctl_range_list **rangelist)
{
struct av_ioctl_range_list *rangehead;
uint8_t omit;
Expand Down Expand Up @@ -2029,7 +2029,7 @@ int avrule_ioctl_ranges(struct av_ioctl_range_list **rangelist)
return 0;
}

int define_te_avtab_xperms_helper(int which, avrule_t ** rule)
static int define_te_avtab_xperms_helper(int which, avrule_t ** rule)
{
char *id;
class_perm_node_t *perms, *tail = NULL, *cur_perms = NULL;
Expand Down Expand Up @@ -2150,7 +2150,7 @@ int define_te_avtab_xperms_helper(int which, avrule_t ** rule)
#define XPERM_LOW(x) ((x) << 5)
/* high value for this u32 */
#define XPERM_HIGH(x) ((((x) + 1) << 5) - 1)
void avrule_xperm_setrangebits(uint16_t low, uint16_t high,
static void avrule_xperm_setrangebits(uint16_t low, uint16_t high,
av_extended_perms_t *xperms)
{
unsigned int i;
Expand All @@ -2172,7 +2172,7 @@ void avrule_xperm_setrangebits(uint16_t low, uint16_t high,
}
}

int avrule_xperms_used(const av_extended_perms_t *xperms)
static int avrule_xperms_used(const av_extended_perms_t *xperms)
{
unsigned int i;

Expand All @@ -2192,7 +2192,7 @@ int avrule_xperms_used(const av_extended_perms_t *xperms)
#define IOC_DRIV(x) ((x) >> 8)
#define IOC_FUNC(x) ((x) & 0xff)
#define IOC_CMD(driver, func) (((driver) << 8) + (func))
int avrule_ioctl_partialdriver(struct av_ioctl_range_list *rangelist,
static int avrule_ioctl_partialdriver(struct av_ioctl_range_list *rangelist,
av_extended_perms_t *complete_driver,
av_extended_perms_t **extended_perms)
{
Expand Down Expand Up @@ -2231,7 +2231,7 @@ int avrule_ioctl_partialdriver(struct av_ioctl_range_list *rangelist,

}

int avrule_ioctl_completedriver(struct av_ioctl_range_list *rangelist,
static int avrule_ioctl_completedriver(struct av_ioctl_range_list *rangelist,
av_extended_perms_t **extended_perms)
{
struct av_ioctl_range_list *r;
Expand Down Expand Up @@ -2273,7 +2273,7 @@ int avrule_ioctl_completedriver(struct av_ioctl_range_list *rangelist,
return 0;
}

int avrule_ioctl_func(struct av_ioctl_range_list *rangelist,
static int avrule_ioctl_func(struct av_ioctl_range_list *rangelist,
av_extended_perms_t **extended_perms, unsigned int driver)
{
struct av_ioctl_range_list *r;
Expand Down Expand Up @@ -2323,18 +2323,7 @@ int avrule_ioctl_func(struct av_ioctl_range_list *rangelist,
return 0;
}

void avrule_ioctl_freeranges(struct av_ioctl_range_list *rangelist)
{
struct av_ioctl_range_list *r, *tmp;
r = rangelist;
while (r) {
tmp = r;
r = r->next;
free(tmp);
}
}

unsigned int xperms_for_each_bit(unsigned int *bit, av_extended_perms_t *xperms)
static unsigned int xperms_for_each_bit(unsigned int *bit, av_extended_perms_t *xperms)
{
unsigned int i;
for (i = *bit; i < sizeof(xperms->perms)*8; i++) {
Expand All @@ -2347,7 +2336,7 @@ unsigned int xperms_for_each_bit(unsigned int *bit, av_extended_perms_t *xperms)
return 0;
}

int avrule_cpy(avrule_t *dest, const avrule_t *src)
static int avrule_cpy(avrule_t *dest, const avrule_t *src)
{
class_perm_node_t *src_perms;
class_perm_node_t *dest_perms, *dest_tail;
Expand Down Expand Up @@ -2395,7 +2384,7 @@ int avrule_cpy(avrule_t *dest, const avrule_t *src)
return 0;
}

int define_te_avtab_ioctl(const avrule_t *avrule_template)
static int define_te_avtab_ioctl(const avrule_t *avrule_template)
{
avrule_t *avrule;
struct av_ioctl_range_list *rangelist;
Expand Down Expand Up @@ -2490,7 +2479,7 @@ int define_te_avtab_extended_perms(int which)
return 0;
}

int define_te_avtab_helper(int which, avrule_t ** rule)
static int define_te_avtab_helper(int which, avrule_t ** rule)
{
char *id;
class_datum_t *cladatum;
Expand Down Expand Up @@ -5470,7 +5459,7 @@ int define_fs_use(int behavior)
return 0;
}

int define_genfs_context_helper(char *fstype, int has_type)
static int define_genfs_context_helper(char *fstype, int has_type)
{
struct genfs *genfs_p, *genfs, *newgenfs;
ocontext_t *newc, *c, *head, *p;
Expand Down
2 changes: 2 additions & 0 deletions checkpolicy/policy_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#define TRUE 1
#define FALSE 0

void init_parser(int pass_number);
void yyerror2(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
avrule_t *define_cond_compute_type(int which);
avrule_t *define_cond_pol_list(avrule_t *avlist, avrule_t *stmt);
avrule_t *define_cond_te_avtab(int which);
Expand Down

0 comments on commit 44f8bb1

Please sign in to comment.