From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 913577803DF for ; Wed, 26 Jul 2023 11:33:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=B4YWPBmSGx9Z5NRpo4gM5YUP+ZQi/yQQmNFUix6mu8U=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:Message-ID:Date:MIME-Version:User-Agent:To:Cc:References:From:Subject:In-Reply-To:X-Spam-Status:X-Spam-Checker-Version:Feedback-ID:X-SES-Outgoing:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690371193; v=1; b=oclVjQeviAGDrRpRUeq15nPZU5e1KU3ZWXnkSrMxoIeo/W/ePrRPqfMnvwTIdjxM1/lbljYO JuZ2AQJdCyNY7kSaf/UOVU7/luJmWILC7A/O98f56dg1ki/Xb0YccIofIapOsXBbzdjGhAW4cbR gspQ5lhQw2ly5ydrATFleMKc= X-Received: by 127.0.0.2 with SMTP id pSOfYY7687511x6kdpxPLinh; Wed, 26 Jul 2023 04:33:13 -0700 X-Received: from a7-12.smtp-out.eu-west-1.amazonses.com (a7-12.smtp-out.eu-west-1.amazonses.com [54.240.7.12]) by mx.groups.io with SMTP id smtpd.web10.8801.1690371192022016717 for ; Wed, 26 Jul 2023 04:33:12 -0700 Message-ID: <0102018991f96c6e-5ed4f81b-9c5b-4163-8206-afdb39b05d24-000000@eu-west-1.amazonses.com> Date: Wed, 26 Jul 2023 11:33:09 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 To: devel@edk2.groups.io, n.jayaprakash@intel.com Cc: Rebecca Cran , Michael D Kinney , Kloper Dimitry References: <20230725160756.1869-1-n.jayaprakash@intel.com> <20230725160756.1869-2-n.jayaprakash@intel.com> From: "Michael Brown" Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc/StdLib: Fix uninitialized global variable In-Reply-To: <20230725160756.1869-2-n.jayaprakash@intel.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_DBL_BLOCKED_OPENDNS,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on blyat.fensystems.co.uk Feedback-ID: 1.eu-west-1.fspj4M/5bzJ9NLRzJP0PaxRwxrpZqiDQJ1IF94CF2TA=:AmazonSES X-SES-Outgoing: 2023.07.26-54.240.7.12 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mcb30@ipxe.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XpTpj45f4grYOi252R5gAa7Ax7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=oclVjQev; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 25/07/2023 17:07, Jayaprakash, N wrote: > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4506 >=20 > res_init() is called from different places in sockets library. It depends > on global _res variable containing a state. >=20 > 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 t= he > variable with garbage that is later used by res_init(). >=20 > Fix is trivial - explicitly initialize _res. > =20 > struct __res_state _res > -# if defined(__BIND_RES_TEXT) > +#if defined(__BIND_RES_TEXT) > =3D { RES_TIMEOUT, } /* Motorola, et al. */ > -# endif > +#endif > + =3D {0} > +#endif > ; NAK. This is very wrong. Firstly, your patch introduces unnecessary whitespace changes and so is=20 unnecessarily cumbersome to review. Secondly, the patch creates an invalid "#if ... #endif ... #endif"=20 combination. I suspect that you meant to use "#else" in the middle. Thirdly, and most importantly, the whole patch is entirely unnecessary.=20 As a variable with static storage duration, if no explicit initializer=20 is provided then the C language guarantees that the value will be=20 initialized to zero anyway. Thanks, Michael -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-