From nobody Mon Feb 9 09:08:41 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1710408953188905.9734056648095; Thu, 14 Mar 2024 02:35:53 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DB70981E; Thu, 14 Mar 2024 05:35:51 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8FB631B76; Thu, 14 Mar 2024 05:34:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6BC9F1AC3; Thu, 14 Mar 2024 05:34:33 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0264B1ADA for ; Thu, 14 Mar 2024 05:34:32 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-uVDlFsWtPiuKTs-HUwVlbA-1; Thu, 14 Mar 2024 05:34:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D07A11C02D35 for ; Thu, 14 Mar 2024 09:34:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 782832166B4F for ; Thu, 14 Mar 2024 09:34:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: uVDlFsWtPiuKTs-HUwVlbA-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] virusbmock: Switch to VIR_MOCK_REAL_INIT() Date: Thu, 14 Mar 2024 10:34:27 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: OC3PBQWND7T75XQQ3CZZO6LQI7EB7CZW X-Message-ID-Hash: OC3PBQWND7T75XQQ3CZZO6LQI7EB7CZW X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710408953426100001 Since virusbmock was written 10 years ago, back when we didn't have virmock.h and its helpers, it open codes symbol resolution (VIR_MOCK_REAL_INIT). With a bit of cleanup (e.g. renaming realopen to real_open and so on) it can use virmock.h provided macros. And while at it, drop include of virusb.h - there is no compelling reason for it include the file. The mock just redirects paths passed to open()/opendir(). Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- tests/virusbmock.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/virusbmock.c b/tests/virusbmock.c index 971d98aa9a..570f7c28eb 100644 --- a/tests/virusbmock.c +++ b/tests/virusbmock.c @@ -24,25 +24,21 @@ #include #include =20 -#include "virusb.h" +#include "virmock.h" =20 #define USB_SYSFS "/sys/bus/usb" #define FAKE_USB_SYSFS "virusbtestdata/sys_bus_usb" =20 -static int (*realopen)(const char *pathname, int flags, ...); -static DIR *(*realopendir)(const char *name); +static int (*real_open)(const char *pathname, int flags, ...); +static DIR *(*real_opendir)(const char *name); =20 static void init_syms(void) { - if (realopen) + if (real_open) return; =20 - realopen =3D dlsym(RTLD_NEXT, "open"); - realopendir =3D dlsym(RTLD_NEXT, "opendir"); - if (!realopen || !realopendir) { - fprintf(stderr, "Error getting symbols"); - abort(); - } + VIR_MOCK_REAL_INIT(open); + VIR_MOCK_REAL_INIT(opendir); } =20 static char *get_fake_path(const char *real_path) @@ -66,7 +62,7 @@ DIR *opendir(const char *name) =20 path =3D get_fake_path(name); =20 - return realopendir(path); + return real_opendir(path); } =20 int open(const char *pathname, int flags, ...) @@ -91,6 +87,6 @@ int open(const char *pathname, int flags, ...) va_end(ap); } =20 - ret =3D realopen(path, flags, mode); + ret =3D real_open(path, flags, mode); return ret; } --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org