Skip to content

Commit b411742

Browse files
tweksteenjwcart2
authored andcommitted
libselinux: rename hashtab functions
In commit d95bc8b ("libselinux: migrating hashtab from policycoreutils") and commit 4a42050 ("libselinux: adapting hashtab to libselinux"), the hashtab implementation was copied to libselinux. Since the same functions exist in libsepol (e.g., hashtab_create, hashtab_destroy, etc), a compilation error is raised when both libraries are included statically. Prefix the libselinux internal implementation with "selinux_". Signed-off-by: Thiébaud Weksteen <[email protected]> Acked-by: James Carter <[email protected]>
1 parent 9c7c6e1 commit b411742

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

libselinux/src/hashtab.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <string.h>
1212
#include "hashtab.h"
1313

14-
hashtab_t hashtab_create(unsigned int (*hash_value) (hashtab_t h,
14+
hashtab_t selinux_hashtab_create(unsigned int (*hash_value) (hashtab_t h,
1515
const_hashtab_key_t key),
1616
int (*keycmp) (hashtab_t h,
1717
const_hashtab_key_t key1,
@@ -42,7 +42,7 @@ hashtab_t hashtab_create(unsigned int (*hash_value) (hashtab_t h,
4242
return p;
4343
}
4444

45-
int hashtab_insert(hashtab_t h, hashtab_key_t key, hashtab_datum_t datum)
45+
int selinux_hashtab_insert(hashtab_t h, hashtab_key_t key, hashtab_datum_t datum)
4646
{
4747
unsigned int hvalue;
4848
hashtab_ptr_t prev, cur, newnode;
@@ -79,7 +79,7 @@ int hashtab_insert(hashtab_t h, hashtab_key_t key, hashtab_datum_t datum)
7979
return HASHTAB_SUCCESS;
8080
}
8181

82-
int hashtab_remove(hashtab_t h, hashtab_key_t key,
82+
int selinux_hashtab_remove(hashtab_t h, hashtab_key_t key,
8383
void (*destroy) (hashtab_key_t k,
8484
hashtab_datum_t d, void *args), void *args)
8585
{
@@ -112,7 +112,7 @@ int hashtab_remove(hashtab_t h, hashtab_key_t key,
112112
return HASHTAB_SUCCESS;
113113
}
114114

115-
hashtab_datum_t hashtab_search(hashtab_t h, const_hashtab_key_t key)
115+
hashtab_datum_t selinux_hashtab_search(hashtab_t h, const_hashtab_key_t key)
116116
{
117117

118118
unsigned int hvalue;
@@ -132,7 +132,7 @@ hashtab_datum_t hashtab_search(hashtab_t h, const_hashtab_key_t key)
132132
return cur->datum;
133133
}
134134

135-
void hashtab_destroy(hashtab_t h)
135+
void selinux_hashtab_destroy(hashtab_t h)
136136
{
137137
unsigned int i;
138138
hashtab_ptr_t cur, temp;
@@ -156,7 +156,7 @@ void hashtab_destroy(hashtab_t h)
156156
free(h);
157157
}
158158

159-
void hashtab_destroy_key(hashtab_t h,
159+
void selinux_hashtab_destroy_key(hashtab_t h,
160160
int (*destroy_key) (hashtab_key_t k))
161161
{
162162
unsigned int i;
@@ -182,7 +182,7 @@ void hashtab_destroy_key(hashtab_t h,
182182
free(h);
183183
}
184184

185-
int hashtab_map(hashtab_t h,
185+
int selinux_hashtab_map(hashtab_t h,
186186
int (*apply) (hashtab_key_t k,
187187
hashtab_datum_t d, void *args), void *args)
188188
{
@@ -205,7 +205,7 @@ int hashtab_map(hashtab_t h,
205205
return HASHTAB_SUCCESS;
206206
}
207207

208-
void hashtab_hash_eval(hashtab_t h, char *tag)
208+
void selinux_hashtab_hash_eval(hashtab_t h, char *tag)
209209
{
210210
unsigned int i;
211211
int chain_len, slots_used, max_chain_len;

libselinux/src/hashtab.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ typedef hashtab_val_t *hashtab_t;
5252
Returns NULL if insufficient space is available or
5353
the new hash table otherwise.
5454
*/
55-
extern hashtab_t hashtab_create(unsigned int (*hash_value) (hashtab_t h,
55+
extern hashtab_t selinux_hashtab_create(unsigned int (*hash_value) (hashtab_t h,
5656
const_hashtab_key_t
5757
key),
5858
int (*keycmp) (hashtab_t h,
@@ -66,7 +66,7 @@ extern hashtab_t hashtab_create(unsigned int (*hash_value) (hashtab_t h,
6666
HASHTAB_PRESENT if there is already an entry with the same key or
6767
HASHTAB_SUCCESS otherwise.
6868
*/
69-
extern int hashtab_insert(hashtab_t h, hashtab_key_t k, hashtab_datum_t d);
69+
extern int selinux_hashtab_insert(hashtab_t h, hashtab_key_t k, hashtab_datum_t d);
7070

7171
/*
7272
Removes the entry with the specified key from the hash table.
@@ -76,7 +76,7 @@ extern int hashtab_insert(hashtab_t h, hashtab_key_t k, hashtab_datum_t d);
7676
Returns HASHTAB_MISSING if no entry has the specified key or
7777
HASHTAB_SUCCESS otherwise.
7878
*/
79-
extern int hashtab_remove(hashtab_t h, hashtab_key_t k,
79+
extern int selinux_hashtab_remove(hashtab_t h, hashtab_key_t k,
8080
void (*destroy) (hashtab_key_t k,
8181
hashtab_datum_t d,
8282
void *args), void *args);
@@ -87,13 +87,13 @@ extern int hashtab_remove(hashtab_t h, hashtab_key_t k,
8787
Returns NULL if no entry has the specified key or
8888
the datum of the entry otherwise.
8989
*/
90-
extern hashtab_datum_t hashtab_search(hashtab_t h, const_hashtab_key_t k);
90+
extern hashtab_datum_t selinux_hashtab_search(hashtab_t h, const_hashtab_key_t k);
9191

9292
/*
9393
Destroys the specified hash table.
9494
*/
95-
extern void hashtab_destroy(hashtab_t h);
96-
extern void hashtab_destroy_key(hashtab_t h,
95+
extern void selinux_hashtab_destroy(hashtab_t h);
96+
extern void selinux_hashtab_destroy_key(hashtab_t h,
9797
int (*destroy_key) (hashtab_key_t k));
9898

9999
/*
@@ -107,11 +107,11 @@ extern void hashtab_destroy_key(hashtab_t h,
107107
iterating through the hash table and will propagate the error
108108
return to its caller.
109109
*/
110-
extern int hashtab_map(hashtab_t h,
110+
extern int selinux_hashtab_map(hashtab_t h,
111111
int (*apply) (hashtab_key_t k,
112112
hashtab_datum_t d,
113113
void *args), void *args);
114114

115-
extern void hashtab_hash_eval(hashtab_t h, char *tag);
115+
extern void selinux_hashtab_hash_eval(hashtab_t h, char *tag);
116116

117117
#endif

libselinux/src/label_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int nodups_specs(struct saved_data *data, const char *path)
111111
struct chkdups_key *new = NULL;
112112
unsigned int hashtab_len = (data->nspec / SHRINK_MULTIS) ? data->nspec / SHRINK_MULTIS : 1;
113113

114-
hashtab_t hash_table = hashtab_create(symhash, symcmp, hashtab_len);
114+
hashtab_t hash_table = selinux_hashtab_create(symhash, symcmp, hashtab_len);
115115
if (!hash_table) {
116116
rc = -1;
117117
COMPAT_LOG(SELINUX_ERROR, "%s: hashtab create failed.\n", path);
@@ -121,18 +121,18 @@ static int nodups_specs(struct saved_data *data, const char *path)
121121
new = (struct chkdups_key *)malloc(sizeof(struct chkdups_key));
122122
if (!new) {
123123
rc = -1;
124-
hashtab_destroy_key(hash_table, destroy_chkdups_key);
124+
selinux_hashtab_destroy_key(hash_table, destroy_chkdups_key);
125125
COMPAT_LOG(SELINUX_ERROR, "%s: hashtab key create failed.\n", path);
126126
return rc;
127127
}
128128
new->regex = spec_arr[ii].regex_str;
129129
new->mode = spec_arr[ii].mode;
130-
ret = hashtab_insert(hash_table, (hashtab_key_t)new, &spec_arr[ii]);
130+
ret = selinux_hashtab_insert(hash_table, (hashtab_key_t)new, &spec_arr[ii]);
131131
if (ret == HASHTAB_SUCCESS)
132132
continue;
133133
if (ret == HASHTAB_PRESENT) {
134134
curr_spec =
135-
(struct spec *)hashtab_search(hash_table, (hashtab_key_t)new);
135+
(struct spec *)selinux_hashtab_search(hash_table, (hashtab_key_t)new);
136136
rc = -1;
137137
errno = EINVAL;
138138
free(new);
@@ -161,7 +161,7 @@ static int nodups_specs(struct saved_data *data, const char *path)
161161
}
162162
}
163163

164-
hashtab_destroy_key(hash_table, destroy_chkdups_key);
164+
selinux_hashtab_destroy_key(hash_table, destroy_chkdups_key);
165165

166166
return rc;
167167
}

0 commit comments

Comments
 (0)