* 3. Passing --help as any argument
* 4. Passing -h as any argument
*/
+ assert(argc == 0 || argv);
if (argc <= 1)
return true;
bool modified = false;
int r;
+ assert(q);
+
if (q->ambient != CAP_MASK_UNSET ||
q->inheritable != CAP_MASK_UNSET ||
q->permitted != CAP_MASK_UNSET ||
#if defined(__x86_64__)
static void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) {
+ assert(eax);
+ assert(ebx);
+ assert(ecx);
+ assert(edx);
+
log_debug("CPUID func %" PRIx32 " %" PRIx32, *eax, *ecx);
__cpuid_count(*eax, *ecx, *eax, *ebx, *ecx, *edx);
log_debug("CPUID result %" PRIx32 " %" PRIx32 " %" PRIx32 " %" PRIx32, *eax, *ebx, *ecx, *edx);
size_t n;
int r;
+ assert(s);
assert(ret);
n = strspn(s, DIGITS);
const suffix_table *table;
size_t n;
+ assert(buf);
assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si));
if (t == UINT64_MAX)
#endif
static unsigned n_buckets(HashmapBase *h) {
+ assert(h);
return h->has_indirect ? h->indirect.n_buckets
: hashmap_type_info[h->type].n_direct_buckets;
}
static unsigned n_entries(HashmapBase *h) {
+ assert(h);
return h->has_indirect ? h->indirect.n_entries
: h->n_direct_entries;
}
static void n_entries_inc(HashmapBase *h) {
+ assert(h);
+
if (h->has_indirect)
h->indirect.n_entries++;
else
}
static void n_entries_dec(HashmapBase *h) {
+ assert(h);
+
if (h->has_indirect)
h->indirect.n_entries--;
else
}
static void* storage_ptr(HashmapBase *h) {
+ assert(h);
return h->has_indirect ? h->indirect.storage
: h->direct.storage;
}
static uint8_t* hash_key(HashmapBase *h) {
+ assert(h);
return h->has_indirect ? h->indirect.hash_key
: shared_hash_key;
}
struct siphash state;
uint64_t hash;
+ assert(h);
+
siphash24_init(&state, hash_key(h));
h->hash_ops->hash(p, &state);
#define bucket_hash(h, p) base_bucket_hash(HASHMAP_BASE(h), p)
static void base_set_dirty(HashmapBase *h) {
+ assert(h);
+
h->dirty = true;
}
#define hashmap_set_dirty(h) base_set_dirty(HASHMAP_BASE(h))
}
static struct hashmap_base_entry* bucket_at(HashmapBase *h, unsigned idx) {
+ assert(h);
return CAST_ALIGN_PTR(
struct hashmap_base_entry,
(uint8_t *) storage_ptr(h) + idx * hashmap_type_info[h->type].entry_size);
}
static struct ordered_hashmap_entry* bucket_at_swap(struct swap_entries *swap, unsigned idx) {
+ assert(swap);
return &swap->e[idx - _IDX_SWAP_BEGIN];
}
}
static dib_raw_t* dib_raw_ptr(HashmapBase *h) {
+ assert(h);
return (dib_raw_t*)
((uint8_t*) storage_ptr(h) + hashmap_type_info[h->type].entry_size * n_buckets(h));
}
}
static void bucket_mark_free(HashmapBase *h, unsigned idx) {
+ assert(h);
+
memzero(bucket_at(h, idx), hashmap_type_info[h->type].entry_size);
bucket_set_dib(h, idx, DIB_FREE);
}
unsigned from, unsigned to) {
struct hashmap_base_entry *e_from, *e_to;
+ assert(h);
assert(from != to);
e_from = bucket_at_virtual(h, swap, from);
}
static void* entry_value(HashmapBase *h, struct hashmap_base_entry *e) {
+ assert(h);
+ assert(e);
+
switch (h->type) {
case HASHMAP_TYPE_PLAIN:
assert(dibs[idx] != DIB_RAW_FREE);
#if ENABLE_DEBUG_HASHMAP
+ assert(h);
h->debug.rem_count++;
h->debug.last_rem_idx = idx;
#endif
unsigned dib, distance;
#if ENABLE_DEBUG_HASHMAP
+ assert(h);
h->debug.put_count++;
#endif
}
bool in6_addr_is_ipv4_mapped_address(const struct in6_addr *a) {
+ assert(a);
+
return a->s6_addr32[0] == 0 &&
a->s6_addr32[1] == 0 &&
a->s6_addr32[2] == htobe32(UINT32_C(0x0000ffff));
int in6_addr_mask(struct in6_addr *addr, unsigned char prefixlen) {
unsigned i;
+ assert(addr);
+
for (i = 0; i < 16; i++) {
uint8_t mask;
_cleanup_set_free_ Set *locales = NULL;
int r;
+ assert(ret);
+
locales = set_new(&string_hash_ops_free);
if (!locales)
return -ENOMEM;
void* mempool_alloc0_tile(struct mempool *mp) {
void *p;
+ assert(mp);
+
p = mempool_alloc_tile(mp);
if (p)
memzero(p, mp->tile_size);
uid_t process_uid;
r = pidref_get_uid(pidref, &process_uid);
if (r < 0)
- return log_debug_errno(r, "Failed to get UID of process " PID_FMT ": %m", pidref->pid);
+ return log_debug_errno(r, "Failed to get UID of process " PID_FMT ": %m", pidref ? pidref->pid : 0);
if (process_uid == uid)
return true;
_cleanup_strv_free_ char **os_release_pairs = NULL, **os_release_pairs_prefixed = NULL;
int r;
+ assert(ret);
+
r = load_os_release_pairs(root, &os_release_pairs);
if (r < 0)
return r;
}
void pidref_hash_func(const PidRef *pidref, struct siphash *state) {
+ assert(pidref);
+
siphash24_compress_typesafe(pidref->pid, state);
}
pid_t ppid;
int r;
+ POINTER_MAY_BE_NULL(pidref);
assert(ret);
r = pidref_get_ppid(pidref, &ppid);
}
size_t sockaddr_len(const union sockaddr_union *sa) {
+ assert(sa);
+
switch (sa->sa.sa_family) {
case AF_INET:
return sizeof(struct sockaddr_in);
* about contents of the file. The purpose here is to detect file contents changes, and nothing
* else. */
+ assert(a);
+ assert(b);
+
return stat_inode_same(a, b) &&
a->st_mtim.tv_sec == b->st_mtim.tv_sec &&
a->st_mtim.tv_nsec == b->st_mtim.tv_nsec &&
}
usec_t statx_timestamp_load(const struct statx_timestamp *ts) {
+ assert(ts);
return timespec_load(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
}
nsec_t statx_timestamp_load_nsec(const struct statx_timestamp *ts) {
+ assert(ts);
return timespec_load_nsec(&(const struct timespec) { .tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec });
}
void inode_hash_func(const struct stat *q, struct siphash *state) {
+ assert(q);
+
siphash24_compress_typesafe(q->st_dev, state);
siphash24_compress_typesafe(q->st_ino, state);
int inode_compare_func(const struct stat *a, const struct stat *b) {
int r;
+ assert(a);
+ assert(b);
+
r = CMP(a->st_dev, b->st_dev);
if (r != 0)
return r;
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(inode_hash_ops, struct stat, inode_hash_func, inode_compare_func, free);
void inode_unmodified_hash_func(const struct stat *q, struct siphash *state) {
+ assert(q);
+
inode_hash_func(q, state);
siphash24_compress_typesafe(q->st_mtim.tv_sec, state);
int inode_unmodified_compare_func(const struct stat *a, const struct stat *b) {
int r;
+ assert(a);
+ assert(b);
+
r = inode_compare_func(a, b);
if (r != 0)
return r;
.c = c,
.child = node_child,
};
- int left = 0, right = node->children_count;
+ int left = 0, right = ASSERT_PTR(node)->children_count;
while (right > left) {
int middle = (right + left) / 2 ;
if (i < 0 || i >= (ssize_t) len)
return NULL;
+ assert(table);
+
return table[i];
}
ssize_t string_table_lookup_from_string(const char * const *table, size_t len, const char *key) {
+ assert_return(table, -EINVAL);
+
if (!key)
return -EINVAL;
int string_table_lookup_to_string_fallback(const char * const *table, size_t len, ssize_t i, size_t max, char **ret) {
char *s;
+ assert(table);
assert(ret);
if (i < 0 || i > (ssize_t) max)
}
char* ascii_strlower_n(char *s, size_t n) {
+ assert(n <= 0 || s);
+
if (n <= 0)
return s;
size_t n;
int r;
+ assert(ret);
assert(s);
/* Special version of strv_split_full() that splits on newlines and
char* sysctl_normalize(char *s) {
char *n;
+ assert(s);
+
n = strpbrk(s, "/.");
/* If the first separator is a slash, the path is
_cleanup_free_ char *found = NULL;
bool partial = false;
+ assert(ret);
+
string = strempty(string);
STRV_FOREACH(c, completions) {
const char *grey_prefix,
bool with_numbers) {
+ assert(x);
assert(n_columns > 0);
if (n_columns == SIZE_MAX)
_cleanup_close_pair_ int pair[2] = EBADF_PAIR;
int r;
+ assert(pidref);
+
r = pidref_namespace_open(pidref, &pidnsfd, &mntnsfd, /* ret_netns_fd= */ NULL, &usernsfd, &rootfd);
if (r < 0)
return log_debug_errno(r, "Failed to open namespaces of PID "PID_FMT": %m", pidref->pid);
_cleanup_close_ int fd = -EBADF;
FILE *f;
+ assert(ret_f);
+
fd = mkostemp_safe(pattern);
if (fd < 0)
return fd;
}
uid_t uid_range_base(const UIDRange *range) {
-
/* Returns the lowest UID in the range (notw that elements are sorted, hence we just need to look at
* the first one that is populated. */
int merge_gid_lists(const gid_t *list1, size_t size1, const gid_t *list2, size_t size2, gid_t **ret) {
size_t nresult = 0;
+
+ assert(size1 == 0 || list1);
+ assert(size2 == 0 || list2);
assert(ret);
if (size2 > INT_MAX - size1)
}
size_t utf16_encode_unichar(char16_t *out, char32_t c) {
+ assert(out);
/* Note that this encodes as little-endian. */
};
static bool given_flag_in_set(const char *flag, const struct cpuid_table_entry *set, size_t set_size, uint32_t val) {
+ assert(set);
+
for (size_t i = 0; i < set_size; i++) {
if ((UINT32_C(1) << set[i].flag_bit) & val &&
streq(flag, set[i].name))