From patchwork Tue Apr 3 12:09:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 132744 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp3726328ljb; Tue, 3 Apr 2018 05:10:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49SGW7jbgDPOkHLCtM0p2+MDLgAYrZRqkeXSvF2HYmNAO9opWQpb+rAjO68t8LHX8N/4lV5 X-Received: by 2002:a17:902:728f:: with SMTP id d15-v6mr13554086pll.227.1522757457889; Tue, 03 Apr 2018 05:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522757457; cv=none; d=google.com; s=arc-20160816; b=nuD9yZjVAop1sFOdkJSJzRrb2v71m9Rz57wW0CmC05WIU+QIG+KZq01YcS2WOSOltT eGv1qyWEEHCpxkQgeUjo9abRVe2amk7fpMt/HsQ+QimxqzvJA8D/3McdGuRl+Ma55Y5+ UfSGV8mkNXS4+45RO7AGgntdi6/F48rges4AWZwtDL0cQPfHNi3462Y3Xu3SdFCfQoDp GDI4Lz2amHJgFOAD/Of8f2IZ7F2iHZydteVtg/h2RbOpjSaUt+27iDTAuMYZBaMeisXI GPEJNDsfs2xJVO87BYFzVggXE8X2+gllCRWjIQHkI9bAEJKhajgxDU2rgfAcoe/NQ6y8 021w== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=e6T9TkC3N25F4OfTIAel/KnnKjt6ADMLHOze0PyY4Kc=; b=gq8UvGI+Ont/EoEEmISwEpvqunq/BfA/zjwL2M+PSbxCKFBGK/UQapd+mu7IgNIEWJ l0S2jA1oXD1rjIPo/f+zcBMnArTwJgGaWi5gEE6EPU63XiKQt2alAWYCU8qDxtZJY6zb 3tIkrG5m27q7VBP/8ensPQx7+07pUp079SJyZPRw5K8AbL+46gD2Za/v6cvzrVBljG5e zoJf3sWDV6JI/QzjURkfnXpGgSnlMQg6D5TJe8E8lk8UTHqX/7XHJy/xYBTKjE1/IwTF ei8pgFiwMklxMqUdROggfGeE2YhzJa27WZQ4W5QbqkcocfnFv0rOAk4icP1a2RKSziyp c+8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dlEzd7i+; 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; 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 1-v6si2743955plx.463.2018.04.03.05.10.57; Tue, 03 Apr 2018 05:10:57 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=dlEzd7i+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755461AbeDCMKz (ORCPT + 29 others); Tue, 3 Apr 2018 08:10:55 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:34870 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755300AbeDCMKx (ORCPT ); Tue, 3 Apr 2018 08:10:53 -0400 Received: by mail-lf0-f68.google.com with SMTP id t132-v6so19842990lfe.2 for ; Tue, 03 Apr 2018 05:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e6T9TkC3N25F4OfTIAel/KnnKjt6ADMLHOze0PyY4Kc=; b=dlEzd7i+wnl0gaJfdorCzXChF1VyjNio0K2vKMZy8YMj5NVybcxj4RbkRowy6zqCNd tMCaPtEmUdXJWWGvFENQ6HRY4xHlKcOijqRTRU9ZH2QwTtl6yEQC8FbKV0F5Sth6oeMw eC9ZsMUhV/F9bAEyv65L/pBcdx94X5Ztc4RPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e6T9TkC3N25F4OfTIAel/KnnKjt6ADMLHOze0PyY4Kc=; b=t0n327VQ/qFMV4d4syja+7Rkf4+PPGcM+6T+URhOX2RiFDuCZn/URcQG90Z8Ers3/I Qm7Pn/b8aDkgCWXcQZE18Jk0Ntc8+FfR0HNzXKal4np9NkllaQQ/r/nKX6z+mBWFlVm8 n/e5glzFDWuxMy+Im0AYUNKWCoN/xsW6tMf4u/A6Xi+7E72HesgTBA1WjejdLxHu31IX mD1xSbnK86o+dPMtXzIVVEJ4QFmlP61uSGBt0dDoKKf9R2e/xU+5pbasgNq091QXkvyU 06qPgBq8L469HNQaUv97JF1myRA+aa2rytyj+KPwdQNysoKRMei9IMcI8YTvvP7pA4lv npNg== X-Gm-Message-State: ALQs6tC8TuvjIz+YETNLPBLdGeSGHfhQ3uPnVZ8KQwk9ns+lsBT4+qj2 XwfsxQSakc0jcC4COuLMhCzwMg== X-Received: by 10.46.144.72 with SMTP id n8mr8273137ljg.40.1522757451865; Tue, 03 Apr 2018 05:10:51 -0700 (PDT) Received: from localhost (c-4c3770d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.55.76]) by smtp.gmail.com with ESMTPSA id s12sm442293ljj.49.2018.04.03.05.10.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Apr 2018 05:10:51 -0700 (PDT) From: Anders Roxell To: ast@kernel.org, daniel@iogearbox.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell Subject: [PATCH] kernel/bpf/syscall: fix warning defined but not used Date: Tue, 3 Apr 2018 14:09:47 +0200 Message-Id: <20180403120947.9321-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF: kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’ defined but not used [-Wunused-function] static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Current code moves function bpf_prog_attach_check_attach_type inside ifdef CONFIG_CGROUP_BPF. Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time") Signed-off-by: Anders Roxell --- kernel/bpf/syscall.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.16.2 diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 7457f2676c6d..56f49557adda 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1226,18 +1226,6 @@ bpf_prog_load_check_attach_type(enum bpf_prog_type prog_type, } } -static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, - enum bpf_attach_type attach_type) -{ - switch (prog->type) { - case BPF_PROG_TYPE_CGROUP_SOCK: - case BPF_PROG_TYPE_CGROUP_SOCK_ADDR: - return attach_type == prog->expected_attach_type ? 0 : -EINVAL; - default: - return 0; - } -} - /* last field in 'union bpf_attr' used by this command */ #define BPF_PROG_LOAD_LAST_FIELD expected_attach_type @@ -1465,6 +1453,18 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr) #ifdef CONFIG_CGROUP_BPF +static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, + enum bpf_attach_type attach_type) +{ + switch (prog->type) { + case BPF_PROG_TYPE_CGROUP_SOCK: + case BPF_PROG_TYPE_CGROUP_SOCK_ADDR: + return attach_type == prog->expected_attach_type ? 0 : -EINVAL; + default: + return 0; + } +} + #define BPF_PROG_ATTACH_LAST_FIELD attach_flags static int sockmap_get_from_fd(const union bpf_attr *attr,