Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp760501pxk; Thu, 3 Sep 2020 11:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp03Hm6SRGth3/q7W1EO7Rt7J9CjWWbD50zRGOn4g2yQw5uIdC+x5u5orZcbCeNh8KhEtP X-Received: by 2002:a17:906:f8d2:: with SMTP id lh18mr3391460ejb.363.1599159125775; Thu, 03 Sep 2020 11:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599159125; cv=none; d=google.com; s=arc-20160816; b=bi6OdJledKOJn3+vdw0rtXp6s98DGLDgflqPEEE3lz/NED5XNSOgZpA0CyMEkvqqb8 e3cw5065p56GaER7GTJLBUWeweH+AQhr6Lb8B+fgQgTi3Q3ZyLb3aphzkDBYsx5Qr4mx whGIlf0yOjCbK7uwXHDEV5XvTC0qtjXPZuBgPH0L5mHtgp9TveRvhVwRUIOJnN7TiK9H 571yElI5zi3VRQnAEYhKTV7qSFFfLWY1VgJlPU9L974qElrK0RLXjcMxxbdPG1PINCCy ZxaWXaHy4I2tWew8qSRlr/lUATak6G9V/z9GFrjV9zkWeUaQ7tUpRaqHmLC9BuBdsvZJ WK5w== 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=nWryz7cGGb7smK7ck6NRR7lmXazI3vI4tRYw7MpNE7I=; b=sP4aSFdmaT54RDAymzGHCLLQN7iosMhF6R8VPYDwPgzOVdIWYrmdiKbN7mbmnMep8r JuQGohnPkzqCiP5o6KrCK+ybGzYjFsZZ+hZszzOkOLSYE2LoTV8Gj+ZdJxUFSSl9zwk+ Sq9h9w6zSI+1ROKExjtj+oigiPJdKGfpNTFtDwN5aCK4efNwt4QMwpo4SZVfOF3NDIGR +9y0YBObsBuKVAsxRjq4h1rXNTszi+GA67HQfGbNtZ9vveYAlOKn8/20ipm5MHbCm7WU UtwuM70wwhvNDt/lqvfieBQfDxvs2qTUk3SNITJziCJHzS91fOcs2zkDNuSl+59VRHe9 HEWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="h/H7emTH"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co12si2477321edb.104.2020.09.03.11.51.42; Thu, 03 Sep 2020 11:52:05 -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=@gmail.com header.s=20161025 header.b="h/H7emTH"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbgICSvC (ORCPT + 99 others); Thu, 3 Sep 2020 14:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbgICSu7 (ORCPT ); Thu, 3 Sep 2020 14:50:59 -0400 Received: from mail-yb1-xb41.google.com (mail-yb1-xb41.google.com [IPv6:2607:f8b0:4864:20::b41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A333C061244; Thu, 3 Sep 2020 11:50:59 -0700 (PDT) Received: by mail-yb1-xb41.google.com with SMTP id s92so2892077ybi.2; Thu, 03 Sep 2020 11:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nWryz7cGGb7smK7ck6NRR7lmXazI3vI4tRYw7MpNE7I=; b=h/H7emTHFm18MSYwIfWOY6up73kGriPotxpPDxxIzGFezb9s6u95yUSAQks1hjPic5 B7TGckUvsRrE54bjV/NjPRrfRjOhcj3KEqh3A0xxpc6o+MI7Xiq2cODAVYtDVoWPbsVx xjEH/BWoqyncQIBs1bPC7PWP08kWzJRk3NCGuL/F3bhPWjzEE4OvMzOaI2AR1p+Dg9Na IUuDSWOUf14qqYxIeFPnFy8/pj1BU+5xhAwDYUD/NIF/fPznUZdEGqonlbq/l1gtznpp 5Wi3oFIyeCTrkjGAG7EXbkieMz9buryVEu7+MTWRx8wXaI6SS41pvEv0gBPLnOgGw5r9 AQLw== 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=nWryz7cGGb7smK7ck6NRR7lmXazI3vI4tRYw7MpNE7I=; b=akuZ6nxiKiFj+vmtzLoXUvUbpVrv31iIgt9TKsDpdIbmZbCMIf1pKkaAFzhdBY3JHs SAu/YgkIe6vuTb++j/S/cUPTE30wQmX6eucgB4gnv1m9lAdbEYxaNa0aEAR7SfzvoPAP EqBEMcFarpr+uD9Y432eknXqBK9ZClWPHsT2pr1sLbmtIKrJfM1S4nuSxWBYeR2pAKGc vOeEEVq9LfV0k9QuOadFsk1/+UnXeXY//2jBoo9V+mtwMYydv4b5ahzrv/q94T8gRq1K +MGO5FyX1ti6rbiT3X0NGJsVgY//M27IAbO7qWdW9cCrRGrXwsimDpgRxsyHMf9jP3pc 7vwQ== X-Gm-Message-State: AOAM531dHL1DATZys+B6xZCVLBtZyuz3e0V41T6M9j8Jrp1+nCgDdd1a 9cVFUJ9isLY2jlQfnhNR1a4rjWGXPPDgl0jEamU= X-Received: by 2002:a25:824a:: with SMTP id d10mr4891758ybn.260.1599159057296; Thu, 03 Sep 2020 11:50:57 -0700 (PDT) MIME-Version: 1.0 References: <20200903180121.662887-1-haoluo@google.com> In-Reply-To: <20200903180121.662887-1-haoluo@google.com> From: Andrii Nakryiko Date: Thu, 3 Sep 2020 11:50:46 -0700 Message-ID: Subject: Re: [PATCH] selftests/bpf: Fix check in global_data_init. To: Hao Luo 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 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 >