Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1254253pxb; Fri, 1 Apr 2022 08:29:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykPoUPzJ29FWS//StpavNqyilTqTq2Fvu9QTjNdzoPNg4LO/1zueb8gFmKEZ54H1e5uVzY X-Received: by 2002:a17:906:434e:b0:6d0:ed9c:68bc with SMTP id z14-20020a170906434e00b006d0ed9c68bcmr330584ejm.70.1648826941498; Fri, 01 Apr 2022 08:29:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648826941; cv=none; d=google.com; s=arc-20160816; b=I+JDiNAaWa3en3Bm1fhLwQDtss7Xi3sz6eu0+8U7TvBLRRPAIT8DAO/mYU1nY7aXyv 7HafITwx9+75KGHQk3lRzfj6KVWm/7J+Y2LlL+ERrlbgpaHcJD9hdBEXT1vbPvFPB+ic YeLSuw1JCqa4+hTLwTCEKEUUOD8GkvDzcO0/MoAIXdffhDsdFuzL41F2ejqidPfPF1IM N3RBx/U/gFBN/Cw4Ya1Vn19cJg6yX0DpBTqUkP9gnbsUqHMogejftuug6X+Kl6jIJ3SY dBpURJPalXPtyOK4W8GpWNKbIGTmeUAAa4fNYIpjNpdwQOH2l/Fw69eI0NMTLd4fq9d9 gA4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=wzk0ykwu4tQZfVHoTNx9MQk0tCGTJyoMT5MyyH8WkMU=; b=lCCvACo1PHFHTRv5wcAoBPiuadXtUKEu9gB96jSJzfi2oIkcV/bs7PaONsBChvF5ZI 9aleStw1a+vptdjY/dzRo3mPcm0oL6lpHdX0xgk4EW/dGOv/6WehUQ+dIpfvugEWxSbZ wOXZnOd2X3K+VdRrRDlWGspFfya1JUkz/h8p2Ib7vbRjTT0T88J1FUlPJhWWgIOn67Xo SZCVv99fCIBRlFUAphcFHcKue7SU8c57kkuFBGJ8jrmF5rAeJb4syPhNPMyhnSOf2y8o 0ufXweLv3vxrafaKjFwZDvJMWd1JLWsJmv291daVviarnPVxFk/j+q3/rw9OhCTXtmG5 VFyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h5-20020a17090619c500b006e00e3ed03csi1822603ejd.288.2022.04.01.08.28.30; Fri, 01 Apr 2022 08:29:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244002AbiDACRz (ORCPT + 99 others); Thu, 31 Mar 2022 22:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238832AbiDACRy (ORCPT ); Thu, 31 Mar 2022 22:17:54 -0400 Received: from mail.meizu.com (edge07.meizu.com [112.91.151.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E803422451A; Thu, 31 Mar 2022 19:16:04 -0700 (PDT) Received: from IT-EXMB-1-125.meizu.com (172.16.1.125) by mz-mail11.meizu.com (172.16.1.15) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 1 Apr 2022 10:15:57 +0800 Received: from meizu.meizu.com (172.16.137.70) by IT-EXMB-1-125.meizu.com (172.16.1.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.14; Fri, 1 Apr 2022 10:15:56 +0800 From: Haowen Bai To: Shuah Khan , Alexei Starovoitov , "Daniel Borkmann" , Andrii Nakryiko , "Martin KaFai Lau" , Song Liu , Yonghong Song , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer CC: Haowen Bai , , , , Subject: [PATCH] selftests/bpf: Return true/false (not 1/0) from bool functions Date: Fri, 1 Apr 2022 10:15:54 +0800 Message-ID: <1648779354-14700-1-git-send-email-baihaowen@meizu.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.16.137.70] X-ClientProxiedBy: IT-EXMB-1-124.meizu.com (172.16.1.124) To IT-EXMB-1-125.meizu.com (172.16.1.125) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Return boolean values ("true" or "false") instead of 1 or 0 from bool functions. This fixes the following warnings from coccicheck: ./tools/testing/selftests/bpf/progs/test_xdp_noinline.c:567:9-10: WARNING: return of 0/1 in function 'get_packet_dst' with return type bool ./tools/testing/selftests/bpf/progs/test_l4lb_noinline.c:221:9-10: WARNING: return of 0/1 in function 'get_packet_dst' with return type bool Signed-off-by: Haowen Bai --- tools/testing/selftests/bpf/progs/test_l4lb_noinline.c | 2 +- tools/testing/selftests/bpf/progs/test_xdp_noinline.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c b/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c index 19e4d20..c8bc0c6 100644 --- a/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c +++ b/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c @@ -218,7 +218,7 @@ static __noinline bool get_packet_dst(struct real_definition **real, if (hash != 0x358459b7 /* jhash of ipv4 packet */ && hash != 0x2f4bc6bb /* jhash of ipv6 packet */) - return 0; + return false; real_pos = bpf_map_lookup_elem(&ch_rings, &key); if (!real_pos) diff --git a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c index 596c4e7..125d872 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c @@ -564,22 +564,22 @@ static bool get_packet_dst(struct real_definition **real, hash = get_packet_hash(pckt, hash_16bytes); if (hash != 0x358459b7 /* jhash of ipv4 packet */ && hash != 0x2f4bc6bb /* jhash of ipv6 packet */) - return 0; + return false; key = 2 * vip_info->vip_num + hash % 2; real_pos = bpf_map_lookup_elem(&ch_rings, &key); if (!real_pos) - return 0; + return false; key = *real_pos; *real = bpf_map_lookup_elem(&reals, &key); if (!(*real)) - return 0; + return false; if (!(vip_info->flags & (1 << 1))) { __u32 conn_rate_key = 512 + 2; struct lb_stats *conn_rate_stats = bpf_map_lookup_elem(&stats, &conn_rate_key); if (!conn_rate_stats) - return 1; + return true; cur_time = bpf_ktime_get_ns(); if ((cur_time - conn_rate_stats->v2) >> 32 > 0xffFFFF) { conn_rate_stats->v1 = 1; @@ -587,14 +587,14 @@ static bool get_packet_dst(struct real_definition **real, } else { conn_rate_stats->v1 += 1; if (conn_rate_stats->v1 >= 1) - return 1; + return true; } if (pckt->flow.proto == IPPROTO_UDP) new_dst_lru.atime = cur_time; new_dst_lru.pos = key; bpf_map_update_elem(lru_map, &pckt->flow, &new_dst_lru, 0); } - return 1; + return true; } __attribute__ ((noinline)) -- 2.7.4