Skip to content

Commit 9080d11

Browse files
ColinIanKingjxwufan
authored andcommitted
scripts: ipe: polgen: remove redundant close and error exit path
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 <[email protected]> Signed-off-by: Fan Wu <[email protected]>
1 parent adc2186 commit 9080d11

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

scripts/ipe/polgen/polgen.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,12 @@ static int policy_to_buffer(const char *pathname, char **buffer, size_t *size)
6161

6262
static int write_boot_policy(const char *pathname, const char *buf, size_t size)
6363
{
64-
int rc = 0;
6564
FILE *fd;
6665
size_t i;
6766

6867
fd = fopen(pathname, "w");
69-
if (!fd) {
70-
rc = errno;
71-
goto err;
72-
}
68+
if (!fd)
69+
return errno;
7370

7471
fprintf(fd, "/* This file is automatically generated.");
7572
fprintf(fd, " Do not edit. */\n");
@@ -113,11 +110,6 @@ static int write_boot_policy(const char *pathname, const char *buf, size_t size)
113110
fclose(fd);
114111

115112
return 0;
116-
117-
err:
118-
if (fd)
119-
fclose(fd);
120-
return rc;
121113
}
122114

123115
int main(int argc, const char *const argv[])

0 commit comments

Comments
 (0)