From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 798203858C1F for ; Tue, 30 May 2023 11:35:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 798203858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-19a427d7b57so1998096fac.2 for ; Tue, 30 May 2023 04:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685446556; x=1688038556; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=yMSTlp/rTpPyJX08H8/bx9lbg3qfxAGLfDZfy53CKqs=; b=zz5r3IFpdRsKteElq+XazKKFssWj9Ieb/GCSallthULcdffN9IH7un3YX3naz9jZOE gKRCIRr1cj8LJ+0iCGZJBFoK9ebAtMemHo8WaWK0bYt2iOKQdJHrTeGJF4hoBcJlnR3U QiA0gI/gbGDJeDtSO7gXsha3PW35Viky1dzC/1qm1jCnRkhBrwGIJ48+dVz0oqwfTOqI kknDFumh/TUmSEkCtOTMsMMOb4WbAa0B8pQuSWVKN0cVobVbYnhy//KNIH3AzwXYXC/a A92jWIWH50WD5bqum7rHGQlDDMPhG9S7hhccGB1pw5ZnIoKp/VhyEnoKUMP2hi/ocdh2 U/kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685446556; x=1688038556; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yMSTlp/rTpPyJX08H8/bx9lbg3qfxAGLfDZfy53CKqs=; b=PTab71WEDKLZVLSGP8wfgquT+1lK7YtspPPwuT7hSsjXtMFK39Etw3Unj2jrgdXrfw z/0MiSpNGSL2vao1LZKvLU9OUwYF6fqKYYfegUNhbZlCbAD7PO+dEbcopPVGM8tS9KDF wYts2bGANTWq5q+2nlJu5u4U+QGlWcbT6tMZe0CEVwaZqmDbrRGiXN4mSMa0JO67OKF+ UkKBWzUlCZzXZjxeF6UdvIEdvZe7NfZKcU+w4/Gzr5iP0XGTSb+jRikDKc0VynID+tt4 M7P0WIubhXAKoJvW2tROsaouXo2cPg4J3Tu2EHqU9PCIbZp6eo0XKFHEiC+9x9c4u+L/ cRpg== X-Gm-Message-State: AC+VfDzUxflyFa8taHoeh2QdXyXUsE9MqGcAVFecJHgsmOSeXCVgiyWF 3AiDFz0bz8O2GWMDNsIfvdeZRg== X-Google-Smtp-Source: ACHHUZ7KU+ep0QUeFfHJjEpW1Wc85aGCUsYPoRZYBgak8REQIquY1ZChVFP/TLwFqc5g24n5SNHtgA== X-Received: by 2002:a05:6870:9550:b0:18e:ab89:5410 with SMTP id v16-20020a056870955000b0018eab895410mr968080oal.46.1685446556730; Tue, 30 May 2023 04:35:56 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:4dd5:b058:c94a:90a7:2c43? ([2804:1b3:a7c1:4dd5:b058:c94a:90a7:2c43]) by smtp.gmail.com with ESMTPSA id x22-20020a056870435600b0018e996a507esm5658296oah.31.2023.05.30.04.35.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 May 2023 04:35:55 -0700 (PDT) Message-ID: <6be23865-d2a2-8a6c-789d-e165906251b5@linaro.org> Date: Tue, 30 May 2023 08:35:53 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: [PATCH v2 3/3] io: Add FORTIFY_SOURCE check for fcntl arguments Content-Language: en-US To: Florian Weimer , Sergey Bugaev Cc: libc-alpha@sourceware.org References: <20230528172013.73111-1-bugaevc@gmail.com> <20230528172013.73111-4-bugaevc@gmail.com> <31457dbb-a805-262f-4b62-be0b40960ca6@linaro.org> <8354c659-cfb0-993a-2764-72a2cd6f6ed4@linaro.org> <87edmyxo4p.fsf@oldenburg.str.redhat.com> <871qiyw3lf.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <871qiyw3lf.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 30/05/23 06:50, Florian Weimer wrote: > * Sergey Bugaev: > >> Hello, >> >> On Tue, May 30, 2023 at 10:41 AM Florian Weimer wrote: >>> The noinline attribute does exactly what it says: it prevents inlining, >>> but it does not prevent inter-procedural analysis. So if a function >>> returns a constrant, the compiler will still use that constant >>> elsewhere. Newer GCC versions support the noipa attribute. If you drop >>> the static, you can use the weak attribute for compatibility with pretty >>> much all GCC versions. >>> >>> But I think using volatile (without noinline for clarity) is fine here. >> >> So do I read this right that you're saying I should just do >> >> static int >> hide_constant (int value) >> { >> volatile int v = value; >> return v; >> } >> >> ? After the yesterday's discussion with Adhemerval, I was thinking of doing >> >> static inline int >> hide_constant (int value) >> { >> asm ("" : "+rm" (value)); >> return value; >> } >> >> This does *not* prevent the whole computation from being optimized out >> if the result is unused (i.e. there's no 'volatile'), but it does >> prevent the compiler from assuming anything about the return value. > > I think both variants are fine in this case. If Adhemerval prefers the > second, please use that. Using the second allows us to provide an internal macro that can consolidate the DO_NOT_OPTIMIZE on benchtests as well.