Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp579231ybi; Thu, 30 May 2019 03:25:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqweu7DWAWvswWit0I4hj73jsH+Pw3Q0Du1RCw8I49d41Q4sNtFnl7V26N+Swdhc2pBigGHt X-Received: by 2002:a17:902:8c8f:: with SMTP id t15mr3088612plo.87.1559211947896; Thu, 30 May 2019 03:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559211947; cv=none; d=google.com; s=arc-20160816; b=N/9hlpWfjNmaw+yApXdtVF0fkukoKXa5gexJwsRRJ9sCl5luB3lhwUC24BDednetSS D8X8OaUj3cAF0ZuTj//jlI4ljnt3ISktAWLP+dpELHC+au6tSXNFzYVDTWLvQmzda2OU gA79YdU8os1MxpM4kz3j7K/BnCdCiTmIOCd9lyjlMic46ExdFOWuvcwO2DdUQEtG/2QP kMx4ybwRTa+dIa3dw8hgMwmG7I1jbWQCPFAm1ME5yZNSLSziGnij0m83mznUGZeeLbu5 yFNXnUiRIQmfmNnV1g/BTqOunGi98aAEC/oATzIw5i6Rqg2W+0+j4hu/LAoYYlchGY8a CDAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=z7J0Xn39SgXExIYRuvTnrthM0vFkOvqZa1CicHZsTm4=; b=UIWXp0e7mJ1A60V//19rxumyfBdtcz2iJUxt4rECwdWBFPKZvfNGn5BjNjhyVuyUCZ 0q+kNIPmEltCaGiJJLJTQjXE0WXLbACXl+LO30sJdYXXwtwnzoZK4h74NmxeVrUfC8vj +0fsUqFNBEslUgllXj3WDs/sjOWZUAs196M4NJRhfgcZ/3I/2X8IulL4QOxj7HK+21+B i/kmYlhxf5JuJOsjNYvJBj+IyoL9Kd27P5okXlAAfw7N66gyJsNCJhQ5pktTGeNZ6TnN 7YfnoZas3r5OlkuXzRfXfUXI8vzcoT27vWTfIuok0aMpsOMERCY1daJEz2ogzpHF5RqU OGCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nd0DMgUY; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si2356995pjq.98.2019.05.30.03.25.32; Thu, 30 May 2019 03:25:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nd0DMgUY; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727685AbfE3KZb (ORCPT + 99 others); Thu, 30 May 2019 06:25:31 -0400 Received: from mail-it1-f171.google.com ([209.85.166.171]:35607 "EHLO mail-it1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727671AbfE3KZb (ORCPT ); Thu, 30 May 2019 06:25:31 -0400 Received: by mail-it1-f171.google.com with SMTP id u186so8553054ith.0 for ; Thu, 30 May 2019 03:25:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=z7J0Xn39SgXExIYRuvTnrthM0vFkOvqZa1CicHZsTm4=; b=nd0DMgUYn/C3HA5qIBdAT7FzHoYVy/Jr4OHQZOK2I+GDNxbj5/qe7ffEJVugezW/xN +P1wo4wzNYa/fNjdb6rmM3guw4j5eFqxSjUigS5EzBA6XNI7wTjwnnmp+6F1zKFQsPdL o+JgJg1pHFWLWf38kEI/KX67U2P6lEQHWNE4AsctVpHlU1C9tA8yLXD9Y3AFIOtdPv1O YruqSrOYppj06jNE+QWvr0KdfSI72GTvpc1tu+RXwhYXO8rNbEezrswdNIv3DeW1geFX OVbrmAFJFAlL6lMNeCcyi1UwR8FLyXSCWrGfvO1mB9Cxot5rKQfRs5NRKAJL5smlpnLM 2M0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=z7J0Xn39SgXExIYRuvTnrthM0vFkOvqZa1CicHZsTm4=; b=FLGxuuphRXRx1YhhSseXNz0IGYfuI2xkw7wXOWPndtj8bQFAdH6/yi3Q1z66ngwLyV t7gMzduMNVu5/XQ0hbbHh35Wcv5Rd1hwhxFhQjwZjNutOHq/8DmFY7+3p6FbslEf4zqK WRyDQn8EHH1a+O1+A/abxggcIm4ah/oWFNtAN0ZikomatplRb1OVpw93yfrTYQNbqJmB dZwAPwKcUCcEBtuRx0oD9UHXi1PV1oXXPMZf7psiHODfPwWYIEg/KgGXmgQMlnIBK9/B S871OymiO2t64PRPvSdeURrJz7U0j9v1tc0g4zZbsDQIAOdSZW7sQAI7LxZyiUIhaVN4 CVBQ== X-Gm-Message-State: APjAAAX4olWLFmLnBrFsV2UgXPBq01JOsnBgzYYBrq/8nlOauNe/aqjL 2zfL4epvFYBH6gycS45glVB2cLTq4DrjusuDjblmMA== X-Received: by 2002:a02:b01c:: with SMTP id p28mr1799230jah.130.1559211930579; Thu, 30 May 2019 03:25:30 -0700 (PDT) MIME-Version: 1.0 References: <20190529180731.Horde.NGHeOXuCgw23pVdGqjc0fw9@messagerie.si.c-s.fr> In-Reply-To: From: Ard Biesheuvel Date: Thu, 30 May 2019 12:25:06 +0200 Message-ID: Subject: Re: Conding style question regarding configuration To: Pascal Van Leeuwen Cc: Christophe Leroy , "linux-crypto@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, 30 May 2019 at 12:16, Pascal Van Leeuwen wrote: > > > >> Yes. Code and data with static linkage will just be optimized away by > > >> the compiler if the CONFIG_xx option is not enabled, so all you need > > >> to guard are the actual statements, function calls etc. > > >> > > > Ok, makes sense. Then I'll just config out the relevant function bodies > > > and assume the compiler will do the rest ... > > > > > > > No need to config out function bodies when they are static. > > > Well, I got a complaint from someone that my driver updates for adding PCIE > support wouldn't compile properly on a platform without a PCI(E) subsystem. > So I figure I do have to config out the references to PCI specific function > calls to fix that. > > Or are you just referring to bodies of static subfunctions that are no > longer being called? Would the compiler skip those entirely? > The idea is that, by doing something like static int bar; static void foo(void) { bar = 1; } if (IS_ENABLED(CONFIG_FOO)) foo(); the function foo() or the variable bar don't have to be decorated with #ifdefs or anything. The compiler will not complain that they are unused if CONFIG_FOO is not enabled, and the contents of foo() are always visible to the compiler, and so any programming errors will be caught regardless of whether CONFIG_FOO is set.