Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5184016ybi; Tue, 28 May 2019 08:52:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoAWZy/D/35Xk2mIyK9SLPWBrOmWv27nEv4UjA0yBBgsEJqN+KO+wOUcJtN839CVSi5/IE X-Received: by 2002:a17:902:3103:: with SMTP id w3mr60466360plb.329.1559058757642; Tue, 28 May 2019 08:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559058757; cv=none; d=google.com; s=arc-20160816; b=Vnu/SVFbtYHTsxwHY4w3N5JccFrg+pGHxuGe8Cj//fwF7ZpVXzNl2/rDEBg5Y//XOm tykCx5lXVSDVL9goaa4lRik4HtPN8vxnx8t6gSH0AFBknpfwSU+u1M65mujWCzUPKhY7 cF3XEgy3yiTmn93ik9v8o5AN3eUTawR/tyMH/2PIVNS8MKAnHHWnT6cFTPhCEfqSh7HC zF6bZ+VA4TeDBuSZZAiHOk4xBXq7LKs/2VpBGJPP2zSqvSvQlfUyEsn2XRZOvKiei5x+ +uljUJFOgtNqJG1AbnUCs8tI9ApjD7lIuZywFkzoko3FkyvJ/dH2JPOpHfFCBvXDNPxW UeWA== 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=l4yZqEsgyzcQICKr9VMFfWmGt5kwBH51mivnqik7jS4=; b=GiyWgpTbxF2T2yn7eYaLOI1TcWcgPJvTbhPEdHH2XKGmOqxF4kzo5x5gRQhHYRZexf sFI2WDNv71mF9viqCgSIJnMUHve0iBKccdQ16ChNtlxG5q9MYJ+0lRA/qG0Or+/k4GET /DhyJfgTzaVEKeYl15+9/9n/omloVDvehozXFUxlDzJQg6owjjMcKZIPdDbIJoZl/Sm3 fYuzVjg/MIqMlp16/nG1rwTFtd4Ri6Gbsz2wteQ+dUvfFTXO8HIogLX/ox7qkwT0XhUr EEcS9iz4Xxrx6FwVD2SzVdXtudkmGTCeix9ZKvaxTRfi+DcUsmwrBv0okD6uBbhpjljh W/yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IVSq5q/I"; 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 h20si19607305pgj.113.2019.05.28.08.52.22; Tue, 28 May 2019 08:52:37 -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="IVSq5q/I"; 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 S1726638AbfE1PwF (ORCPT + 99 others); Tue, 28 May 2019 11:52:05 -0400 Received: from mail-it1-f178.google.com ([209.85.166.178]:50980 "EHLO mail-it1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfE1PwF (ORCPT ); Tue, 28 May 2019 11:52:05 -0400 Received: by mail-it1-f178.google.com with SMTP id a186so5218235itg.0 for ; Tue, 28 May 2019 08:52:04 -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=l4yZqEsgyzcQICKr9VMFfWmGt5kwBH51mivnqik7jS4=; b=IVSq5q/Iyfix9F5OYiLcWLkI/RnjE5kJZ5qHRulDPJKpyCilWcJopPmLFwKRq3IHRO HriE6TbwrLKLjWYLJ9YgVB6Kz/iU+NJZNoZpi6VSY8V0A3A3Dix2nNb/NSoZGZmYvu/q W27zCBc4+itybx1zmb8R3dWCJYhtL+rTi8omqqTYWebEoPS2ugIR/6t/I7K/b4FIFTVW JwWCBXVuhOqzizYSvMAQ+1QdD7ejFfalSl2PAsxxxZ7ijoaE8cZzyfpJDMFfucryFrGl 9BhLL0CFSLA96II+Ub4jtVKFFTXY9DsMyN0w+6zhcoF0OlMqyahiYuSDA7S6d/Bca670 pJHw== 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=l4yZqEsgyzcQICKr9VMFfWmGt5kwBH51mivnqik7jS4=; b=qWHPMya+n1BxbfS2xVnnxcpGX4tIhnuhPCabKsqa/EZluKPCBQymCPEiCAecGE01as pGZ7YYCNMth8wyhC6cVz3bj4lt2Lqcf8Mmm9aTkYKBKSwZSIHM2n0/57ZQTaCoNA9mhC Fv3D+lClwh0MjHBVzS/OeObaAt+qrB/cfsSpF7IZ72levC5Fa8hf5DoMvXLSoPgAU7tO tturOGAo1pEANF0U1zvLSVo74XPI1W7lRPvfz5pelUHGzVOmnp5aYz+QgVFtZdssK5+8 AlcRGILGzSF0xT8+qLwZhviaMXJpU7YQFxmtzVCeKp+3Mp2Ki/6QxCW6A7tyfku/Ntlw hdwQ== X-Gm-Message-State: APjAAAUKOHmmQflr4cABVAlRjd6OZAOivbfxSVMtQ6RdOAk/ipeo9due ek2anZp1n8gN12EWsPe0moXg2i5hJXtzH58FgXUT4B1osyk= X-Received: by 2002:a02:ce37:: with SMTP id v23mr10909803jar.2.1559058723933; Tue, 28 May 2019 08:52:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Tue, 28 May 2019 17:51:51 +0200 Message-ID: Subject: Re: Conding style question regarding configuration To: Pascal Van Leeuwen Cc: "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 Tue, 28 May 2019 at 17:47, Pascal Van Leeuwen wrote: > > Hi, > > Quick question regarding how to configure out code depending on a CONFIG_xxx > switch. As far as I understood so far, the proper way to do this is not by > doing an #ifdef but by using a regular if with IS_ENABLED like so: > > if (IS_ENABLED(CONFIG_PCI)) { > } > > Such that the compiler can still check the code even if the switch is > disabled. Now that all works fine and dandy for statements within a > function, but how do you configure out, say, global variable definitions > referencing types that are tied to this configuration switch? Or should > I just leave them in, depending on the compiler to optimize them away? > > Obviously the code depends on those variables again, so if it's not > done consistently the compiler will complain somehow if the switch is not > defined ... > > Also, with if (IS_ENABLED()) I cannot remove my function prototypes, > just the function body. Is that really how it's supposed to be done? > 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.