lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKtyLkHwAJP4U5TQcT5igz+xt79xiUdMxUHitzLZGxNK5jO1Qw@mail.gmail.com>
Date: Thu, 31 Oct 2024 10:11:47 -0700
From: Fan Wu <wufan@...nel.org>
To: Colin Ian King <colin.i.king@...il.com>
Cc: Fan Wu <wufan@...nel.org>, Deven Bowers <deven.desai@...ux.microsoft.com>, 
	Paul Moore <paul@...l-moore.com>, linux-security-module@...r.kernel.org, 
	kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] scripts: ipe: polgen: remove redundant close and
 error exit path

Acked-by: Fan Wu <wufan@...ux.microsoft.com>

Thanks, I will pull this into my tree.

-Fan

On Thu, Oct 31, 2024 at 8:59 AM Colin Ian King <colin.i.king@...il.com> wrote:
>
> 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@...il.com>
> ---
>  scripts/ipe/polgen/polgen.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/ipe/polgen/polgen.c b/scripts/ipe/polgen/polgen.c
> index c6283b3ff006..01134cf895d0 100644
> --- a/scripts/ipe/polgen/polgen.c
> +++ b/scripts/ipe/polgen/polgen.c
> @@ -61,15 +61,12 @@ static int policy_to_buffer(const char *pathname, char **buffer, size_t *size)
>
>  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[])
> --
> 2.39.5
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