return fs ? fs->source : NULL;
}
-/* Used by parser struct libmnt_file ONLY (@source has to be allocated) */
+/*
+ * Used by parser ONLY (@source has to be allocated on error)
+ */
int __mnt_fs_set_source_ptr(struct libmnt_fs *fs, char *source)
{
char *t = NULL, *v = NULL;
assert(fs);
- if (source && !strcmp(source, "none"))
+ if (source && !strcmp(source, "none")) {
+ free(source);
source = NULL;
- if (source && strchr(source, '=')) {
+ } else if (source && strchr(source, '=')) {
if (blkid_parse_tag_string(source, &t, &v) != 0)
return -1;
}
unmangle_string(fs->target);
unmangle_string(fs->vfs_optstr);
unmangle_string(fstype);
-
- if (!strcmp(src, "none")) {
- free(src);
- src = NULL;
- } else
- unmangle_string(src);
+ unmangle_string(src);
if (!strcmp(fs->fs_optstr, "none")) {
free(fs->fs_optstr);
char *v = unmangle(p + 4, &end);
if (!v)
goto enomem;
- if (strcmp(v, "none"))
- __mnt_fs_set_source_ptr(fs, v);
+ __mnt_fs_set_source_ptr(fs, v);
} else if (!fs->target && !strncmp(p, "TARGET=", 7)) {
fs->target = unmangle(p + 7, &end);