]> git.ipfire.org Git - pakfire.git/commitdiff
cgroups: Fix checks for file descriptors
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 May 2023 15:20:07 +0000 (15:20 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 May 2023 06:19:21 +0000 (06:19 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/cgroup.c

index cc6cce94c3dd82cfbdf2e56cd904d586c3d34e7b..22b6ba83ca8e130881eeadf7a5f5125b7884bcdf 100644 (file)
@@ -148,7 +148,7 @@ static void pakfire_cgroup_free(struct pakfire_cgroup* cgroup) {
                pakfire_cgroup_name(cgroup), cgroup);
 
        // Close the file descriptor
-       if (cgroup->fd)
+       if (cgroup->fd > 0)
                close(cgroup->fd);
 
        pakfire_unref(cgroup->pakfire);
@@ -251,7 +251,7 @@ static FILE* pakfire_cgroup_open_file(struct pakfire_cgroup* cgroup,
                goto ERROR;
 
 ERROR:
-       if (fd)
+       if (fd > 0)
                close(fd);
 
        return f;
@@ -637,7 +637,7 @@ int pakfire_cgroup_destroy(struct pakfire_cgroup* cgroup) {
                return r;
 
        // Close the file descriptor
-       if (cgroup->fd) {
+       if (cgroup->fd > 0) {
                close(cgroup->fd);
                cgroup->fd = 0;
        }