Re: [PATCH v2] network: convert virFileLinkPointsTo to return bool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 07, 2023 at 12:09:38PM +0300, Anastasia Belova wrote:
Convert prototype of virFileLinkPointsTo to return bool.
Remove dead checks in virDomainObjListLoadConfig and
virNetworkLoadConfig.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Anastasia Belova <abelova@xxxxxxxxxxxxx>
---
v2: fix logic according to maintainer's answer
src/conf/virdomainobjlist.c | 3 +--
src/conf/virnetworkobj.c    | 3 +--
src/util/virfile.c          | 2 +-
src/util/virfile.h          | 2 +-
4 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index 0bd833257d..bb5807d00b 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -497,8 +497,7 @@ virDomainObjListLoadConfig(virDomainObjList *doms,
    if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL)
        return NULL;

-    if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
-        return NULL;
+    autostart = virFileLinkPointsTo(autostartLink, configFile);

    if (!(dom = virDomainObjListAddLocked(doms, &def, xmlopt, 0, &oldDef)))
        return NULL;
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 20ee8eb58a..d5aa121e20 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -945,8 +945,7 @@ virNetworkLoadConfig(virNetworkObjList *nets,
    if ((autostartLink = virNetworkConfigFile(autostartDir, name)) == NULL)
        return NULL;

-    if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
-        return NULL;
+    autostart = virFileLinkPointsTo(autostartLink, configFile);

    if (!(def = virNetworkDefParse(NULL, configFile, xmlopt, false)))
        return NULL;
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 007b6cf512..f3108e99cf 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1697,7 +1697,7 @@ virFileWriteStr(const char *path, const char *str, mode_t mode)
/* Return nonzero if checkLink and checkDest
 * refer to the same file.  Otherwise, return 0.
 */
-int
+bool
virFileLinkPointsTo(const char *checkLink,
                    const char *checkDest)
{
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 286401e0f5..92400c18fd 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -176,7 +176,7 @@ int virFileReadBufQuiet(const char *file, char *buf, int len)
int virFileWriteStr(const char *path, const char *str, mode_t mode)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;

-int virFileLinkPointsTo(const char *checkLink,
+bool virFileLinkPointsTo(const char *checkLink,
                        const char *checkDest)

Alignment is off here, but I can fix that before pushing.

Reviewed-by: Martin Kletzander <mkletzan@xxxxxxxxxx>

and thanks for the patch.

    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int virFileRelLinkPointsTo(const char *directory,
--
2.30.2
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux