public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael Brown" <mcb30@ipxe.org>
To: devel@edk2.groups.io, n.jayaprakash@intel.com
Cc: Rebecca Cran <rebecca@bsdio.com>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Kloper Dimitry <dimitry.kloper@intel.com>
Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable
Date: Wed, 26 Jul 2023 11:33:09 +0000	[thread overview]
Message-ID: <0102018991f96c6e-5ed4f81b-9c5b-4163-8206-afdb39b05d24-000000@eu-west-1.amazonses.com> (raw)
In-Reply-To: <20230725160756.1869-2-n.jayaprakash@intel.com>

On 25/07/2023 17:07, Jayaprakash, N wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4506
> 
> res_init() is called from different places in sockets library. It depends
> on global _res variable containing a state.
> 
> The problem is that if __BIND_RES_TEXT macro is not defined, _res is not
> initialized. Depending on compiler and build optimization this can fill the
> variable with garbage that is later used by res_init().
> 
> Fix is trivial - explicitly initialize _res.
>   
>   struct __res_state _res
> -# if defined(__BIND_RES_TEXT)
> +#if defined(__BIND_RES_TEXT)
>       = { RES_TIMEOUT, }  /* Motorola, et al. */
> -# endif
> +#endif
> +    = {0}
> +#endif
>       ;

NAK.  This is very wrong.

Firstly, your patch introduces unnecessary whitespace changes and so is 
unnecessarily cumbersome to review.

Secondly, the patch creates an invalid "#if ... #endif ... #endif" 
combination.  I suspect that you meant to use "#else" in the middle.

Thirdly, and most importantly, the whole patch is entirely unnecessary. 
As a variable with static storage duration, if no explicit initializer 
is provided then the C language guarantees that the value will be 
initialized to zero anyway.

Thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107268): https://edk2.groups.io/g/devel/message/107268
Mute This Topic: https://groups.io/mt/100353380/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      reply	other threads:[~2023-07-26 11:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 16:07 [edk2-devel] [edk2-libc Patch 0/1] edk2-libc/StdLib: Fix uninitialized global variable Jayaprakash, N
2023-07-25 16:07 ` [edk2-devel] [edk2-libc Patch 1/1] " Jayaprakash, N
2023-07-26 11:33   ` Michael Brown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0102018991f96c6e-5ed4f81b-9c5b-4163-8206-afdb39b05d24-000000@eu-west-1.amazonses.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox