From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4B46C433B4 for ; Wed, 12 May 2021 21:09:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80410613C5 for ; Wed, 12 May 2021 21:09:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237515AbhELVJy (ORCPT ); Wed, 12 May 2021 17:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243458AbhELTAE (ORCPT ); Wed, 12 May 2021 15:00:04 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F0DAC06137F for ; Wed, 12 May 2021 11:55:49 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id i4so31994580ybe.2 for ; Wed, 12 May 2021 11:55:49 -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=Ni2rDVSZd62hK7RvjUtltYrU0nSL/K6ogWoKRE8gpTY=; b=N6yGaS9Dt4Ax5NhLLkE5H6LisOyI0QxLO2wHljBA90UbWn4a2awjiNV8CPUWyFdSu4 Qszm0lyW71szdK7zntd/etqXahT8a+gcnaAN/vsBTcKfujoIgvMCDrEWQe0JYpcHgbhQ aYxLGEi0ky5ZJbCeOiLUH6pdibUeh4eTvhKrWd52+Px2d+2t6Eif+TPHD2To9eZyMNVZ PgPGDtUKphvSgUzgkT2fNmTWF/Xbz1LFVWRGLSSC/x3islSDH2H3iRfbr95Z409BWrUf 6hTySYC6iiCtMwq5TLe+W6IvfThwHiwMaeQKpoP+LzX1joNQYMpBmKOPWCvfO7j1UlKg zORw== 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=Ni2rDVSZd62hK7RvjUtltYrU0nSL/K6ogWoKRE8gpTY=; b=perFtowfZQiH8cK/803LMs0F4NITF38WLgTDvUJzA0DYIeUPcb150wG3C+OMRu7KyB JoMtpWB0l5HCBumDEAjD9RDI/VnDh5M53eS07/o54RuBfBF65qO9cF2HJxCHxv0y65Qb jTjbCWVp/15YjrzhiFRpZdJs+YG1wRBRD9fLZhzRL/NlCSftkwtf2Vk5t3mFqv25OPSf 1myMSr3HL6DlXCSFSqAaOw1P/aAWBAxJpKFRu9KOlcGj+arNuwZqUADHGS24Q3k40IZ3 jtdkxmHQ03gAdqxa8Akt2vrI85QnguMDW0LdyjAIZ+2IC+u5ltvATJKvQxSv9PhrvNpf w/XA== X-Gm-Message-State: AOAM533mHy+4oC4FqCwRq0Ha9H7ddxpCBk9qpME8HSy7pFsYHsfauH49 H+rvyZnJ0wObLZzZpjPnUWuDI2SF1/RAsR3NCuY= X-Google-Smtp-Source: ABdhPJwNQDyWLBL3WPUs93lEHokr08bHH8poqdkHpQeh+anyFft+UkD9ascZMuNIP9oj3ThaavDuh3XdAxopM9Pp0wQ= X-Received: by 2002:a25:3357:: with SMTP id z84mr49435640ybz.260.1620845749047; Wed, 12 May 2021 11:55:49 -0700 (PDT) MIME-Version: 1.0 References: <20210508034837.64585-1-alexei.starovoitov@gmail.com> <20210508034837.64585-19-alexei.starovoitov@gmail.com> In-Reply-To: From: Andrii Nakryiko Date: Wed, 12 May 2021 11:55:38 -0700 Message-ID: Subject: Re: [PATCH v4 bpf-next 18/22] bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command. To: Alexei Starovoitov Cc: Alexei Starovoitov , "David S. Miller" , Daniel Borkmann , Andrii Nakryiko , john fastabend , bpf , Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Wed, May 12, 2021 at 11:44 AM Alexei Starovoitov wrote: > > On 5/11/21 9:17 PM, Andrii Nakryiko wrote: > >> + bpf_object__for_each_program(prog, obj) { > >> + printf("\tif (skel->links.%1$s_fd > 0) close(skel->links.%1$s_fd);\n", > >> + bpf_program__name(prog)); > > > > you use bpf_program__name(prog) in so many place that it will be much > > simpler if you have a dedicated variable for it > > Every time it's in the different loop over all progs. ok, it's no big deal, using variable is always an option to shorten printf if necessary > > >> + obj = bpf_object__open_file(file, &open_opts); > >> + if (IS_ERR_OR_NULL(obj)) { > > > > please use libbpf_get_error() instead of IS_ERR_OR_NULL() > > That was copy-pasted from another place in the same file. > Fixed both and the rest of comments. The reason to use libbpf_get_error() is because we'll be changing how error is reported for APIs like bpf_object__open_file and libbpf_get_error() will handle that transition automatically, so not having IS_ERR or IS_ERR_OR_NULL reduces amount of clean up we'll need to do.