Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1846672iog; Tue, 14 Jun 2022 14:56:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uhIOxNqN4q/84sCxGa+DQvlPcjmhbcfFmueDk4ooNXNpfvGoqMw6GemssHCqaZ0fKvdQA2 X-Received: by 2002:a17:903:2445:b0:164:16dd:a971 with SMTP id l5-20020a170903244500b0016416dda971mr6494283pls.60.1655243791468; Tue, 14 Jun 2022 14:56:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655243791; cv=none; d=google.com; s=arc-20160816; b=STG3O0yJlhqX8g0V9ym+zYBhP/HvZqafRCCXIYdLteWYGv2YKjXKImj2dGLR01NEhY SaTQJs4dd57buGE2Bm6SqTwORcrbwBBHG5NsjaT4v89HMtUSrO8DUgWsxbHS8mhkS4OE 02xcYh8xf53drl97/SnUwY7ydkZ517MAKWBSU9PXUZZfzzJfWwYC5FIFG7wi7FzVcHHl /ztpiyQx/UBvdL2/G3MRQmg+lG3cxaVdnr1TGOVcpoJMQkzZcnRN4SOaReRsDTWiEX47 HcsJJ5yAF7ab2CjsLTuoN0xw5J4WnyKVE+BR575n1yEq1W0vwmtm8jE08fFM7s0sZjoX uOiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dhAM/LQikebwPyrwCB/38lxgJLD4HIC2Qhyl28Iz4Bo=; b=Cahv+X8bRWurDSy+EUMZlIHz9Ygeh3SOhFCb5cPeIIvyTR8g1ha0+7ebUPc4g2jfog S4k24591zQ4s9MEOMbqOVoJZj5pey/udt5h+xGJuVubG8xjFtKqebrS99uRAg5cEqhWt WOeG47PymJUEgoHI5uimVAEyXfHKuHu/+7B1ereJFkOq+IN5yCAehvfC1r0OgBELnvrg 5Jfv4do32/34A90yHrRY9mpdtSoZUT8lUkeCHoxUVyqxOvK9aFQh2XkekGMmleyH6+gi BVoqkpeXuxSryFcQ7ouifAyo94Z+jL2LCMFHb4ytKoAnCam0MXiGetGDY9jXa0pKJfqS +a2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F64WuJyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v64-20020a638943000000b003f5fa8c55e9si8665586pgd.9.2022.06.14.14.56.20; Tue, 14 Jun 2022 14:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F64WuJyf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357291AbiFNUnp (ORCPT + 99 others); Tue, 14 Jun 2022 16:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353110AbiFNUnd (ORCPT ); Tue, 14 Jun 2022 16:43:33 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2E819015 for ; Tue, 14 Jun 2022 13:43:31 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id v1so19357878ejg.13 for ; Tue, 14 Jun 2022 13:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dhAM/LQikebwPyrwCB/38lxgJLD4HIC2Qhyl28Iz4Bo=; b=F64WuJyflipU8IKSxsvGs9EdDSEd6+FrvI2BKcasSS/0ENM051pT66CjnRViaTl7sw Lwp5sxIwuSmAzzBzwSqg/uYy/OkIfMGeDtO7gOick8FFKeDNMqyzE5X77y+6saloeTcw C2sC9S+KjWM86en5pcv/eMsQB6SPZUaenDdoU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dhAM/LQikebwPyrwCB/38lxgJLD4HIC2Qhyl28Iz4Bo=; b=3sGGjzari481ke74m1yJV7tk0Cv/mcVG6vWCvBUXRjpbSUO5XMnoQqs35fSCa/LwdP cQu1IcW2UFSS6j1YEcEHW/toMGbWerEhn4l+WAST12tUsS4UPMG0INboPNSQphE3+cQC ghXhmksw0g+6WLBmpzDjc7uqqHI4bE56jkV2/KQRfFrnswPmrJP3c24MoOEKcBGm23sD 6I0pA/H/ob8v2Kqa2YeMcZ97imTMtteFewgDzDKSXILnexMDvxTDf+Pa5Vh8/BUsyL4F KFJFzSzpk61s6vnT47C27sORf7OZY1dC1p1ynY8KI9SAzkRuBnO61MOLYhYCRP7JTQvs ZbbQ== X-Gm-Message-State: AOAM533qn1emDnkwmYF2dckU/+F0CrPqQZuMI2iV1X9IXGMMsT3o6C3Q bo9/mIg1sCLAewbhM/Ocr5EtnTb/E65XJRnk75k= X-Received: by 2002:a17:907:c22:b0:711:dc95:3996 with SMTP id ga34-20020a1709070c2200b00711dc953996mr5929448ejc.62.1655239409801; Tue, 14 Jun 2022 13:43:29 -0700 (PDT) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com. [209.85.221.47]) by smtp.gmail.com with ESMTPSA id x90-20020a50bae3000000b0042ab87ea713sm7815658ede.22.2022.06.14.13.43.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Jun 2022 13:43:28 -0700 (PDT) Received: by mail-wr1-f47.google.com with SMTP id u8so12727663wrm.13 for ; Tue, 14 Jun 2022 13:43:27 -0700 (PDT) X-Received: by 2002:a5d:47aa:0:b0:218:5ac8:f3a8 with SMTP id 10-20020a5d47aa000000b002185ac8f3a8mr6695741wrb.442.1655239407469; Tue, 14 Jun 2022 13:43:27 -0700 (PDT) MIME-Version: 1.0 References: <20220614144853.3693273-1-glider@google.com> In-Reply-To: From: Linus Torvalds Date: Tue, 14 Jun 2022 13:43:11 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] [RFC] Initialization of unused function parameters To: Alexander Potapenko Cc: Evgenii Stepanov , Kees Cook , Marco Elver , Nathan Chancellor , Nick Desaulniers , Thomas Gleixner , Vitaly Buka , Linux Kernel Mailing List , linux-toolchains Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 14, 2022 at 1:20 PM Alexander Potapenko wrote: > > What about the cases where these uninitialized values are never used > in the callee? I assume that what happens is that when things are inlined, the compiler then sees that there is no actual uninitialized value, and that's ok. But if things aren't inlined, I really hope all compilers already warn about "look, I'm calling this function with an uninitialized argument". IOW, compilers can - and should - obviously take more information into account when they can see it. So no, don't warn for things you can actually see are not used. IOW, you shouldn't warn because of any _syntactic_ issue of it being an argument to a function. We often use inlining as an actually semantically meaningful thing, and the compiler should *not* warn for some theoretical "if this was not inlined, the argument would be used and be uninitialized" case. For an example of this kind of "not really used" thing, I could imagine that some configuration might need a "cookie" model to pair up actions, and you have a void *cookie; start(arg, &cookie); .... end(cookie); kind of situation. But then I could imagine that other configurations don't actually need or use that "end()" thing at all, and would leave "cookie" uninitialized, because the only valid use would be an inline function that is empty, and purely there for those *other* configurations. Again, if the compiler inlines 'end()', and sees that 'cookie' is not actually used, then no complaint is needed - or valid. But if 'cookie()' is an actual real function call, and you don't see the use of it, then it had better warn. No? Linus