]> git.ipfire.org Git - telemetry.git/commitdiff
file: Try to make the static analyzer happy
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 20:33:15 +0000 (20:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Oct 2025 20:33:15 +0000 (20:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/file.c

index d18b80ff4762e2874aeaa441b5d666b3c516a3d2..b48ddd6a995465570ad171da2fade11aeb8efd6f 100644 (file)
@@ -64,56 +64,50 @@ static int collecty_file_create(collecty_file** file, collecty_ctx* ctx) {
 }
 
 int collecty_file_open_path(collecty_file** file, collecty_ctx* ctx, const char* path) {
-       collecty_file* self = NULL;
        int r;
 
        // Create a new object
-       r = collecty_file_create(&self, ctx);
+       r = collecty_file_create(file, ctx);
        if (r < 0)
                goto ERROR;
 
        // Open the file
-       self->f = fopen(path, "r");
-       if (!self->f) {
+       (*file)->f = fopen(path, "r");
+       if (!(*file)->f) {
                ERROR(ctx, "Failed to open %s: %m\n", path);
                r = -errno;
                goto ERROR;
        }
 
-       // Return the pointer
-       *file = self;
        return 0;
 
 ERROR:
-       if (self)
-               collecty_file_unref(self);
+       if (*file)
+               collecty_file_unref(*file);
 
        return r;
 }
 
 int collecty_file_open_buffer(collecty_file** file, collecty_ctx* ctx, collecty_buffer* buffer) {
-       collecty_file* self = NULL;
        int r;
 
        // Create a new object
-       r = collecty_file_create(&self, ctx);
+       r = collecty_file_create(file, ctx);
        if (r < 0)
                goto ERROR;
 
        // Open the buffer as a file
-       self->f = collecty_buffer_fopen(buffer, "r");
-       if (!self->f) {
+       (*file)->f = collecty_buffer_fopen(buffer, "r");
+       if (!(*file)->f) {
                r = -errno;
                goto ERROR;
        }
 
-       // Return the pointer
-       *file = self;
        return 0;
 
 ERROR:
-       if (self)
-               collecty_file_unref(self);
+       if (*file)
+               collecty_file_unref(*file);
 
        return r;
 }