Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp786331pxk; Thu, 3 Sep 2020 12:33:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUWpvvE2xpC/7uuitDhQ+0g2YCvNCAzqUp0d2XssDqnYHpZH1VtSH/ES54kXo7FRZ64lJ9 X-Received: by 2002:a17:906:d8cd:: with SMTP id re13mr3698017ejb.140.1599161582910; Thu, 03 Sep 2020 12:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599161582; cv=none; d=google.com; s=arc-20160816; b=ObgzZixNP3QLwIHPnOAvpl8hepuqUVFigz5EfW22dT+F/FppSYrDCylVWg3ay3nBUg SIQ8/VYq8PAVBYrm8xsDXzBidPdDv7fldKmG2DAif3u8pUCIoaXKvRQ4Ri3GnW5znznC UoFqH188EmDXiLio1Lv2Lus3LNyUczpymFTKbvpKeZwE2gYX5jzTWY2Ww5i50Iui3xq/ OMFKf8ep94eZy60gsIgCAXPbyO53u1gYaPTDoEP/r5kFJwQXl+5l6oDfsMj1hHqQsyLD mNF87z5TTrj/NqNsDqPTtF6TFIs0vUulgTYmwgNyh35/4L5MBEQNZz9E1Qe0lHeUypRA iLyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7ju/sydS5Q9IaBUhC6NOUzji212D6APi15kEY10l2jM=; b=O5Pf6WEmjdd5AIuT2XeShH0Ihq2n5GLv2eyTNphvi5RPEqgFWqKbL8WXm7ibVsPP68 C1uluiI5sd/U8eKBkgix6fhLpeDebeJ/Dr5PEnKZmp5cbplYstbmCQGxK7uE/cVNWewd 1sb1XhcwZ7CrFoQLBSeP9xdtfXVqBXes7mQ/8W6+8g+0OLrP4XjQFznEHvELbbWkhDej x2YP79tFq6s6Tjzb1aTSmnsaJ6ldjoCBkgdBlhRNnIuK0/SLLyornw4q3t7aMkF+xCsy mMZsFy5I5BEtGEsUh8wv2G+ahkPxBcG/4FEZ/ftis9sReYFV19tHY3R25swbAB5Oock1 /jCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lbrg7jCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si2903667ejf.223.2020.09.03.12.32.40; Thu, 03 Sep 2020 12:33:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lbrg7jCc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729156AbgICTbx (ORCPT + 99 others); Thu, 3 Sep 2020 15:31:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbgICTbu (ORCPT ); Thu, 3 Sep 2020 15:31:50 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C424FC061244 for ; Thu, 3 Sep 2020 12:31:49 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id a26so5492249ejc.2 for ; Thu, 03 Sep 2020 12:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7ju/sydS5Q9IaBUhC6NOUzji212D6APi15kEY10l2jM=; b=lbrg7jCc44YPYHlwiPPcORp12NA43Sx5aUGnQyPqjAZQ5Q1+z1RgPw+CGG0dUOPJEj kJGDDjgam1jWTW3bD6eQLxH3xOpG/BbB/aI6TuYBbYOK2ufE5kZLYsGVcwI8E76JMncU 1qMvJ0kvpTY6aJ2Xdtm32ZmteixI8ThusUxRh5s6VPVymfaGtdGYMNUWAL9DZVm/NXQi 1cGBTEWExtOQDHGxdV8X7JrgCcJOFDgRA9Bubiog5xFkI384UOsEB29j9ha2PplRjHec hYTYbOHrDZgXRGwZTildKLwFfV/T2hngSupVSuZxPAeEmyq8zw+HnSntGFc4Yrr+ndAw wTNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7ju/sydS5Q9IaBUhC6NOUzji212D6APi15kEY10l2jM=; b=g/Dsbveq9fCH0phZYSNdUq1e3+SvPdN6Eup4ptJD8HaH5IKjyUAMitcHHQKQEU2wO6 +pbTJYAQcBi4PR0STZSdkhQooIR/Qw1vezQX6s5zk4xR4Axf9YiCYJ6rGCp2umIcTi2y VxEgkb+Ym8gXlhQd2WX2pdNiNpm41oNs15cZlmEo7O6oMoEkj2nLCAavHceI1do0G2HD 4koI4O9C+4p3fEwsi6npgoku8fapv4OoB838t6iku70ZFPMY73hffrLi7NRRiyTGL7nY xoILICFKHu3bR6DaAFMFTRruwV5BtlvwiNMk8ZiarLWhPqf6N5zqX9CTe2Os2hbBrMGl Tung== X-Gm-Message-State: AOAM533dI3F604OsE9yb/ssTFUk/lAKa/ncikcB24dw9IVWFVXrmHhE2 kgv8qtyHP/QUJUPCZWV7WdV7JNHyoDgVlI7eKmyk3w== X-Received: by 2002:a17:906:7746:: with SMTP id o6mr3684224ejn.113.1599161508226; Thu, 03 Sep 2020 12:31:48 -0700 (PDT) MIME-Version: 1.0 References: <20200903180121.662887-1-haoluo@google.com> In-Reply-To: From: Hao Luo Date: Thu, 3 Sep 2020 12:31:36 -0700 Message-ID: Subject: Re: [PATCH] selftests/bpf: Fix check in global_data_init. To: Andrii Nakryiko Cc: Networking , bpf , open list , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , KP Singh Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No problem! Let me update and resend. On Thu, Sep 3, 2020 at 11:50 AM Andrii Nakryiko wrote: > > On Thu, Sep 3, 2020 at 11:02 AM Hao Luo wrote: > > > > The returned value of bpf_object__open_file() should be checked with > > IS_ERR() rather than NULL. This fix makes test_progs not crash when > > test_global_data.o is not present. > > > > Signed-off-by: Hao Luo > > --- > > tools/testing/selftests/bpf/prog_tests/global_data_init.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/bpf/prog_tests/global_data_init.c b/tools/testing/selftests/bpf/prog_tests/global_data_init.c > > index 3bdaa5a40744..1ece86d5c519 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/global_data_init.c > > +++ b/tools/testing/selftests/bpf/prog_tests/global_data_init.c > > @@ -12,7 +12,7 @@ void test_global_data_init(void) > > size_t sz; > > > > obj = bpf_object__open_file(file, NULL); > > - if (CHECK_FAIL(!obj)) > > + if (CHECK_FAIL(IS_ERR(obj))) > > Can you please use libbpf_get_error(obj) instead to set a good example > or not relying on kernel internal macros? > > > return; > > > > map = bpf_object__find_map_by_name(obj, "test_glo.rodata"); > > -- > > 2.28.0.402.g5ffc5be6b7-goog > >