Skip to content

Commit 74a4179

Browse files
sshedijohannbg
authored andcommitted
fix(install): use unsigned int instead of unsigned
Signed-off-by: Shreenidhi Shedi <[email protected]>
1 parent b0bf818 commit 74a4179

File tree

9 files changed

+66
-64
lines changed

9 files changed

+66
-64
lines changed

src/install/hashmap.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ struct Hashmap {
4040
compare_func_t compare_func;
4141

4242
struct hashmap_entry *iterate_list_head, *iterate_list_tail;
43-
unsigned n_entries;
43+
unsigned int n_entries;
4444
};
4545

4646
#define BY_HASH(h) ((struct hashmap_entry**) ((uint8_t*) (h) + ALIGN(sizeof(Hashmap))))
4747

48-
unsigned string_hash_func(const void *p)
48+
unsigned int string_hash_func(const void *p)
4949
{
50-
unsigned hash = 5381;
50+
unsigned int hash = 5381;
5151
const signed char *c;
5252

5353
/* DJB's hash function */
5454

5555
for (c = p; *c; c++)
56-
hash = (hash << 5) + hash + (unsigned)*c;
56+
hash = (hash << 5) + hash + (unsigned int)*c;
5757

5858
return hash;
5959
}
@@ -63,7 +63,7 @@ int string_compare_func(const void *a, const void *b)
6363
return strcmp(a, b);
6464
}
6565

66-
unsigned trivial_hash_func(const void *p)
66+
unsigned int trivial_hash_func(const void *p)
6767
{
6868
return PTR_TO_UINT(p);
6969
}
@@ -107,7 +107,7 @@ int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t
107107
return 0;
108108
}
109109

110-
static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
110+
static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned int hash)
111111
{
112112
assert(h);
113113
assert(e);
@@ -135,7 +135,7 @@ static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
135135
assert(h->n_entries >= 1);
136136
}
137137

138-
static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
138+
static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned int hash)
139139
{
140140
assert(h);
141141
assert(e);
@@ -167,7 +167,7 @@ static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash)
167167
static void remove_entry(Hashmap *h, struct hashmap_entry **ep)
168168
{
169169
struct hashmap_entry *e = *ep;
170-
unsigned hash;
170+
unsigned int hash;
171171

172172
assert(h);
173173
assert(e);
@@ -212,7 +212,7 @@ void hashmap_clear(Hashmap *h)
212212
}
213213
}
214214

