From 527b7a421ff3927d4f3f170b1b143452e88ae1dc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 6 Apr 2015 20:11:41 +0200 Subject: util: rework cunescape(), improve error handling Change cunescape() to return a normal error code, so that we can distuingish OOM errors from parse errors. This also adds a flags parameter to control whether "relaxed" or normal parsing shall be done. If set no parse failures are generated, and the only reason why cunescape() can fail is OOM. --- src/core/mount.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/core/mount.c') diff --git a/src/core/mount.c b/src/core/mount.c index 53594cd40b..c4aa810d05 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1579,7 +1579,7 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { r = 0; for (;;) { const char *device, *path, *options, *fstype; - _cleanup_free_ const char *d = NULL, *p = NULL; + _cleanup_free_ char *d = NULL, *p = NULL; struct libmnt_fs *fs; int k; @@ -1594,12 +1594,10 @@ static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { options = mnt_fs_get_options(fs); fstype = mnt_fs_get_fstype(fs); - d = cunescape(device); - if (!d) + if (cunescape(device, UNESCAPE_RELAX, &d) < 0) return log_oom(); - p = cunescape(path); - if (!p) + if (cunescape(path, UNESCAPE_RELAX, &p) < 0) return log_oom(); (void) device_found_node(m, d, true, DEVICE_FOUND_MOUNT, set_flags); -- cgit v1.2.3-54-g00ecf