Re: git: 2e2a1c8ecf63 - main - libgssapi: Remove set but unused variable.

From: Benjamin Kaduk <bjkfbsd_at_gmail.com>
Date: Tue, 20 Jun 2023 21:56:11 UTC
On Tue, Jun 20, 2023 at 9:29 AM John Baldwin <jhb@freebsd.org> wrote:

> The branch main has been updated by jhb:
>
> URL:
> https://cgit.FreeBSD.org/src/commit/?id=2e2a1c8ecf639317f40cdb1c2a0c5b9abe990e58
>
> commit 2e2a1c8ecf639317f40cdb1c2a0c5b9abe990e58
> Author:     John Baldwin <jhb@FreeBSD.org>
> AuthorDate: 2023-06-20 16:28:59 +0000
> Commit:     John Baldwin <jhb@FreeBSD.org>
> CommitDate: 2023-06-20 16:28:59 +0000
>
>     libgssapi: Remove set but unused variable.
>
>     Reported by:    GCC
> ---
>  lib/libgssapi/gss_delete_sec_context.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/libgssapi/gss_delete_sec_context.c
> b/lib/libgssapi/gss_delete_sec_context.c
> index 930f51399cce..b64e32c5dc2c 100644
> --- a/lib/libgssapi/gss_delete_sec_context.c
> +++ b/lib/libgssapi/gss_delete_sec_context.c
> @@ -41,7 +41,6 @@ gss_delete_sec_context(OM_uint32 *minor_status,
>      gss_ctx_id_t *context_handle,
>      gss_buffer_t output_token)
>  {
> -       OM_uint32 major_status;
>         struct _gss_context *ctx = (struct _gss_context *) *context_handle;
>
>         if (output_token)
> @@ -54,7 +53,7 @@ gss_delete_sec_context(OM_uint32 *minor_status,
>                  * otherwise fake an empty token.
>                  */
>                 if (ctx->gc_ctx) {
> -                       major_status = ctx->gc_mech->gm_delete_sec_context(
> +                       (void) ctx->gc_mech->gm_delete_sec_context(
>

Looks like gcc was catching a latent bug here -- if we consult the
corresponding heimdal implementation, major_status is initialized to
GSS_S_COMPLETE but this assignment can override it, and the function itself
returns major_status rather than a hardcoded GSS_S_COMPLETE.

-Ben



>                                 minor_status, &ctx->gc_ctx, output_token);
>                 }
>                 free(ctx);
>
>