215-
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key)
215+
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned int hash, const void *key)
216216
{
217217
struct hashmap_entry *e;
218218
assert(h);
@@ -228,7 +228,7 @@ static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *ke
228228
int hashmap_put(Hashmap *h, const void *key, void *value)
229229
{
230230
struct hashmap_entry *e;
231-
unsigned hash;
231+
unsigned int hash;
232232

233233
assert(h);
234234

@@ -258,7 +258,7 @@ int hashmap_put(Hashmap *h, const void *key, void *value)
258258
int hashmap_replace(Hashmap *h, const void *key, void *value)
259259
{
260260
struct hashmap_entry *e;
261-
unsigned hash;
261+
unsigned int hash;
262262

263263
assert(h);
264264

@@ -275,7 +275,7 @@ int hashmap_replace(Hashmap *h, const void *key, void *value)
275275

276276
void *hashmap_get(Hashmap *h, const void *key)
277277
{
278-
unsigned hash;
278+
unsigned int hash;
279279
struct hashmap_entry *e;
280280

281281
if (!h)
@@ -292,7 +292,7 @@ void *hashmap_get(Hashmap *h, const void *key)
292292
void *hashmap_remove(Hashmap *h, const void *key)
293293
{
294294
struct hashmap_entry *e;
295-
unsigned hash;
295+
unsigned int hash;
296296
void *data;
297297

298298
if (!h)
@@ -312,7 +312,7 @@ void *hashmap_remove(Hashmap *h, const void *key)
312312
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value)
313313
{
314314
struct hashmap_entry *e;
315-
unsigned old_hash, new_hash;
315+
unsigned int old_hash, new_hash;
316316

317317
if (!h)
318318
return -ENOENT;
@@ -338,7 +338,7 @@ int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key,
338338
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value)
339339
{
340340
struct hashmap_entry *e, *k;
341-
unsigned old_hash, new_hash;
341+
unsigned int old_hash, new_hash;
342342

343343
if (!h)
344344
return -ENOENT;
@@ -366,7 +366,7 @@ int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_
366366
void *hashmap_remove_value(Hashmap *h, const void *key, void *value)
367367
{
368368
struct hashmap_entry *e;
369-
unsigned hash;
369+
unsigned int hash;
370370

371371
if (!h)
372372
return NULL;
@@ -458,7 +458,7 @@ void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key)
458458

459459
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i)
460460
{
461-
unsigned hash;
461+
unsigned int hash;
462462
struct hashmap_entry *e;
463463

464464
if (!h)
@@ -546,7 +546,7 @@ void *hashmap_steal_first_key(Hashmap *h)
546546
return key;
547547
}
548548

549-
unsigned hashmap_size(Hashmap *h)
549+
unsigned int hashmap_size(Hashmap *h)
550550
{
551551

552552
if (!h)
@@ -597,7 +597,7 @@ void hashmap_move(Hashmap *h, Hashmap *other)
597597
return;
598598

599599
for (e = other->iterate_list_head; e; e = n) {
600-
unsigned h_hash, other_hash;
600+
unsigned int h_hash, other_hash;
601601

602602
n = e->iterate_next;
603603

@@ -615,7 +615,7 @@ void hashmap_move(Hashmap *h, Hashmap *other)
615615

616616
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key)
617617
{
618-
unsigned h_hash, other_hash;
618+
unsigned int h_hash, other_hash;
619619
struct hashmap_entry *e;
620620

621621
if (!other)

src/install/hashmap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ typedef _IteratorStruct *Iterator;
3434
#define ITERATOR_FIRST ((Iterator) 0)
3535
#define ITERATOR_LAST ((Iterator) -1)
3636

37-
typedef unsigned (*hash_func_t)(const void *p);
37+
typedef unsigned int (*hash_func_t)(const void *p);
3838
typedef int (*compare_func_t)(const void *a, const void *b);
3939

40-
unsigned string_hash_func(const void *p);
40+
unsigned int string_hash_func(const void *p);
4141
int string_compare_func(const void *a, const void *b);
4242

43-
unsigned trivial_hash_func(const void *p);
43+
unsigned int trivial_hash_func(const void *p);
4444
int trivial_compare_func(const void *a, const void *b);
4545

4646
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
@@ -60,7 +60,7 @@ int hashmap_merge(Hashmap *h, Hashmap *other);
6060
void hashmap_move(Hashmap *h, Hashmap *other);
6161
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
6262

63-
unsigned hashmap_size(Hashmap *h);
63+
unsigned int hashmap_size(Hashmap *h);
6464
bool hashmap_isempty(Hashmap *h);
6565

6666
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);

src/install/log.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int write_to_console(int level, const char *file, unsigned int line, cons
105105
{
106106

107107
struct iovec iovec[5];
108-
unsigned n = 0;
108+
unsigned int n = 0;
109109

110110
if (console_fd < 0)
111111
return 0;
@@ -130,7 +130,7 @@ static int write_to_console(int level, const char *file, unsigned int line, cons
130130
return 1;
131131
}
132132

133-
static int log_dispatch(int level, const char *file, int line, const char *func, char *buffer)
133+
static int log_dispatch(int level, const char *file, unsigned int line, const char *func, char *buffer)
134134
{
135135

136136
int r = 0;
@@ -163,7 +163,7 @@ static int log_dispatch(int level, const char *file, int line, const char *func,
163163
return r;
164164
}
165165

166-
int log_metav(int level, const char *file, int line, const char *func, const char *format, va_list ap)
166+
int log_metav(int level, const char *file, unsigned int line, const char *func, const char *format, va_list ap)
167167
{
168168

169169
char buffer[LINE_MAX];
@@ -182,7 +182,7 @@ int log_metav(int level, const char *file, int line, const char *func, const cha
182182
return r;
183183
}
184184

185-
int log_meta(int level, const char *file, int line, const char *func, const char *format, ...)
185+
int log_meta(int level, const char *file, unsigned int line, const char *func, const char *format, ...)
186186
{
187187

188188
int r;
@@ -197,7 +197,8 @@ int log_meta(int level, const char *file, int line, const char *func, const char
197197

198198
#pragma GCC diagnostic push
199199
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
200-
_noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format)
200+
_noreturn_ static void log_assert(const char *text, const char *file, unsigned int line, const char *func,
201+
const char *format)
201202
{
202203
static char buffer[LINE_MAX];
203204

@@ -212,12 +213,12 @@ _noreturn_ static void log_assert(const char *text, const char *file, int line,
212213

213214
#pragma GCC diagnostic pop
214215

215-
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func)
216+
_noreturn_ void log_assert_failed(const char *text, const char *file, unsigned int line, const char *func)
216217
{
217218
log_assert(text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
218219
}
219220

220-
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func)
221+
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, unsigned int line, const char *func)
221222
{
222223
log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
223224
}

src/install/log.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ void log_close_console(void);
6767

6868
void log_parse_environment(void);
6969

70-
int log_meta(int level, const char *file, int line, const char *func, const char *format, ...) _printf_attr_(5, 6);
70+
int log_meta(int level, const char *file, unsigned int line, const char *func,
71+
const char *format, ...) _printf_attr_(5, 6);
7172

72-
int log_metav(int level, const char *file, int line, const char *func, const char *format, va_list ap);
73+
int log_metav(int level, const char *file, unsigned int line, const char *func, const char *format, va_list ap);
7374

74-
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func);
75-
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func);
75+
_noreturn_ void log_assert_failed(const char *text, const char *file, unsigned int line, const char *func);
76+
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, unsigned int line, const char *func);
7677

7778
/* This modifies the buffer passed! */
7879
int log_dump_internal(int level, const char *file, int line, const char *func, char *buffer);

src/install/macro.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ static inline size_t ALIGN_TO(size_t l, size_t ali)
190190
_i->iov_len = strlen(_s); \
191191
} while(false)
192192

193-
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n)
193+
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned int n)
194194
{
195-
unsigned j;
195+
unsigned int j;
196196
size_t r = 0;
197197

198198
for (j = 0; j < n; j++)
@@ -201,9 +201,9 @@ static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n)
201201
return r;
202202
}
203203

204-
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k)
204+
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned int n, size_t k)
205205
{
206-
unsigned j;
206+
unsigned int j;
207207

208208
for (j = 0; j < n; j++) {
209209
size_t sub;

src/install/strv.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ char **strv_copy(char *const *l)
9090

9191
unsigned int strv_length(char *const *l)
9292
{
93-
unsigned n = 0;
93+
unsigned int n = 0;
9494

9595
if (!l)
9696
return 0;
@@ -105,7 +105,7 @@ char **strv_new_ap(const char *x, va_list ap)
105105
{
106106
const char *s;
107107
char **a;
108-
unsigned n = 0, i = 0;
108+
unsigned int n = 0, i = 0;
109109
va_list aq;
110110

111111
/* As a special trick we ignore all listed strings that equal
@@ -248,7 +248,7 @@ char **strv_split(const char *s, const char *separator)
248248
char *state;
249249
char *w;
250250
size_t l;
251-
unsigned n, i;
251+
unsigned int n, i;
252252
char **r;
253253

254254
assert(s);
@@ -282,7 +282,7 @@ char **strv_split_quoted(const char *s)
282282
char *state;
283283
char *w;
284284
size_t l;
285-
unsigned n, i;
285+
unsigned int n, i;
286286
char **r;
287287

288288
assert(s);
@@ -406,7 +406,7 @@ char **strv_append(char **l, const char *s)
406406
int strv_push(char ***l, char *value)
407407
{
408408
char **c;
409-
unsigned n;
409+
unsigned int n;
410410

411411
if (!value)
412412
return 0;
@@ -510,7 +510,7 @@ char **strv_remove_prefix(char **l, const char *s)
510510
char **strv_parse_nulstr(const char *s, size_t l)
511511
{
512512
const char *p;
513-
unsigned c = 0, i = 0;
513+
unsigned int c = 0, i = 0;
514514
char **v;
515515

516516
assert(s || l == 0);

src/install/strv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void strv_print(char **l);
9595
if (!first) \
9696
_l = (char**) &first; \
9797
else { \
98-
unsigned _n; \
98+
unsigned int _n; \
9999
va_list _ap; \
100100
\
101101
_n = 1; \

src/install/util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void close_nointr_nofail(int fd)
9696
int open_terminal(const char *name, int mode)
9797
{
9898
int fd, r;
99-
unsigned c = 0;
99+
unsigned int c = 0;
100100

101101
/*
102102
* If a TTY is in the process of being closed opening it might
@@ -161,7 +161,7 @@ bool is_main_thread(void)
161161
return cached > 0;
162162
}
163163

164-
int safe_atou(const char *s, unsigned *ret_u)
164+
int safe_atou(const char *s, unsigned int *ret_u)
165165
{
166166
char *x = NULL;
167167
unsigned long l;
@@ -175,10 +175,10 @@ int safe_atou(const char *s, unsigned *ret_u)
175175
if (!x || *x || errno)
176176
return errno ? -errno : -EINVAL;
177177

178-
if ((unsigned long)(unsigned)l != l)
178+
if ((unsigned long)(unsigned int)l != l)
179179
return -ERANGE;
180180

181-
*ret_u = (unsigned)l;
181+
*ret_u = (unsigned int)l;
182182
return 0;
183183
}
184184

0 commit comments

Comments
 (0)