scripts: ipe: polgen: remove redundant close and error exit path
authorColin Ian King <colin.i.king@gmail.com>
Thu, 31 Oct 2024 15:58:57 +0000 (15:58 +0000)
committerFan Wu <wufan@kernel.org>
Tue, 19 Nov 2024 21:57:03 +0000 (13:57 -0800)
Currently if an fopen fails the error exit path is via code that
checks if fp is not null and closes the file, however, fp is null
so this check and close is redundant. Since the only use of the
err exit label is on the fopen check, remove it and replace the
code with a simple return of errno. Also remove variable rc since
it's no longer required.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Fan Wu <wufan@kernel.org>
scripts/ipe/polgen/polgen.c

index c6283b3ff0062661ccf506d8f7799f273635e965..01134cf895d08ed31f92f43abed977dea2583f22 100644 (file)
@@ -61,15 +61,12 @@ out:
 
 static int write_boot_policy(const char *pathname, const char *buf, size_t size)
 {
-       int rc = 0;
        FILE *fd;
        size_t i;
 
        fd = fopen(pathname, "w");
-       if (!fd) {
-               rc = errno;
-               goto err;
-       }
+       if (!fd)
+               return errno;
 
        fprintf(fd, "/* This file is automatically generated.");
        fprintf(fd, " Do not edit. */\n");
@@ -113,11 +110,6 @@ static int write_boot_policy(const char *pathname, const char *buf, size_t size)
        fclose(fd);
 
        return 0;
-
-err:
-       if (fd)
-               fclose(fd);
-       return rc;
 }
 
 int main(int argc, const char *const argv[])
This page took 0.062397 seconds and 4 git commands to generate.