Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp26358pxh; Thu, 7 Apr 2022 21:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD/5kyGkbQNuQ7/vsNhC/FdVUevNi0JXgBq7+PmMJ6IDgOm080Z4TJCC1kkktuivs2w4ca X-Received: by 2002:a63:5522:0:b0:398:f8a1:c8bd with SMTP id j34-20020a635522000000b00398f8a1c8bdmr13974787pgb.118.1649393381581; Thu, 07 Apr 2022 21:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649393381; cv=none; d=google.com; s=arc-20160816; b=HO3s6xfnevnDRM03rIOpQmK6Vvu54mRRqy4uUagEFZWEVlQPx54r7aJLplnw5N9cc6 mAtEbrv0IvfYflwCYUlfy9UGpaiCPRzboSvd/AEpRDPjD9UboSUoGAiizZVSl+f5/edC 1eNT38FJCHcMnZIw8UR52MgMKlPASUI7WsbnrVsQzU28CdyrGjzeZ0sIqLqM+XdSWDdA yNRpk2Ter0gRhD8VOEzpBUIk3hYM8xE7aESxdiwlbBhMmw5x6oCUaCxTEljoA+umB5zt M5UntUt86H5JYUkDYSj/S9NQT+tlx7/rfwGcOAn/TpTT1Kwhmk11LoDKVQ7cGAbTafJm IasA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4+rOEzFAMJJgXNy15jCz7SsQISiJWacBJllHkfSFDfk=; b=iVtlwRA3AxF/4glQACaMOUOX9MMKXOUJaCf3OqmxafxiCIxePiP+g7EURnny/9jjcj +a8NnI2p3aLunGM529n82zdnZSD/JKAOXjiSOEsKwqAsN06YsT3+7VH7/eASr4n//WKx mFCQ77juYHEMn5Rl6yuMcrd3QehFcS74equ/3nMI4okMGRYRycQVSNQOq0QMupmkbBmk /7pT7ufwIJlILhHThnlrcg8LKDr3cUQosGYxJKSvpkPcYgHOKszNdlUhMpRXTMJE8sad KgwTJPCRJaicwMFtpuZjhio97MJrjGeHBYue5keWUic+dtJJ22bCov8NSD48sVXVoX8y Ei4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KTJGOHY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u11-20020a17090341cb00b00153b2d165b2si1759461ple.442.2022.04.07.21.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 21:49:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=KTJGOHY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC9AAC31; Thu, 7 Apr 2022 21:16:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234167AbiDHERa (ORCPT + 99 others); Fri, 8 Apr 2022 00:17:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232658AbiDHER2 (ORCPT ); Fri, 8 Apr 2022 00:17:28 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68EAC2E0F20; Thu, 7 Apr 2022 21:15:25 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id a16-20020a17090a6d9000b001c7d6c1bb13so8481238pjk.4; Thu, 07 Apr 2022 21:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4+rOEzFAMJJgXNy15jCz7SsQISiJWacBJllHkfSFDfk=; b=KTJGOHY1jWaNKMCowdV/0KshrzntST/NJ2chxhHVG54H7LfhRJb3PdOmoV4vHk+dKM RUFI7CS0leoZ+SvwHFyaN0W9MuV+RqDQ0RQvW8CDZl8rWUtEC3fn+9n9RRJaV6StWf7K rEMdl/86TDCo2CaDLveZaSAECeIy2KSZOJOs+acpnWyXp1UXGkhylydCDBPvi4d4721j GsIPPpMlcazsxT/Nd7gulCvAiaDdKMNhAmuIVisB3FcPHEEsp3pCIVCjRF58drpMXMSw 1ZaeoiuxjGZC4xakz68ISoyZgv2lCPNYkijTEkS6dWaj9aXqMZZC+fm1J5szybcNCDdZ VUSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4+rOEzFAMJJgXNy15jCz7SsQISiJWacBJllHkfSFDfk=; b=cY68dX53NWczIZHElkIC2XYCqlZrbGDqpfHgi/53HNGxCoK6dZ+xEQJGt7xe4GlnZu 1V0KThCOa+jWFeGlPTAaJ1TVliTjVZgXIM+GMMlr3EDzNHzpMpSdXbzlLSD7XorR1P7X EmWjq7MwLDueO1In5eHREMv1OMv7eB8/eQDUPNN4a51cxpGsBdDDbDtFl7PeePDUtF2Q 3o2MpqUa9aAMagxV5m3ulR8tlzUUgxoyks5sCtbF2axoOyVRv9KVk64KeZHMTMGc5FeQ w6vQ0qVvTS9bwbRG4fff8p809R0cPP1BpVI0xUxPrPsGpBE+wArUIA//0j/IURl0I5M9 snxg== X-Gm-Message-State: AOAM530g7yz6R9NT5hriCdSwU054V5LV8el/cjHdj03ekyi9+HJSC8YT nq+LCQjjkmBEMjLTuu7xdVc= X-Received: by 2002:a17:903:1104:b0:154:c628:e7c2 with SMTP id n4-20020a170903110400b00154c628e7c2mr17648425plh.54.1649391324970; Thu, 07 Apr 2022 21:15:24 -0700 (PDT) Received: from localhost.localdomain ([43.132.141.8]) by smtp.gmail.com with ESMTPSA id f14-20020a056a0022ce00b004fabe9fac23sm25789042pfj.151.2022.04.07.21.15.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 21:15:24 -0700 (PDT) From: Yuntao Wang To: skhan@linuxfoundation.org Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org, daniel@iogearbox.net, hengqi.chen@gmail.com, john.fastabend@gmail.com, kafai@fb.com, kpsingh@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, shuah@kernel.org, songliubraving@fb.com, yhs@fb.com, ytcoode@gmail.com Subject: [PATCH bpf-next v2] selftests/bpf: Fix return value checks in perf_event_stackmap.c Date: Fri, 8 Apr 2022 12:14:52 +0800 Message-Id: <20220408041452.933944-1-ytcoode@gmail.com> X-Mailer: git-send-email 2.35.0.rc2 In-Reply-To: <7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org> References: <7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The bpf_get_stackid() function may also return 0 on success. Correct checks from 'val > 0' to 'val >= 0' to ensure that they cover all possible success return values. Signed-off-by: Yuntao Wang --- v1 -> v2: update commit message tools/testing/selftests/bpf/progs/perf_event_stackmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c index b3fcb5274ee0..f793280a3238 100644 --- a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c +++ b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c @@ -35,10 +35,10 @@ int oncpu(void *ctx) long val; val = bpf_get_stackid(ctx, &stackmap, 0); - if (val > 0) + if (val >= 0) stackid_kernel = 2; val = bpf_get_stackid(ctx, &stackmap, BPF_F_USER_STACK); - if (val > 0) + if (val >= 0) stackid_user = 2; trace = bpf_map_lookup_elem(&stackdata_map, &key); -- 2.35.0.rc2