From patchwork Thu Jul 25 10:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 13741747 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AFA214D457; Thu, 25 Jul 2024 10:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903953; cv=none; b=dM3XfyWtsIhQUH7eevki37xRbe8IvtkA++9dlbWQ7jk2bdEX2chfO7SmSMuIV6b5+GpIYdNAWEp1NUHPzoKiu4uCbh9B0nrHSz9AQtU2KZq+LkY3u5e9UHZc/Cn+hC7JdkAFDJPq/z9x8amTw0BHIJs9NeQnCOyKEDLcQB9/hwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903953; c=relaxed/simple; bh=FhhULHJSRQRfqOkOSBVfyHqLgWbWh8s2Lych3idzotM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Sv9W3hP8VorFMoxtCqSeEG083hqjqgSH2K2ekh829iOTqbX+uqXXZpFCrN8TOMz4PxrMEXjUjq/YzevM+mGO8MKj9N/ftqNZoIE0dKoP0rV5+qsiZvnuT45IsiO1wCjfOkqr6m/ehSe2O9oPGsdBpudOCV30YSaOOq2uh2XUqZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d2lL6Qwr; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d2lL6Qwr" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fd9e6189d5so6498795ad.3; Thu, 25 Jul 2024 03:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903952; x=1722508752; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ghp88PrF1o/2mzcoM7JfrRTyuYzOPJ40TUi0UK8SVqA=; b=d2lL6Qwrcr6Bu+xuhiByTGZ72SwEHoxl5hR4pzOlcimEGeovCxVFxc91TVhVeeazkd PEP0raLrCxaVm6G4OvggGAT22+hVbVXxoPsGcN+QXGUjqGjYI4W48+qdLlkDVy7t5qhh QaJ0EYWedLbVraBp3Hk7nByvJqGNl1MXs2m647dd81IZQ/ejzevpc4uulWUVnKfXJgRG Dktf/F8ZYO8r5tNqVO3ECX5hKyFDfAVggErKY3qVZ9bIeyJYxPpsT//+nWYnwdTgCYyB TUKuesq0eyo6SewdDhDIk0o1ZyvlzJGe7XIj66ganUujgdSy2XnJmub2qnPFDPQhxH6L 1Lmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903952; x=1722508752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ghp88PrF1o/2mzcoM7JfrRTyuYzOPJ40TUi0UK8SVqA=; b=iaKvdVqOLJkjzDS0iUEIQnpOs5xmSDWJZdeyZG/7Z/fmTH6pt8PEY3pEqk8Ua3Nrb7 SCKHu7oG2dmOT/9pHtxyc+kQFXYJtaXeVsUXAzmqo002z94sl6Fy3qIOEnd90S7IF59e Qt85UJo9qbj38LrbJ9b0ECIsQR4BqCmy2nsCdpueP0JmBkuufKmpltSRx5l3XS/H08GF 1IYgzNWBvJ4BhaTwhRvnfxFvRZtTSiSjcxz7q2RWDurM5IQ3E9AkRRXEY1g/hC4E3x0G LwLhbUeEjTThd3LDAgG62ucjIkWz6UgNF8RfG5ktr3qe/s5/SG3mnhbxGxtCVZ/EwYI5 zk2g== X-Forwarded-Encrypted: i=1; AJvYcCWwxknLXr8kCZ+s2ShnGLumdZdZ0ZV/M6gjEcRH7eZFyU27dqj22NPscOnnUEMaVNs6z85ZJL5mGelHLmkAfAkp7GyXBC2rWI1sfZf2Novngg/MFgK0ZXJ1X5Drhbs6TpNlQGrJnSqZ X-Gm-Message-State: AOJu0Yzl192NToem0SqnfayoUtRd1QbSjw3vrqtQA+xD2PMgWtbmxLoB WpdOP/BBHGB/k5F81uTGxiriruhU/Cp0CNzsH+SvELl/KH+t56DB6o13KVYi X-Google-Smtp-Source: AGHT+IHIy/VccFzu/PejmYfYrlXyVUe0mollB6ADsyNs+yD+o6XPQfOPVqoASrMH/7qtfhA6eLZ3Ww== X-Received: by 2002:a17:903:228a:b0:1fd:6848:bc2d with SMTP id d9443c01a7336-1fed9257af7mr13548175ad.20.1721903951607; Thu, 25 Jul 2024 03:39:11 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:11 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 1/8] selftests/bpf: Use portable POSIX basename() Date: Thu, 25 Jul 2024 03:35:53 -0700 Message-Id: <570a059b3db60199028e0a36896be0f1b472b9cf.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net From: Tony Ambardar Use the POSIX version of basename() to allow compilation against non-gnu libc (e.g. musl). Include ahead of to enable using functions from the latter while preferring POSIX over GNU basename(). In veristat.c, rely on strdupa() to avoid basename() altering the passed "const char" argument. This is not needed in xskxceiver.c since the arg is mutable and the program exits immediately after usage. Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/veristat.c | 8 +++++--- tools/testing/selftests/bpf/xskxceiver.c | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c index b2854238d4a0..11ec1190d582 100644 --- a/tools/testing/selftests/bpf/veristat.c +++ b/tools/testing/selftests/bpf/veristat.c @@ -2,6 +2,7 @@ /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ #define _GNU_SOURCE #include +#include #include #include #include @@ -988,8 +989,8 @@ static void fixup_obj(struct bpf_object *obj, struct bpf_program *prog, const ch static int process_prog(const char *filename, struct bpf_object *obj, struct bpf_program *prog) { + const char *base_filename = basename(strdupa(filename)); const char *prog_name = bpf_program__name(prog); - const char *base_filename = basename(filename); char *buf; int buf_sz, log_level; struct verif_stats *stats; @@ -1056,13 +1057,14 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf static int process_obj(const char *filename) { + const char *base_filename = basename(strdupa(filename)); struct bpf_object *obj = NULL, *tobj; struct bpf_program *prog, *tprog, *lprog; libbpf_print_fn_t old_libbpf_print_fn; LIBBPF_OPTS(bpf_object_open_opts, opts); int err = 0, prog_cnt = 0; - if (!should_process_file_prog(basename(filename), NULL)) { + if (!should_process_file_prog(base_filename, NULL)) { if (env.verbose) printf("Skipping '%s' due to filters...\n", filename); env.files_skipped++; @@ -1076,7 +1078,7 @@ static int process_obj(const char *filename) } if (!env.quiet && env.out_fmt == RESFMT_TABLE) - printf("Processing '%s'...\n", basename(filename)); + printf("Processing '%s'...\n", base_filename); old_libbpf_print_fn = libbpf_set_print(libbpf_print_fn); obj = bpf_object__open_file(filename, &opts); diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 8144fd145237..92af633faea8 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include