tree-wide: use ASSERT_PTR more

This commit is contained in:
David Tardon
2022-09-13 08:13:27 +02:00
parent 6d64cb0625
commit 995340074e
220 changed files with 1071 additions and 2323 deletions
+1 -3
View File
@@ -443,11 +443,9 @@ static int merge_env_file_push(
const char *key, char *value,
void *userdata) {
char ***env = userdata;
char ***env = ASSERT_PTR(userdata);
char *expanded_value;
assert(env);
if (!value) {
log_error("%s:%u: invalid syntax (around \"%s\"), ignoring.", strna(filename), line, key);
return 0;
+1 -2
View File
@@ -1882,11 +1882,10 @@ int _set_put_strdupv_full(Set **s, const struct hash_ops *hash_ops, char **l HA
}
int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags) {
const char *p = v;
const char *p = ASSERT_PTR(v);
int r;
assert(s);
assert(v);
for (;;) {
char *word;
+2 -4
View File
@@ -49,11 +49,10 @@ int flush_fd(int fd) {
}
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
uint8_t *p = buf;
uint8_t *p = ASSERT_PTR(buf);
ssize_t n = 0;
assert(fd >= 0);
assert(buf);
/* If called with nbytes == 0, let's call read() at least
* once, to validate the operation */
@@ -108,10 +107,9 @@ int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll) {
}
int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
const uint8_t *p = buf;
const uint8_t *p = ASSERT_PTR(buf);
assert(fd >= 0);
assert(buf);
if (_unlikely_(nbytes > (size_t) SSIZE_MAX))
return -EINVAL;
+1 -3
View File
@@ -338,11 +338,9 @@ char **path_strv_resolve_uniq(char **l, const char *root) {
char *path_simplify(char *path) {
bool add_slash = false;
char *f = path;
char *f = ASSERT_PTR(path);
int r;
assert(path);
/* Removes redundant inner and trailing slashes. Also removes unnecessary dots.
* Modifies the passed string in-place.
*
+1 -2
View File
@@ -72,12 +72,11 @@ void siphash24_init(struct siphash *state, const uint8_t k[static 16]) {
void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
const uint8_t *in = _in;
const uint8_t *in = ASSERT_PTR(_in);
const uint8_t *end = in + inlen;
size_t left = state->inlen & 7;
uint64_t m;
assert(in);
assert(state);
/* Update total length */
+1 -2
View File
@@ -513,10 +513,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
{ "us", 1 },
};
char *p = buf;
char *p = ASSERT_PTR(buf);
bool something = false;
assert(buf);
assert(l > 0);
if (t == USEC_INFINITY) {