Received: by 10.223.185.116 with SMTP id b49csp1144933wrg; Tue, 20 Feb 2018 14:13:44 -0800 (PST) X-Google-Smtp-Source: AH8x226i7ea26IYcGZDInJdDZB+yNJnm/HN0azittSQRFZRDgbq8AdzojF866WIG/7KgSQxyJfZ8 X-Received: by 10.98.159.209 with SMTP id v78mr1047173pfk.49.1519164824774; Tue, 20 Feb 2018 14:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519164824; cv=none; d=google.com; s=arc-20160816; b=TWJwiWuvzy8NStcphtBek0DCji4A3Otih99MdL4xg7AuqmY0nR2lNPHuZPvXsGzg02 nKVX1G4FsNag65ZnlLC/g2sfzfmGkiwg6x6+rB2OW+9wMLDjgGxSgAIFxUfgynEqKxQw JdwvyqbhpDNzZ8IMpkOBk46AfSer7LRqJLhQgKrRTZ/jIdJV1slWRFSi01jeYoAIj7dY aEo5D1ie79e86Z+no1VfPTZ8TXeI1odl/q1jIw1CVW/YxELMz9mJrcO8/iXkUbB9KErm QLA1Mq6EY38Awp/6jxzHLUH5GWyPOj9SD5W45ZvAtLOfvTf8qzcDk63a1VL9DRAiyD1S IPog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=GzNKoXNYAfSDtuIWhVyPJD+N58bR7MHsnBWg9jV3OlE=; b=P2AVWObzuBTETBRaimKWy2uhJPIpsguPqjzRvp0huAwg89ifSEcp8LenKgFjNg0J21 gsZVLimkLgIHpbF6/A68YjY4Ce52R+YypDXKvbzxiJx73e7qmeiPybH1yiqNIETS4S1C bB4y02xYiu+ptnvmzfhJaHmeGmr8E/CwiFezTZzI1RY7mKpYSynJT0rt63kgXc0RpEnU eN9YURKAKhxgRC/h6Aksrwf67DPE/JOdV7Cx2gkPUYu1G+62Jd+w+W/u52pSwMi2KJhu XaxB+mJDl20sSWDd7bU/AFezNxFJQejxn4kahfQ330DZRYBdVu6rVrFfCsXS7v3xFMH1 wxww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si195513pfe.301.2018.02.20.14.13.14; Tue, 20 Feb 2018 14:13:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbeBTWMf (ORCPT + 99 others); Tue, 20 Feb 2018 17:12:35 -0500 Received: from www62.your-server.de ([213.133.104.62]:44297 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750786AbeBTWMe (ORCPT ); Tue, 20 Feb 2018 17:12:34 -0500 Received: from [62.202.221.135] (helo=linux.home) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-SHA:256) (Exim 4.85_2) (envelope-from ) id 1eoG9D-00046w-U7; Tue, 20 Feb 2018 23:12:28 +0100 Subject: Re: [PATCH] bpf: hide a possibly unused variable To: Arnd Bergmann Cc: Alexei Starovoitov , "David S. Miller" , John Fastabend , Lawrence Brakmo , Jesper Dangaard Brouer , Jakub Kicinski , Networking , Linux Kernel Mailing List References: <20180220211658.2653840-1-arnd@arndb.de> <824bfc29-d6e8-9d7d-9307-79bf0097ce8e@iogearbox.net> From: Daniel Borkmann Message-ID: Date: Tue, 20 Feb 2018 23:12:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.99.3/24333/Tue Feb 20 18:20:41 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/20/2018 11:08 PM, Arnd Bergmann wrote: > On Tue, Feb 20, 2018 at 10:44 PM, Daniel Borkmann wrote: >> Hi Arnd, >> >> On 02/20/2018 10:16 PM, Arnd Bergmann wrote: >>> The only user of this variable is inside of an #ifdef, causing >>> a warning without CONFIG_INET: >>> >>> net/core/filter.c: In function '____bpf_sock_ops_cb_flags_set': >>> net/core/filter.c:3382:6: error: unused variable 'val' [-Werror=unused-variable] >>> int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; >>> >>> This adds the same #ifdef around the declaration. >>> >>> Fixes: b13d88072172 ("bpf: Adds field bpf_sock_ops_cb_flags to tcp_sock") >>> Signed-off-by: Arnd Bergmann >>> --- >>> net/core/filter.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/net/core/filter.c b/net/core/filter.c >>> index 08ab4c65a998..c3dc6d60b4bb 100644 >>> --- a/net/core/filter.c >>> +++ b/net/core/filter.c >>> @@ -3379,7 +3379,9 @@ BPF_CALL_2(bpf_sock_ops_cb_flags_set, struct bpf_sock_ops_kern *, bpf_sock, >>> int, argval) >>> { >>> struct sock *sk = bpf_sock->sk; >>> +#ifdef CONFIG_INET >>> int val = argval & BPF_SOCK_OPS_ALL_CB_FLAGS; >>> +#endif >> >> Looks good, thanks for the fix! >> >> Could you move the existing '#ifdef CONFIG_INET' to the beginning of >> the function given the only error in case of !CONFIG_INET is -EINVAL >> anyway? That would at least not increase the ifdef ugliness further. > > Sure, sent a new version now. I decided to clean up that #ifdef > check as well, since a IS_ENABLED() check is nicer anway. Looks great, thanks! I'll get it into bpf once the pending pr got pulled.