Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selinux: constify some avtab function arguments

This makes the code a bit easier to reason about.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>

authored by

Ondrej Mosnacek and committed by
Paul Moore
e1cce3a3 fba472bb

+26 -21
+15 -13
security/selinux/ss/avtab.c
··· 29 29 /* Based on MurmurHash3, written by Austin Appleby and placed in the 30 30 * public domain. 31 31 */ 32 - static inline int avtab_hash(struct avtab_key *keyp, u32 mask) 32 + static inline int avtab_hash(const struct avtab_key *keyp, u32 mask) 33 33 { 34 34 static const u32 c1 = 0xcc9e2d51; 35 35 static const u32 c2 = 0x1b873593; ··· 68 68 static struct avtab_node* 69 69 avtab_insert_node(struct avtab *h, int hvalue, 70 70 struct avtab_node *prev, struct avtab_node *cur, 71 - struct avtab_key *key, struct avtab_datum *datum) 71 + const struct avtab_key *key, const struct avtab_datum *datum) 72 72 { 73 73 struct avtab_node *newnode; 74 74 struct avtab_extended_perms *xperms; ··· 103 103 return newnode; 104 104 } 105 105 106 - static int avtab_insert(struct avtab *h, struct avtab_key *key, struct avtab_datum *datum) 106 + static int avtab_insert(struct avtab *h, const struct avtab_key *key, 107 + const struct avtab_datum *datum) 107 108 { 108 109 int hvalue; 109 110 struct avtab_node *prev, *cur, *newnode; ··· 148 147 * key/specified mask into the table, as needed by the conditional avtab. 149 148 * It also returns a pointer to the node inserted. 150 149 */ 151 - struct avtab_node * 152 - avtab_insert_nonunique(struct avtab *h, struct avtab_key *key, struct avtab_datum *datum) 150 + struct avtab_node *avtab_insert_nonunique(struct avtab *h, 151 + const struct avtab_key *key, 152 + const struct avtab_datum *datum) 153 153 { 154 154 int hvalue; 155 155 struct avtab_node *prev, *cur; ··· 180 178 return avtab_insert_node(h, hvalue, prev, cur, key, datum); 181 179 } 182 180 183 - struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *key) 181 + struct avtab_datum *avtab_search(struct avtab *h, const struct avtab_key *key) 184 182 { 185 183 int hvalue; 186 184 struct avtab_node *cur; ··· 215 213 /* This search function returns a node pointer, and can be used in 216 214 * conjunction with avtab_search_next_node() 217 215 */ 218 - struct avtab_node* 219 - avtab_search_node(struct avtab *h, struct avtab_key *key) 216 + struct avtab_node *avtab_search_node(struct avtab *h, 217 + const struct avtab_key *key) 220 218 { 221 219 int hvalue; 222 220 struct avtab_node *cur; ··· 398 396 }; 399 397 400 398 int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, 401 - int (*insertf)(struct avtab *a, struct avtab_key *k, 402 - struct avtab_datum *d, void *p), 399 + int (*insertf)(struct avtab *a, const struct avtab_key *k, 400 + const struct avtab_datum *d, void *p), 403 401 void *p) 404 402 { 405 403 __le16 buf16[4]; ··· 559 557 return insertf(a, &key, &datum, p); 560 558 } 561 559 562 - static int avtab_insertf(struct avtab *a, struct avtab_key *k, 563 - struct avtab_datum *d, void *p) 560 + static int avtab_insertf(struct avtab *a, const struct avtab_key *k, 561 + const struct avtab_datum *d, void *p) 564 562 { 565 563 return avtab_insert(a, k, d); 566 564 } ··· 609 607 goto out; 610 608 } 611 609 612 - int avtab_write_item(struct policydb *p, struct avtab_node *cur, void *fp) 610 + int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp) 613 611 { 614 612 __le16 buf16[4]; 615 613 __le32 buf32[ARRAY_SIZE(cur->datum.u.xperms->perms.p)];
+9 -7
security/selinux/ss/avtab.h
··· 90 90 void avtab_init(struct avtab *h); 91 91 int avtab_alloc(struct avtab *, u32); 92 92 int avtab_alloc_dup(struct avtab *new, const struct avtab *orig); 93 - struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k); 93 + struct avtab_datum *avtab_search(struct avtab *h, const struct avtab_key *k); 94 94 void avtab_destroy(struct avtab *h); 95 95 void avtab_hash_eval(struct avtab *h, char *tag); 96 96 97 97 struct policydb; 98 98 int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol, 99 - int (*insert)(struct avtab *a, struct avtab_key *k, 100 - struct avtab_datum *d, void *p), 99 + int (*insert)(struct avtab *a, const struct avtab_key *k, 100 + const struct avtab_datum *d, void *p), 101 101 void *p); 102 102 103 103 int avtab_read(struct avtab *a, void *fp, struct policydb *pol); 104 - int avtab_write_item(struct policydb *p, struct avtab_node *cur, void *fp); 104 + int avtab_write_item(struct policydb *p, const struct avtab_node *cur, void *fp); 105 105 int avtab_write(struct policydb *p, struct avtab *a, void *fp); 106 106 107 - struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key, 108 - struct avtab_datum *datum); 107 + struct avtab_node *avtab_insert_nonunique(struct avtab *h, 108 + const struct avtab_key *key, 109 + const struct avtab_datum *datum); 109 110 110 - struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key); 111 + struct avtab_node *avtab_search_node(struct avtab *h, 112 + const struct avtab_key *key); 111 113 112 114 struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified); 113 115
+2 -1
security/selinux/ss/conditional.c
··· 254 254 struct cond_av_list *other; 255 255 }; 256 256 257 - static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum *d, void *ptr) 257 + static int cond_insertf(struct avtab *a, const struct avtab_key *k, 258 + const struct avtab_datum *d, void *ptr) 258 259 { 259 260 struct cond_insertf_data *data = ptr; 260 261 struct policydb *p = data->p;