tree-wide: drop a few == NULL and != NULL comparison
Our CODING_STYLE suggests not comparing with NULL, but relying on C's downgrade-to-bool feature for that. Fix up some code to match these guidelines. (This is not comprehensive, the coccinelle output for this is unfortunately kinda borked)
This commit is contained in:
@@ -73,7 +73,7 @@ int clock_set_hwclock(const struct tm *tm) {
|
||||
int clock_is_localtime(const char* adjtime_path) {
|
||||
_cleanup_fclose_ FILE *f;
|
||||
|
||||
if (adjtime_path == NULL)
|
||||
if (!adjtime_path)
|
||||
adjtime_path = "/etc/adjtime";
|
||||
|
||||
/*
|
||||
|
||||
@@ -40,7 +40,7 @@ int whitelisted_char_for_devnode(char c, const char *white) {
|
||||
int encode_devnode_name(const char *str, char *str_enc, size_t len) {
|
||||
size_t i, j;
|
||||
|
||||
if (str == NULL || str_enc == NULL)
|
||||
if (!str || !str_enc)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0, j = 0; str[i] != '\0'; i++) {
|
||||
|
||||
@@ -71,7 +71,7 @@ int ether_addr_from_string(const char *s, struct ether_addr *ret, size_t *offset
|
||||
if (s[pos] == '\0') \
|
||||
break; \
|
||||
hexoff = strchr(hex, s[pos]); \
|
||||
if (hexoff == NULL) \
|
||||
if (!hexoff) \
|
||||
break; \
|
||||
assert(hexoff >= hex); \
|
||||
x = hexoff - hex; \
|
||||
@@ -99,7 +99,7 @@ int ether_addr_from_string(const char *s, struct ether_addr *ret, size_t *offset
|
||||
sep = s[strspn(s, hex)];
|
||||
if (sep == '\n')
|
||||
return -EINVAL;
|
||||
if (strchr(":.-", sep) == NULL)
|
||||
if (!strchr(":.-", sep))
|
||||
return -EINVAL;
|
||||
|
||||
if (sep == '.') {
|
||||
|
||||
+2
-2
@@ -140,7 +140,7 @@ int write_string_file_ts(
|
||||
|
||||
return r;
|
||||
} else
|
||||
assert(ts == NULL);
|
||||
assert(!ts);
|
||||
|
||||
if (flags & WRITE_STRING_FILE_CREATE) {
|
||||
f = fopen(fn, "we");
|
||||
@@ -1191,7 +1191,7 @@ int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
|
||||
if (!filename_is_valid(fn))
|
||||
return -EINVAL;
|
||||
|
||||
if (extra == NULL)
|
||||
if (!extra)
|
||||
extra = "";
|
||||
|
||||
t = new(char, strlen(p) + 2 + strlen(extra) + 6 + 1);
|
||||
|
||||
@@ -96,7 +96,7 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) {
|
||||
assert(imp->state == IMPORTER_STATE_LINE);
|
||||
assert(imp->offset <= imp->filled);
|
||||
assert(imp->filled <= imp->size);
|
||||
assert(imp->buf == NULL || imp->size > 0);
|
||||
assert(!imp->buf || imp->size > 0);
|
||||
assert(imp->fd >= 0);
|
||||
|
||||
for (;;) {
|
||||
@@ -159,8 +159,8 @@ static int fill_fixed_size(JournalImporter *imp, void **data, size_t size) {
|
||||
assert(size <= DATA_SIZE_MAX);
|
||||
assert(imp->offset <= imp->filled);
|
||||
assert(imp->filled <= imp->size);
|
||||
assert(imp->buf != NULL || imp->size == 0);
|
||||
assert(imp->buf == NULL || imp->size > 0);
|
||||
assert(imp->buf || imp->size == 0);
|
||||
assert(!imp->buf || imp->size > 0);
|
||||
assert(imp->fd >= 0);
|
||||
assert(data);
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
|
||||
|
||||
assert(timestamp);
|
||||
|
||||
if (paths == NULL)
|
||||
if (!paths)
|
||||
return false;
|
||||
|
||||
STRV_FOREACH(i, paths) {
|
||||
|
||||
@@ -893,7 +893,7 @@ int parse_timestamp(const char *t, usec_t *usec) {
|
||||
if (last_space != NULL && timezone_is_valid(last_space + 1))
|
||||
tz = last_space + 1;
|
||||
|
||||
if (tz == NULL || endswith_no_case(t, " UTC"))
|
||||
if (!tz || endswith_no_case(t, " UTC"))
|
||||
return parse_timestamp_impl(t, usec, false);
|
||||
|
||||
shared = mmap(NULL, sizeof *shared, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
Reference in New Issue
Block a user