From nobody Sun Feb 8 11:17:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564671701; cv=none; d=zoho.com; s=zohoarc; b=ay5ePZHigDZfF/wnKLXVSKBM5J1XtDUe5b3GIzVQxppvDpyULqg1HTu4SDShPrPZ1Zp0pgYSrrqHrlotKtvpapDhrgtw/1vfgYw45MnOTPR8ZBYbubDzTla2iWqMhaTLHmm6HkY/ZWIyM3fkvwd/qFPoAAcCZPuxqXB+OQkXQp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564671701; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zf0L8/HqFUPSI1RMZJao/NoiooWldypLCPg+lD1Q6Nc=; b=TwI+AkV56e1Q2MLeUB+vDDgTLWfqbp9NxZqrjDgAPs/e8P2Pa2tHyRUdmAPIxRYyb92/eBFZ+6ijBTqHl4/dLFXXHZxTQ3yHnp4DmBV9tj9EpECPDr++wP33zqOz102cGDwOBxI9uhVX1hwq9cYhZgMxK1eQYlSPSSwtGsoecKo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564671701953778.8340180189349; Thu, 1 Aug 2019 08:01:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 69A7B30860DF; Thu, 1 Aug 2019 15:01:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23050196FF; Thu, 1 Aug 2019 15:01:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C47FC1806B00; Thu, 1 Aug 2019 15:01:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x71F1OZj032280 for ; Thu, 1 Aug 2019 11:01:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04D7919697; Thu, 1 Aug 2019 15:01:24 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-94.gsslab.fab.redhat.com [10.33.9.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B6EE196FE; Thu, 1 Aug 2019 15:01:23 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 1 Aug 2019 16:00:18 +0100 Message-Id: <20190801150019.10519-17-berrange@redhat.com> In-Reply-To: <20190801150019.10519-1-berrange@redhat.com> References: <20190801150019.10519-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/17] nss: remove last usages of libvirt headers X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 01 Aug 2019 15:01:41 +0000 (UTC) Use the plain libc APIs to avoid a dependancy on the main libvirt code from the nss module. Signed-off-by: Daniel P. Berrang=C3=A9 --- tools/nss/libvirt_nss.c | 16 +++++++++++----- tools/nss/libvirt_nss.h | 5 +++-- tools/nss/libvirt_nss_leases.c | 6 ++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index 2719e19cda..a9814cf0dc 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -31,13 +31,15 @@ #include #include #include +#include +#include +#include + =20 #if defined(HAVE_BSD_NSS) # include #endif =20 -#include "viralloc.h" -#include "virtime.h" #include "configmake.h" =20 #include "libvirt_nss_leases.h" @@ -146,10 +148,10 @@ findLease(const char *name, =20 DEBUG("Processing %s", path); if (findMACs(path, name, &macs, &nmacs) < 0) { - VIR_FREE(path); + free(path); goto cleanup; } - VIR_FREE(path); + free(path); #endif /* LIBVIRT_NSS_GUEST */ } =20 @@ -243,7 +245,7 @@ NSS_NAME(gethostbyname3)(const char *name, int af, stru= ct hostent *result, { enum nss_status ret =3D NSS_STATUS_UNAVAIL; char *r_name, **r_aliases, *r_addr, *r_addr_next, **r_addr_list; - VIR_AUTOFREE(leaseAddress *) addr =3D NULL; + leaseAddress *addr =3D NULL; size_t naddr, i; bool found =3D false; size_t nameLen, need, idx =3D 0; @@ -259,6 +261,7 @@ NSS_NAME(gethostbyname3)(const char *name, int af, stru= ct hostent *result, af =3D AF_INET; =20 if ((r =3D findLease(name, af, &addr, &naddr, &found, errnop)) < 0) { + free(addr); /* Error occurred. Return immediately. */ if (*errnop =3D=3D EAGAIN) { *herrnop =3D TRY_AGAIN; @@ -273,11 +276,13 @@ NSS_NAME(gethostbyname3)(const char *name, int af, st= ruct hostent *result, /* NOT found */ *errnop =3D ESRCH; *herrnop =3D HOST_NOT_FOUND; + free(addr); return NSS_STATUS_NOTFOUND; } else if (!naddr) { /* Found, but no data */ *errnop =3D ENXIO; *herrnop =3D NO_DATA; + free(addr); return NSS_STATUS_UNAVAIL; } =20 @@ -349,6 +354,7 @@ NSS_NAME(gethostbyname3)(const char *name, int af, stru= ct hostent *result, =20 ret =3D NSS_STATUS_SUCCESS; cleanup: + free(addr); return ret; } =20 diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h index 6e4be125d2..fa4ff892c6 100644 --- a/tools/nss/libvirt_nss.h +++ b/tools/nss/libvirt_nss.h @@ -30,13 +30,14 @@ =20 =20 #if 0 -# include "virerror.h" +# include # define ERROR(...) \ do { \ char ebuf[1024]; \ + strerror_r(errno, ebuf, sizeof(ebuf)); \ fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ - fprintf(stderr, " : %s\n", virStrerror(errno, ebuf, sizeof(ebuf))); \ + fprintf(stderr, " : %s\n", ebuf); \ fprintf(stderr, "\n"); \ } while (0) =20 diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 803b14cc55..ddd50288d2 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -30,7 +30,6 @@ =20 #include "libvirt_nss_leases.h" #include "libvirt_nss.h" -#include "viralloc.h" =20 enum { FIND_LEASES_STATE_START, @@ -79,6 +78,7 @@ appendAddr(const char *name ATTRIBUTE_UNUSED, } sa; unsigned char addr[16]; int err; + leaseAddress *newAddr; =20 DEBUG("IP address: %s", ipAddr); =20 @@ -131,10 +131,12 @@ appendAddr(const char *name ATTRIBUTE_UNUSED, } } =20 - if (VIR_REALLOC_N_QUIET(*tmpAddress, *ntmpAddress + 1) < 0) { + newAddr =3D realloc(*tmpAddress, sizeof(*newAddr) * (*ntmpAddress + 1)= ); + if (!newAddr) { ERROR("Out of memory"); return -1; } + *tmpAddress =3D newAddr; =20 (*tmpAddress)[*ntmpAddress].expirytime =3D expirytime; (*tmpAddress)[*ntmpAddress].af =3D family; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list