HashmapBase *h;
const struct hashmap_type_info *hi = &hashmap_type_info[type];
- bool use_pool = mempool_enabled && mempool_enabled();
+ bool use_pool = mempool_enabled && mempool_enabled(); /* mempool_enabled is a weak symbol */
h = use_pool ? mempool_alloc0_tile(hi->mempool) : malloc0(hi->head_size);
if (!h)
/* Use malloc attribute as this never returns p like userspace realloc. */
_malloc_ _alloc_(3) _returns_nonnull_ _warn_unused_result_
static inline void *xrealloc(void *p, size_t old_size, size_t new_size) {
- void *r = xmalloc(new_size);
+ void *t = xmalloc(new_size);
new_size = MIN(old_size, new_size);
if (new_size > 0)
- memcpy(r, p, new_size);
+ memcpy(t, p, new_size);
free(p);
- return r;
+ return t;
}
#define xpool_print(fmt, ...) ((char16_t *) ASSERT_SE_PTR(PoolPrint((fmt), ##__VA_ARGS__)))
int dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max) {
_cleanup_free_ uint32_t *input = NULL;
size_t input_size, l;
- const char *p;
bool contains_8bit = false;
char buffer[DNS_LABEL_MAX+1];
int r;
if (encoded_size <= 0)
return -EINVAL;
- for (p = encoded; p < encoded + encoded_size; p++)
+ for (const char *p = encoded; p < encoded + encoded_size; p++)
if ((uint8_t) *p > 127)
contains_8bit = true;
return r;
if (r > 0) {
uint8_t a[4];
- unsigned i;
- for (i = 0; i < ELEMENTSOF(a); i++) {
+ for (size_t i = 0; i < ELEMENTSOF(a); i++) {
char label[DNS_LABEL_MAX+1];
r = dns_label_unescape(&p, label, sizeof label, 0);
return r;
if (r > 0) {
struct in6_addr a;
- unsigned i;
- for (i = 0; i < ELEMENTSOF(a.s6_addr); i++) {
+ for (size_t i = 0; i < ELEMENTSOF(a.s6_addr); i++) {
char label[DNS_LABEL_MAX+1];
int x, y;
}
static bool srv_type_label_is_valid(const char *label, size_t n) {
- size_t k;
-
assert(label);
if (n < 2) /* Label needs to be at least 2 chars long */
return false;
/* Third and further chars must be alphanumeric or a hyphen */
- for (k = 2; k < n; k++) {
+ for (size_t k = 2; k < n; k++)
if (!ascii_isalpha(label[k]) &&
!ascii_isdigit(label[k]) &&
label[k] != '-')
return false;
- }
return true;
}
}
static int dns_name_build_suffix_table(const char *name, const char *table[]) {
- const char *p;
+ const char *p = ASSERT_PTR(name);
unsigned n = 0;
int r;
- assert(name);
assert(table);
- p = name;
for (;;) {
if (n > DNS_N_LABELS_MAX)
return -EINVAL;
streq(de->d_name, "io.systemd.DynamicUser"))
continue;
- /* Avoid NSS is this is requested. Note that we also skip NSS when we were asked to skip the
+ /* Avoid NSS if this is requested. Note that we also skip NSS when we were asked to skip the
* multiplexer, since in that case it's safer to do NSS in the client side emulation below
* (and when we run as part of systemd-userdbd.service we don't want to talk to ourselves
* anyway). */