Received: by 10.213.65.68 with SMTP id h4csp3444378imn; Tue, 3 Apr 2018 05:12:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Ri8/39b4DSJBK+Ipt67MHqF71cgMKhg4M5x2UYQX2LKv9X4+HV/28fT700EYDpXZrVL1n X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr13637702pla.98.1522757539024; Tue, 03 Apr 2018 05:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522757538; cv=none; d=google.com; s=arc-20160816; b=wdu6cgEy5bPjfw9cV71DhTsZ7knKLNEDP/qBPJsTuVK4JYVJKLx7e2nMmkIGQU7ivO BC+yHKRBEfnXw0pBKvfbA6S/1/AiVO6tGeEbOs/ycJ2tywGgn5tMNw6SJTfKOAOQQEkY 17VzukFzyWSUW+d7RQ1iRgc3Aj/WsJhYaoK5ozBFH9WtETjHDlxVW0PxNVyku6lCMMxJ j3u0XOOnraeFPrcDmcbZB5ot+7sC8iFAsSEyVwh/qiKyyEHqjS62w5SI/+K1bYvDBdJY WJ9wAeuGKhD1HHrH+xoMronY17gNKSRoqm9XsuC+tXY/YF/HSaIS8js7OQfpPtp3doOF auTg== 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 z20si2032027pfh.251.2018.04.03.05.12.04; Tue, 03 Apr 2018 05:12:18 -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 S1755454AbeDCMKz (ORCPT + 99 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(-) 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, -- 2.16.2