]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Remember if we opened the fp referring to the file we're processing
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 27 Mar 2025 00:49:07 +0000 (18:49 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Thu, 27 Mar 2025 02:27:43 +0000 (20:27 -0600)
Mostly to quiet clang analyzer

src/bin/unit_test_attribute.c

index 3ebac5f0f8c95f39f5da70734d908cd1a97eb06f..30e36efd657aa1e6b391d53210f4d2381bca760d 100644 (file)
@@ -3439,6 +3439,7 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, command_config_t const
        ssize_t         data_used = 0;                  /* How much data the last command wrote */
        static char     path[PATH_MAX] = "";
        command_line_range_t    *lr = NULL;
+       bool            opened_fp = false;
 
        command_file_ctx_t      *cc;
 
@@ -3465,6 +3466,7 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, command_config_t const
                }
 
                filename = path;
+               opened_fp = true;
        }
 
        if (lines && !fr_dlist_empty(lines)) lr = fr_dlist_head(lines);
@@ -3578,7 +3580,8 @@ static int process_file(bool *exit_now, TALLOC_CTX *ctx, command_config_t const
        }
 
 finish:
-       if (fp && (fp != stdin)) fclose(fp);
+       /* The explicit check is to quiet clang_analyzer */
+       if (opened_fp) fclose(fp);
 
        /*
         *      Free any residual resources we loaded.