From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nXWB1-0007sg-Ao for mharc-grub-devel@gnu.org; Thu, 24 Mar 2022 18:43:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXWAz-0007rX-Pa for grub-devel@gnu.org; Thu, 24 Mar 2022 18:43:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXWAw-0001Ua-Eb for grub-devel@gnu.org; Thu, 24 Mar 2022 18:43:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648161804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4qtGK6+CL6bat96m1Gxh/NxQGTFr9cbDZLjwFPENIDs=; b=JDprxx9Oi1iqIAqhS8Azy8isCIk5sXSiP0XXSe6jjTkIFw3WT7PGRO4slRq7tdgZiStvb8 v782wmjywWt3Udd6Lwv/9PzTkUhmxIeIFGXUbq6nrCH/PF/VNqCu/Gw6sbq3eNHUbXqPda wCv4KmozVshZb9xqqNOSn2AtrDm1UDM= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-A9idCnHCOY2WEDtTMa544A-1; Thu, 24 Mar 2022 18:43:21 -0400 X-MC-Unique: A9idCnHCOY2WEDtTMa544A-1 Received: by mail-qv1-f70.google.com with SMTP id 33-20020a0c8024000000b0043d17ffb0bdso4671017qva.18 for ; Thu, 24 Mar 2022 15:43:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=4qtGK6+CL6bat96m1Gxh/NxQGTFr9cbDZLjwFPENIDs=; b=L7WTB6j0Mb+zD+YY/dVvYs2qVOLrwCfqy9c0NqvKzNf8a413YAmT4ZK3IVHPT22FDJ DCF0c86mV83LBLa81cigshuaVWkRYsgws1vg+95Und8Ivab8fNKJLQ2ClUr3Nf4jGwH0 mHzHKJgp2/IX5NR8hejN82MqJ+nV8XWbfwJh8k+tn40BjcQulzrq07RAeQuNVkSQLut+ L6sFl5ZyhIaqNW0o9OoHjW9VIsQs91BVCm6/xN6IAahVrx18VGEuflmJav4U7WRgRUz6 yOwt7yFqOEFHCIy8aQHH7PZZe+YWcXHcuorUj4FsAyTkWcogyElzpzURxlWBeKYl0xc/ i6YA== X-Gm-Message-State: AOAM531O+PMjkv9j6o6dv4ylRnMMTso3KzkJN05Ds+10FAB8SkkotxAc x5kPY+P3q3NlnHd1N30x+5TMKIRQTrqZJc2cR5Lhs9RRrN4TDPpUVkAH4QQjr51SFCkdhH3rQrF 6B4baX0jVJVQ= X-Received: by 2002:ac8:5984:0:b0:2e1:e812:f42 with SMTP id e4-20020ac85984000000b002e1e8120f42mr6504547qte.609.1648161800249; Thu, 24 Mar 2022 15:43:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx93z+V/sKf+4IATr9DatBzOCkp+0oO7rvfUFKZTr51e3N61NKP45YYner+++d9c9R8hZdPFA== X-Received: by 2002:ac8:5984:0:b0:2e1:e812:f42 with SMTP id e4-20020ac85984000000b002e1e8120f42mr6504517qte.609.1648161799676; Thu, 24 Mar 2022 15:43:19 -0700 (PDT) Received: from localhost ([2601:184:4181:74c0:862e:5809:ed9e:e10e]) by smtp.gmail.com with ESMTPSA id s16-20020ac85cd0000000b002e1ed82f1e5sm3759571qta.75.2022.03.24.15.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 15:43:19 -0700 (PDT) From: Robbie Harwood To: Peter Jones , grub-devel@gnu.org Cc: daniel.kiper@oracle.com Subject: Re: [PATCH] misc: Make grub_min() and grub_max() more resilient. In-Reply-To: <20220324200638.3388997-1-pjones@redhat.com> References: <20220324200638.3388997-1-pjones@redhat.com> Date: Thu, 24 Mar 2022 18:43:16 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=170.10.129.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 22:43:30 -0000 --=-=-= Content-Type: text/plain Peter Jones writes: > grub_min(a,b) and grub_max(a,b) use a relatively naive implementation > which leads to several problems: > - they evaluate their parameters more than once > - the naive way to address this, to declare temporary variables in a > statement-expression, isn't resilient against nested uses, because > MIN(a,MIN(b,c)) results in the temporary variables being declared in > two nested scopes, which may result in a build warning depending on > your build options. > > This patch changes our implementation to use a statement-expression > inside a helper macro, and creates the symbols for the temporary > variables with __COUNTER__ (A GNU C cpp extension) and token pasting to > create uniquely named internal variables. > > Signed-off-by: Peter Jones Reviewed-by: Robbie Harwood Be well, --Robbie --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJIBAEBCgAyFiEEA5qc6hnelQjDaHWqJTL5F2qVpEIFAmI89AQUHHJoYXJ3b29k QHJlZGhhdC5jb20ACgkQJTL5F2qVpEJuoQ/9ETYqACcHTNlMWoUOJgtO6RlPKYCG bOntzjz9oWHl9FSYvqnC2j5QyUtGOeRAUu8IriqM/N/xd8b226NAc0l0UL1ZO+mj OR1SLiZHEbgAMW+Aid9RuC9n9bQ2tCTSskMYt8hAHLEhTpbsmbxKuUNpKHivItLw nTbYY+KNxf20VHhZ+6sesMNWbI8UJI6mH24uBl//UxOnCbWx/PZCCRnwx5Vw8ZtP BnKA93qlvC91ZIZABnrJA5Y69sbfvEC4070LJ/zL2PIuzwUlM5hD82GsuVGfh+ii OBsaBy4TcNpj3mSzhLWlNrSwbt63jGKEsbD9xtTqnrfzog79J20ieqlOC69R4vHh DfTsgE8m3yQK248646OYyt0PFTC2uMbDbmQkHIySU/GLljhc8FThMHxi+OIUGM/y 9LTUJ0a8gg9xE84l1rRM64qmJW3BBVRS3ycnzwvNjpEUxxqGBb8/OFKTStW95And E4A3JENm4qn+rYzmhKqhCHifkk1om9BFvIncnXJkHvkhdLMFnGrhkyjJl+iIlIrQ 8iwA8cz15Uznlqh9oCH70vxsKAxpypgi7cyi9DfbCJS0O/OPNipJmvv/TjNTfjlx iTVT2hqLf2oqSWg8sAMEf/3dZXBzi4VApWaqgTELCBJ19Tkwptc9Oqt30zhIXjW8 gLSrodskyTiXM7c= =NEJA -----END PGP SIGNATURE----- --=-=-=--