libsepol: use size_t for indexes in strs helpers

Use size_t, as the strs struct uses it for its size member.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2021-12-09 17:49:08 +01:00 committed by James Carter
parent 8565e2c5c8
commit 47c3d96e56
2 changed files with 6 additions and 6 deletions

View File

@ -159,7 +159,7 @@ int strs_add(struct strs *strs, char *s)
{ {
if (strs->num + 1 > strs->size) { if (strs->num + 1 > strs->size) {
char **new; char **new;
unsigned i = strs->size; size_t i = strs->size;
strs->size *= 2; strs->size *= 2;
new = reallocarray(strs->list, strs->size, sizeof(char *)); new = reallocarray(strs->list, strs->size, sizeof(char *));
if (!new) { if (!new) {
@ -212,11 +212,11 @@ char *strs_remove_last(struct strs *strs)
return strs->list[strs->num]; return strs->list[strs->num];
} }
int strs_add_at_index(struct strs *strs, char *s, unsigned index) int strs_add_at_index(struct strs *strs, char *s, size_t index)
{ {
if (index >= strs->size) { if (index >= strs->size) {
char **new; char **new;
unsigned i = strs->size; size_t i = strs->size;
while (index >= strs->size) { while (index >= strs->size) {
strs->size *= 2; strs->size *= 2;
} }
@ -237,7 +237,7 @@ int strs_add_at_index(struct strs *strs, char *s, unsigned index)
return 0; return 0;
} }
char *strs_read_at_index(struct strs *strs, unsigned index) char *strs_read_at_index(struct strs *strs, size_t index)
{ {
if (index >= strs->num) { if (index >= strs->num) {
return NULL; return NULL;

View File

@ -99,8 +99,8 @@ int strs_add(struct strs *strs, char *s);
__attribute__ ((format(printf, 2, 4))) __attribute__ ((format(printf, 2, 4)))
int strs_create_and_add(struct strs *strs, const char *fmt, int num, ...); int strs_create_and_add(struct strs *strs, const char *fmt, int num, ...);
char *strs_remove_last(struct strs *strs); char *strs_remove_last(struct strs *strs);
int strs_add_at_index(struct strs *strs, char *s, unsigned index); int strs_add_at_index(struct strs *strs, char *s, size_t index);
char *strs_read_at_index(struct strs *strs, unsigned index); char *strs_read_at_index(struct strs *strs, size_t index);
void strs_sort(struct strs *strs); void strs_sort(struct strs *strs);
unsigned strs_num_items(struct strs *strs); unsigned strs_num_items(struct strs *strs);
size_t strs_len_items(struct strs *strs); size_t strs_len_items(struct strs *strs);