mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
tree-wide: replace explicit NULL checks with their shorter variants
Done by coccinelle/equals-null.cocci
This commit is contained in:
parent
17e3e37c05
commit
4e361acc06
@ -181,7 +181,7 @@ static int get_source_for_fd(RemoteServer *s,
|
||||
return log_warning_errno(r, "Failed to get writer for source %s: %m",
|
||||
name);
|
||||
|
||||
if (s->sources[fd] == NULL) {
|
||||
if (!s->sources[fd]) {
|
||||
s->sources[fd] = source_new(fd, false, name, writer);
|
||||
if (!s->sources[fd]) {
|
||||
writer_unref(writer);
|
||||
|
@ -612,7 +612,7 @@ int serialize_dhcp_option(FILE *f, const char *key, const void *data, size_t siz
|
||||
assert(data);
|
||||
|
||||
hex_buf = hexmem(data, size);
|
||||
if (hex_buf == NULL)
|
||||
if (!hex_buf)
|
||||
return -ENOMEM;
|
||||
|
||||
fprintf(f, "%s=%s\n", key, hex_buf);
|
||||
|
@ -26,7 +26,7 @@ static int message_append_basic(sd_bus_message *m, char type, const void *p, con
|
||||
|
||||
static void *adjust_pointer(const void *p, void *old_base, size_t sz, void *new_base) {
|
||||
|
||||
if (p == NULL)
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
if (old_base == new_base)
|
||||
|
@ -229,7 +229,7 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i,
|
||||
strnull(assigned_buf),
|
||||
strnull(buf), pd_prefix_len);
|
||||
|
||||
if (assigned_link == NULL)
|
||||
if (!assigned_link)
|
||||
continue;
|
||||
|
||||
} else
|
||||
|
@ -356,7 +356,7 @@ static int radv_set_dns(Link *link, Link *uplink) {
|
||||
if (link->network->router_dns) {
|
||||
dns = newdup(struct in6_addr, link->network->router_dns,
|
||||
link->network->n_router_dns);
|
||||
if (dns == NULL)
|
||||
if (!dns)
|
||||
return -ENOMEM;
|
||||
|
||||
n_dns = link->network->n_router_dns;
|
||||
@ -372,7 +372,7 @@ static int radv_set_dns(Link *link, Link *uplink) {
|
||||
goto set_dns;
|
||||
|
||||
if (uplink) {
|
||||
if (uplink->network == NULL) {
|
||||
if (!uplink->network) {
|
||||
log_link_debug(uplink, "Cannot fetch DNS servers as uplink interface is not managed by us");
|
||||
return 0;
|
||||
}
|
||||
@ -411,7 +411,7 @@ static int radv_set_domains(Link *link, Link *uplink) {
|
||||
goto set_domains;
|
||||
|
||||
if (uplink) {
|
||||
if (uplink->network == NULL) {
|
||||
if (!uplink->network) {
|
||||
log_link_debug(uplink, "Cannot fetch DNS search domains as uplink interface is not managed by us");
|
||||
return 0;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ static int get_line(JournalImporter *imp, char **line, size_t *size) {
|
||||
|
||||
c = memchr(imp->buf + start, '\n',
|
||||
imp->filled - start);
|
||||
if (c != NULL)
|
||||
if (c)
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ static int enumerate_print_list(struct udev_enumerate *enumerate) {
|
||||
|
||||
device = udev_device_new_from_syspath(udev_enumerate_get_udev(enumerate),
|
||||
udev_list_entry_get_name(list_entry));
|
||||
if (device != NULL) {
|
||||
if (device) {
|
||||
log_info("device: '%s' (%s)",
|
||||
udev_device_get_syspath(device),
|
||||
udev_device_get_subsystem(device));
|
||||
@ -249,7 +249,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate '%s'", subsystem == NULL ? "<all>" : subsystem);
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_match_subsystem(udev_enumerate, subsystem);
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
@ -258,7 +258,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'net' + duplicated scan + null + zero");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_match_subsystem(udev_enumerate, "net");
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
@ -278,7 +278,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'block'");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_match_subsystem(udev_enumerate,"block");
|
||||
r = udev_enumerate_add_match_is_initialized(udev_enumerate);
|
||||
@ -292,7 +292,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'not block'");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_nomatch_subsystem(udev_enumerate, "block");
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
@ -301,7 +301,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'pci, mem, vc'");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_match_subsystem(udev_enumerate, "pci");
|
||||
udev_enumerate_add_match_subsystem(udev_enumerate, "mem");
|
||||
@ -312,7 +312,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'subsystem'");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_scan_subsystems(udev_enumerate);
|
||||
enumerate_print_list(udev_enumerate);
|
||||
@ -320,7 +320,7 @@ static int test_enumerate(struct udev *udev, const char *subsystem) {
|
||||
|
||||
log_info("enumerate 'property IF_FS_*=filesystem'");
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
if (udev_enumerate == NULL)
|
||||
if (!udev_enumerate)
|
||||
return -1;
|
||||
udev_enumerate_add_match_property(udev_enumerate, "ID_FS*", "filesystem");
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
|
@ -88,7 +88,7 @@ static int print_gaih_addrtuples(const struct gaih_addrtuple *tuples) {
|
||||
if (it->scopeid == 0)
|
||||
goto numerical_index;
|
||||
|
||||
if (if_indextoname(it->scopeid, ifname) == NULL) {
|
||||
if (!if_indextoname(it->scopeid, ifname)) {
|
||||
log_warning_errno(errno, "if_indextoname(%d) failed: %m", it->scopeid);
|
||||
numerical_index:
|
||||
xsprintf(ifname, "%i", it->scopeid);
|
||||
|
@ -2397,7 +2397,7 @@ static int specifier_expansion_from_arg(Item *i) {
|
||||
|
||||
assert(i);
|
||||
|
||||
if (i->argument == NULL)
|
||||
if (!i->argument)
|
||||
return 0;
|
||||
|
||||
switch (i->type) {
|
||||
|
@ -381,7 +381,7 @@ static int disk_identify(int fd,
|
||||
}
|
||||
|
||||
out:
|
||||
if (out_is_packet_device != NULL)
|
||||
if (out_is_packet_device)
|
||||
*out_is_packet_device = is_packet_device;
|
||||
return ret;
|
||||
}
|
||||
@ -432,7 +432,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
node = argv[optind];
|
||||
if (node == NULL) {
|
||||
if (!node) {
|
||||
log_error("no node specified");
|
||||
return 1;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ static bool is_mounted(const char *device) {
|
||||
return false;
|
||||
|
||||
fp = fopen("/proc/self/mountinfo", "re");
|
||||
if (fp == NULL)
|
||||
if (!fp)
|
||||
return false;
|
||||
while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
|
||||
if (makedev(maj, min) == statbuf.st_rdev) {
|
||||
@ -1026,7 +1026,7 @@ work:
|
||||
if (cd_media_hddvd_rw)
|
||||
printf("ID_CDROM_MEDIA_HDDVD_RW=1\n");
|
||||
|
||||
if (cd_media_state != NULL)
|
||||
if (cd_media_state)
|
||||
printf("ID_CDROM_MEDIA_STATE=%s\n", cd_media_state);
|
||||
if (cd_media_session_next > 0)
|
||||
printf("ID_CDROM_MEDIA_SESSION_NEXT=%u\n", cd_media_session_next);
|
||||
|
@ -157,7 +157,7 @@ static int get_file_options(const char *vendor, const char *model,
|
||||
int retval = 0;
|
||||
|
||||
f = fopen(config_file, "re");
|
||||
if (f == NULL) {
|
||||
if (!f) {
|
||||
if (errno == ENOENT)
|
||||
return 1;
|
||||
else {
|
||||
@ -181,7 +181,7 @@ static int get_file_options(const char *vendor, const char *model,
|
||||
vendor_in = model_in = options_in = NULL;
|
||||
|
||||
buf = fgets(buffer, MAX_BUFFER_LEN, f);
|
||||
if (buf == NULL)
|
||||
if (!buf)
|
||||
break;
|
||||
lineno++;
|
||||
if (buf[strlen(buffer) - 1] != '\n') {
|
||||
@ -239,7 +239,7 @@ static int get_file_options(const char *vendor, const char *model,
|
||||
break;
|
||||
}
|
||||
if (vendor == NULL) {
|
||||
if (vendor_in == NULL)
|
||||
if (!vendor_in)
|
||||
break;
|
||||
} else if (vendor_in &&
|
||||
startswith(vendor, vendor_in) &&
|
||||
|
@ -524,7 +524,7 @@ static int check_fill_0x83_id(struct scsi_id_device *dev_scsi,
|
||||
|
||||
if (id_search->id_type == SCSI_ID_NAA && wwn != NULL) {
|
||||
strncpy(wwn, &serial[s], 16);
|
||||
if (wwn_vendor_extension != NULL)
|
||||
if (wwn_vendor_extension)
|
||||
strncpy(wwn_vendor_extension, &serial[s + 16], 16);
|
||||
}
|
||||
|
||||
@ -729,7 +729,7 @@ static int do_scsi_page80_inquiry(struct scsi_id_device *dev_scsi, int fd,
|
||||
* specific type where we prepend '0' + vendor + model.
|
||||
*/
|
||||
len = buf[3];
|
||||
if (serial != NULL) {
|
||||
if (serial) {
|
||||
serial[0] = 'S';
|
||||
ser_ind = prepend_vendor_model(dev_scsi, &serial[1]);
|
||||
if (ser_ind < 0)
|
||||
@ -738,7 +738,7 @@ static int do_scsi_page80_inquiry(struct scsi_id_device *dev_scsi, int fd,
|
||||
for (i = 4; i < len + 4; i++, ser_ind++)
|
||||
serial[ser_ind] = buf[i];
|
||||
}
|
||||
if (serial_short != NULL) {
|
||||
if (serial_short) {
|
||||
memcpy(serial_short, &buf[4], len);
|
||||
serial_short[len] = '\0';
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ static int dev_if_packed_info(sd_device *dev, char *ifs_str, size_t len) {
|
||||
desc->bInterfaceProtocol) != 7)
|
||||
continue;
|
||||
|
||||
if (strstr(ifs_str, if_str) != NULL)
|
||||
if (strstr(ifs_str, if_str))
|
||||
continue;
|
||||
|
||||
memcpy(&ifs_str[strpos], if_str, 8),
|
||||
|
@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
device = argv[optind];
|
||||
if (device == NULL)
|
||||
if (!device)
|
||||
return 2;
|
||||
|
||||
fd = open(device, O_RDONLY);
|
||||
|
Loading…
Reference in New Issue
Block a user