mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-07 01:31:17 +00:00
btrfs-progs: fix btrfs_get_subvol cut/paste error
in btrfs_get_subvol(), there is a cut and paste error: if (ri->full_path) the_ri->full_path = strdup(ri->full_path); else the_ri->name = NULL; It should be setting the_ri->full_path to NULL here. Do it in a function instead of the cpoy & paste to avoid future errors. Signed-off-by: Eric Sandeen <sandeen@redhat.com>
This commit is contained in:
parent
efbbbc88cb
commit
220e1ccd87
22
btrfs-list.c
22
btrfs-list.c
@ -1515,6 +1515,13 @@ int btrfs_list_subvols_print(int fd, struct btrfs_list_filter_set *filter_set,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *strdup_or_null(const char *s)
|
||||||
|
{
|
||||||
|
if (!s)
|
||||||
|
return NULL;
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
int btrfs_get_subvol(int fd, struct root_info *the_ri)
|
int btrfs_get_subvol(int fd, struct root_info *the_ri)
|
||||||
{
|
{
|
||||||
int ret = 1, rr;
|
int ret = 1, rr;
|
||||||
@ -1537,18 +1544,9 @@ int btrfs_get_subvol(int fd, struct root_info *the_ri)
|
|||||||
}
|
}
|
||||||
if (!comp_entry_with_rootid(the_ri, ri, 0)) {
|
if (!comp_entry_with_rootid(the_ri, ri, 0)) {
|
||||||
memcpy(the_ri, ri, offsetof(struct root_info, path));
|
memcpy(the_ri, ri, offsetof(struct root_info, path));
|
||||||
if (ri->path)
|
the_ri->path = strdup_or_null(ri->path);
|
||||||
the_ri->path = strdup(ri->path);
|
the_ri->name = strdup_or_null(ri->name);
|
||||||
else
|
the_ri->full_path = strdup_or_null(ri->full_path);
|
||||||
the_ri->path = NULL;
|
|
||||||
if (ri->name)
|
|
||||||
the_ri->name = strdup(ri->name);
|
|
||||||
else
|
|
||||||
the_ri->name = NULL;
|
|
||||||
if (ri->full_path)
|
|
||||||
the_ri->full_path = strdup(ri->full_path);
|
|
||||||
else
|
|
||||||
the_ri->name = NULL;
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user