[libvirt] [PATCH 0/2] Fix some nits

Martin Kletzander (2): util: Don't lie in virFileGetMount*Subtree's docstrings qemu: Remove /dev mount info properly src/qemu/qemu_domain.c | 9 ++++----- src/util/virfile.c | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) -- 2.11.0

The resulting function virFileGetMountSubtreeImpl() just uses virStringSortRevCompare or virStringSortCompare which uses strcmp(). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virfile.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 718dcc4a98a6..99157be162b4 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1965,7 +1965,7 @@ virFileGetMountSubtreeImpl(const char *mtabpath ATTRIBUTE_UNUSED, * @nmountsret: filled with number of matching mounts, not counting NULL terminator * * Return the list of mounts from @mtabpath which contain - * the path @prefix, sorted from shortest to longest path. + * the path @prefix, sorted alphabetically. * * The @mountsret array will be NULL terminated and should * be freed with virStringListFree @@ -1988,8 +1988,7 @@ int virFileGetMountSubtree(const char *mtabpath, * @nmountsret: filled with number of matching mounts, not counting NULL terminator * * Return the list of mounts from @mtabpath which contain - * the path @prefix, sorted from longest to shortest path. - * ie opposite order to which they appear in @mtabpath + * the path @prefix, reverse-sorted alphabetically. * * The @mountsret array will be NULL terminated and should * be freed with virStringListFree -- 2.11.0

Just so it doesn't bite us in the future, even though it's unlikely. And fix the comment above it as well. Commit e08ee7cd3405 took the info from the function it's calling, but that was lie itself in the first place. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_domain.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 55ccd16d25e0..495d86a011a6 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -226,11 +226,10 @@ qemuDomainGetPreservedMounts(virQEMUDriverPtr driver, return 0; } - /* Okay, this is crazy. But virFileGetMountSubtree() fetched us all the - * mount points under /dev including /dev itself. Fortunately, the paths - * are sorted based on their length so we skip the first one (/dev) as it - * is handled differently anyway. */ - VIR_DELETE_ELEMENT(mounts, 0, nmounts); + /* Since the list is sorted and only has paths that start with /dev, the + * /dev itself can only be first. */ + if (STREQ(mounts[0], "/dev")) + VIR_DELETE_ELEMENT(mounts, 0, nmounts); if (VIR_ALLOC_N(paths, nmounts) < 0) goto error; -- 2.11.0

On 01/05/2017 04:30 PM, Martin Kletzander wrote:
Martin Kletzander (2): util: Don't lie in virFileGetMount*Subtree's docstrings qemu: Remove /dev mount info properly
src/qemu/qemu_domain.c | 9 ++++----- src/util/virfile.c | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-)
ACK to both. Michal
participants (2)
-
Martin Kletzander
-
Michal Privoznik