From nobody Sun Feb 8 08:48:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1571576205; cv=none; d=zoho.com; s=zohoarc; b=ap+CmLFO+59sqCL7r6+6kXGtSO4J6Co+5ygLD6WcSvkD30T6g9yQf8lpP8AidHDz9CkNE1Nc3ccAdkRfbusc+xk9rt6qpTuxkPP3Y+wpm+F8eHT+JLKWgBsi6Pk9+vKW5hDf3/zgQcuSvL7+xYTFmo6+5anRVRjyqvJ5YQ4t0Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571576205; 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; bh=Xt6oMG+l4IZBwYBAxIJfgq5Xxh/DFnlGO1bvnmiRHO0=; b=CvMmCQyw4gd9HlCHSUINTbvoBhcv1i0QXf+E2N/+y5eBw9JoD9GYU1AzBdet9RhGL/mKlQ8OhnrfsxNtHCOEVpgVaXjwLiJEhDkPcr/hauL3yg2MLIx0TZMA+8kEWaJ0aOqKJJvlOhT8GxpNPMGcVgUvN6TdsQLJap3sXN1Wk3E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1571576205586742.8731904152056; Sun, 20 Oct 2019 05:56:45 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-CY6bgWp3OD63upBmrWGVmA-1; Sun, 20 Oct 2019 08:56:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D779107AFD9; Sun, 20 Oct 2019 12:56:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6868C5D6A7; Sun, 20 Oct 2019 12:56:36 +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 2E5573FB45; Sun, 20 Oct 2019 12:56:36 +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 x9KCts9Q023471 for ; Sun, 20 Oct 2019 08:55:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 364A63CC8; Sun, 20 Oct 2019 12:55:54 +0000 (UTC) Received: from lpt.redhat.com (ovpn-200-23.brq.redhat.com [10.40.200.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1805194B9 for ; Sun, 20 Oct 2019 12:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571576204; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Xt6oMG+l4IZBwYBAxIJfgq5Xxh/DFnlGO1bvnmiRHO0=; b=h1bXjQvB8HvOioBIdG5oa3DT5jkGpB6HFUqzzw5cSJZbnpZb9hsOSFPrtMWSQUswwcglPB fy/sr93BgKwfK1g4BVPwEteL+LxNO9HmX88v7nMncdcj+VvdusZTD7N2Bvmohu1NrZ1yvi LSe/rHI/4dbFyuMLNPOd0YtmJoEi+ic= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Sun, 20 Oct 2019 14:55:35 +0200 Message-Id: <5d0ce4f141c83c8082b8f9cf287e12802ce3e1bf.1571575889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/34] logging: use g_strdup instead of VIR_STRDUP 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: CY6bgWp3OD63upBmrWGVmA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Replace all occurrences of if (VIR_STRDUP(a, b) < 0) /* effectively dead code */ with: a =3D g_strdup(b); Signed-off-by: J=C3=A1n Tomko --- src/logging/log_daemon.c | 21 ++++++--------------- src/logging/log_daemon_config.c | 3 +-- src/logging/log_handler.c | 11 ++++------- src/logging/log_manager.c | 3 +-- 4 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 851695b109..73bd3c4ac2 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -388,9 +388,8 @@ virLogDaemonUnixSocketPaths(bool privileged, char **adminSockfile) { if (privileged) { - if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlogd-sock") < = 0 || - VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlogd-admi= n-sock") < 0) - goto error; + *sockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); + *adminSockfile =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-admin-s= ock"); } else { char *rundir =3D NULL; mode_t old_umask; @@ -623,8 +622,7 @@ virLogDaemonExecRestartStatePath(bool privileged, char **state_file) { if (privileged) { - if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlogd-restart-exec.js= on") < 0) - goto error; + *state_file =3D g_strdup(RUNSTATEDIR "/virtlogd-restart-exec.json"= ); } else { char *rundir =3D NULL; mode_t old_umask; @@ -934,14 +932,12 @@ int main(int argc, char **argv) { =20 case 'p': VIR_FREE(pid_file); - if (VIR_STRDUP_QUIET(pid_file, optarg) < 0) - goto no_memory; + pid_file =3D g_strdup(optarg); break; =20 case 'f': VIR_FREE(remote_config_file); - if (VIR_STRDUP_QUIET(remote_config_file, optarg) < 0) - goto no_memory; + remote_config_file =3D g_strdup(optarg); break; =20 case 'V': @@ -1018,8 +1014,7 @@ int main(int argc, char **argv) { =20 /* Ensure the rundir exists (on tmpfs on some systems) */ if (privileged) { - if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) - goto no_memory; + run_dir =3D g_strdup(RUNSTATEDIR "/libvirt"); } else { if (!(run_dir =3D virGetUserRuntimeDirectory())) { VIR_ERROR(_("Can't determine user directory")); @@ -1220,8 +1215,4 @@ int main(int argc, char **argv) { VIR_FREE(remote_config_file); virLogDaemonConfigFree(config); return ret; - - no_memory: - VIR_ERROR(_("Can't allocate memory")); - exit(EXIT_FAILURE); } diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_confi= g.c index c339da1808..df7c6339b7 100644 --- a/src/logging/log_daemon_config.c +++ b/src/logging/log_daemon_config.c @@ -40,8 +40,7 @@ int virLogDaemonConfigFilePath(bool privileged, char **configfile) { if (privileged) { - if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlogd.conf") <= 0) - goto error; + *configfile =3D g_strdup(SYSCONFDIR "/libvirt/virtlogd.conf"); } else { char *configdir =3D NULL; =20 diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index 025a546b51..29ea3011b9 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -239,16 +239,14 @@ virLogHandlerLogFilePostExecRestart(virLogHandlerPtr = handler, _("Missing 'driver' in JSON document")); goto error; } - if (VIR_STRDUP(file->driver, tmp) < 0) - goto error; + file->driver =3D g_strdup(tmp); =20 if ((tmp =3D virJSONValueObjectGetString(object, "domname")) =3D=3D NU= LL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing 'domname' in JSON document")); goto error; } - if (VIR_STRDUP(file->domname, tmp) < 0) - goto error; + file->domname =3D g_strdup(tmp); =20 if ((domuuid =3D virJSONValueObjectGetString(object, "domuuid")) =3D= =3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -402,9 +400,8 @@ virLogHandlerDomainOpenLogFile(virLogHandlerPtr handler, file->pipefd =3D pipefd[0]; pipefd[0] =3D -1; memcpy(file->domuuid, domuuid, VIR_UUID_BUFLEN); - if (VIR_STRDUP(file->driver, driver) < 0 || - VIR_STRDUP(file->domname, domname) < 0) - goto error; + file->driver =3D g_strdup(driver); + file->domname =3D g_strdup(domname); =20 if ((file->file =3D virRotatingFileWriterNew(path, handler->max_size, diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c index 1613d1f8a8..b60a6aaf59 100644 --- a/src/logging/log_manager.c +++ b/src/logging/log_manager.c @@ -45,8 +45,7 @@ virLogManagerDaemonPath(bool privileged) { char *path; if (privileged) { - if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0) - return NULL; + path =3D g_strdup(RUNSTATEDIR "/libvirt/virtlogd-sock"); } else { char *rundir =3D NULL; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list