mirror of
https://github.com/systemd/systemd.git
synced 2025-01-27 18:04:05 +03:00
Replace free and reassignment with free_and_replace
This commit is contained in:
parent
5fecf46d76
commit
f9ecfd3bbe
@ -337,9 +337,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
|
||||
d->create = arg_whitelist = true;
|
||||
|
||||
free(d->name);
|
||||
d->name = uuid_value;
|
||||
uuid_value = NULL;
|
||||
free_and_replace(d->name, uuid_value);
|
||||
} else
|
||||
log_warning("Failed to parse luks name switch %s. Ignoring.", value);
|
||||
}
|
||||
|
@ -207,9 +207,7 @@ static int raw_import_maybe_convert_qcow2(RawImport *i) {
|
||||
}
|
||||
|
||||
(void) unlink(i->temp_path);
|
||||
free(i->temp_path);
|
||||
i->temp_path = t;
|
||||
t = NULL;
|
||||
free_and_replace(i->temp_path, t);
|
||||
|
||||
safe_close(i->output_fd);
|
||||
i->output_fd = converted_fd;
|
||||
|
@ -269,9 +269,7 @@ static int raw_pull_maybe_convert_qcow2(RawPull *i) {
|
||||
}
|
||||
|
||||
(void) unlink(i->temp_path);
|
||||
free(i->temp_path);
|
||||
i->temp_path = t;
|
||||
t = NULL;
|
||||
free_and_replace(i->temp_path, t);
|
||||
|
||||
safe_close(i->raw_job->disk_fd);
|
||||
i->raw_job->disk_fd = converted_fd;
|
||||
|
@ -191,9 +191,7 @@ static int parse_options(const uint8_t options[], size_t buflen, uint8_t *overlo
|
||||
if (!ascii_is_valid(string))
|
||||
return -EINVAL;
|
||||
|
||||
free(*error_message);
|
||||
*error_message = string;
|
||||
string = NULL;
|
||||
free_and_replace(*error_message, string);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -393,9 +393,7 @@ static int lease_parse_domain(const uint8_t *option, size_t len, char **ret) {
|
||||
if (dns_name_is_root(normalized))
|
||||
return -EINVAL;
|
||||
|
||||
free(*ret);
|
||||
*ret = normalized;
|
||||
normalized = NULL;
|
||||
free_and_replace(*ret, normalized);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -684,9 +682,7 @@ int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(lease->timezone);
|
||||
lease->timezone = tz;
|
||||
tz = NULL;
|
||||
free_and_replace(lease->timezone, tz);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -786,9 +786,7 @@ static int parse_container_unix_address(sd_bus *b, const char **p, char **guid)
|
||||
if (!machine_name_is_valid(machine))
|
||||
return -EINVAL;
|
||||
|
||||
free(b->machine);
|
||||
b->machine = machine;
|
||||
machine = NULL;
|
||||
free_and_replace(b->machine, machine);
|
||||
} else {
|
||||
b->machine = mfree(b->machine);
|
||||
}
|
||||
|
@ -678,13 +678,9 @@ static int device_update_properties_bufs(sd_device *device) {
|
||||
i++;
|
||||
}
|
||||
|
||||
free(device->properties_nulstr);
|
||||
device->properties_nulstr = buf_nulstr;
|
||||
buf_nulstr = NULL;
|
||||
free_and_replace(device->properties_nulstr, buf_nulstr);
|
||||
device->properties_nulstr_len = nulstr_len;
|
||||
free(device->properties_strv);
|
||||
device->properties_strv = buf_strv;
|
||||
buf_strv = NULL;
|
||||
free_and_replace(device->properties_strv, buf_strv);
|
||||
|
||||
device->properties_buf_outdated = false;
|
||||
|
||||
|
@ -215,9 +215,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->syspath);
|
||||
device->syspath = syspath;
|
||||
syspath = NULL;
|
||||
free_and_replace(device->syspath, syspath);
|
||||
|
||||
device->devpath = devpath;
|
||||
|
||||
@ -347,9 +345,7 @@ int device_set_devtype(sd_device *device, const char *_devtype) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->devtype);
|
||||
device->devtype = devtype;
|
||||
devtype = NULL;
|
||||
free_and_replace(device->devtype, devtype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -394,9 +390,7 @@ int device_set_devname(sd_device *device, const char *_devname) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->devname);
|
||||
device->devname = devname;
|
||||
devname = NULL;
|
||||
free_and_replace(device->devname, devname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -761,9 +755,7 @@ int device_set_subsystem(sd_device *device, const char *_subsystem) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->subsystem);
|
||||
device->subsystem = subsystem;
|
||||
subsystem = NULL;
|
||||
free_and_replace(device->subsystem, subsystem);
|
||||
|
||||
device->subsystem_set = true;
|
||||
|
||||
@ -786,9 +778,7 @@ static int device_set_drivers_subsystem(sd_device *device, const char *_subsyste
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->driver_subsystem);
|
||||
device->driver_subsystem = subsystem;
|
||||
subsystem = NULL;
|
||||
free_and_replace(device->driver_subsystem, subsystem);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -936,9 +926,7 @@ int device_set_driver(sd_device *device, const char *_driver) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
free(device->driver);
|
||||
device->driver = driver;
|
||||
driver = NULL;
|
||||
free_and_replace(device->driver, driver);
|
||||
|
||||
device->driver_set = true;
|
||||
|
||||
@ -1045,9 +1033,7 @@ static int device_set_sysname(sd_device *device) {
|
||||
if (len == 0)
|
||||
sysnum = NULL;
|
||||
|
||||
free(device->sysname);
|
||||
device->sysname = sysname;
|
||||
sysname = NULL;
|
||||
free_and_replace(device->sysname, sysname);
|
||||
|
||||
device->sysnum = sysnum;
|
||||
|
||||
|
@ -201,9 +201,7 @@ static int x11_read_data(Context *c) {
|
||||
p = &c->x11_options;
|
||||
|
||||
if (p) {
|
||||
free(*p);
|
||||
*p = a[2];
|
||||
a[2] = NULL;
|
||||
free_and_replace(*p, a[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,9 +403,7 @@ int config_parse_network_zone(
|
||||
return 0;
|
||||
}
|
||||
|
||||
free(settings->network_zone);
|
||||
settings->network_zone = j;
|
||||
j = NULL;
|
||||
free_and_replace(settings->network_zone, j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -649,13 +649,8 @@ int image_rename(Image *i, const char *new_name) {
|
||||
if (file_attr & FS_IMMUTABLE_FL)
|
||||
(void) chattr_path(new_path, FS_IMMUTABLE_FL, FS_IMMUTABLE_FL);
|
||||
|
||||
free(i->path);
|
||||
i->path = new_path;
|
||||
new_path = NULL;
|
||||
|
||||
free(i->name);
|
||||
i->name = nn;
|
||||
nn = NULL;
|
||||
free_and_replace(i->path, new_path);
|
||||
free_and_replace(i->name, nn);
|
||||
|
||||
STRV_FOREACH(j, settings) {
|
||||
r = rename_auxiliary_file(*j, new_name, ".nspawn");
|
||||
|
@ -75,9 +75,7 @@ static int context_read_data(Context *c) {
|
||||
else if (r < 0)
|
||||
log_warning_errno(r, "Failed to get target of /etc/localtime: %m");
|
||||
|
||||
free(c->zone);
|
||||
c->zone = t;
|
||||
t = NULL;
|
||||
free_and_replace(c->zone, t);
|
||||
|
||||
c->local_rtc = clock_is_localtime(NULL) > 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user