1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

mount: use free_and_strdup() over plain strdup()

Let's initialize two fields with free_and_strdup() rather than directly
with strdup(). The fields should not be initialized so far, but it's
still nicer to be prepared for futzre code changes and always free
what's stored before replacing it.
This commit is contained in:
Lennart Poettering 2018-11-28 14:40:56 +01:00
parent 60b8c203f8
commit e10fe04266

View File

@ -1475,13 +1475,13 @@ static int mount_setup_new_unit(
if (r < 0) if (r < 0)
return r; return r;
u->source_path = strdup("/proc/self/mountinfo"); r = free_and_strdup(&u->source_path, "/proc/self/mountinfo");
MOUNT(u)->where = strdup(where); if (r < 0)
if (!u->source_path || !MOUNT(u)->where) return r;
return -ENOMEM;
/* Make sure to initialize those fields before mount_is_extrinsic(). */ r = free_and_strdup(&MOUNT(u)->where, where);
MOUNT(u)->from_proc_self_mountinfo = true; if (r < 0)
return r;
r = update_parameters_proc_self_mount_info(MOUNT(u), what, options, fstype); r = update_parameters_proc_self_mount_info(MOUNT(u), what, options, fstype);
if (r < 0) if (r < 0)