From nobody Sun Feb 8 23:42:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1638543672; cv=none; d=zohomail.com; s=zohoarc; b=hguzxL9GxvqZol2D6UkbJ49wddIXgdglxV3UWF9SkMAueiNtjVgB/e82E+SdfVSvQNXiTIK8lCL9uHY2e54WepPoxOaVSFDlcLy/ZrUlWhkdO+/1rejHhfXpBwdbADTN0Q3veasDUtbipzYlDpMkqAoD/PPj4tvhNCqu7Vt0P0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638543672; 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=Acx+1fil9Ii62rrT80j9QUW+AEWdgomv6vFj7vhSG3I=; b=Xykm9KTm0CD3NQy605iNUI/Ub7beS7FrZGsrYBmtVtAIeEM9Va0IZZW8w0by3h92Xm4P0XDR9HWxHV7lajEkik7YSPmwE4NjwzHBV924+JSXgH0moOk/9eymzyVpD/kPXgCNi05YAwL+0JLOEtcRS+VaSx5pZu/8Sf/jq3o8LmI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1638543672736577.8805499866494; Fri, 3 Dec 2021 07:01:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-324-gytn2VPnMfmhPMrsi8ABZw-1; Fri, 03 Dec 2021 10:01:05 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5BC7787110B; Fri, 3 Dec 2021 15:00:45 +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 0689D67849; Fri, 3 Dec 2021 15:00:45 +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 C81FD4CA9B; Fri, 3 Dec 2021 15:00:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B3Evnac029579 for ; Fri, 3 Dec 2021 09:57:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id A37C11042A48; Fri, 3 Dec 2021 14:57:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 059C010429D2 for ; Fri, 3 Dec 2021 14:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638543671; 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=Acx+1fil9Ii62rrT80j9QUW+AEWdgomv6vFj7vhSG3I=; b=VUKB92G19bvcIdbcSP+yneqYMdJgrvYXRqQr1O110m8PAZZJRhNNT2/glW4Pp179wbSUkv SMVGeB9EUTjUXLMPvGATsbDO4aVMIhOeMwxKTbQc9mEYTbyqlxmmAHNNSQ7XhGJr1A/3OU Z/ipDCkLx5hmJZLzMtuCdUv5X0kopDg= X-MC-Unique: gytn2VPnMfmhPMrsi8ABZw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/16] virLockDaemonClientPreExecRestart: Modernize JSON object construction Date: Fri, 3 Dec 2021 15:57:31 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1638543674488100003 Content-Type: text/plain; charset="utf-8" Use virJSONValueObjectAdd instead of step-by-step construction of the object. This also removes a handful impossible to reach errors with translatable messages. Signed-off-by: Peter Krempa --- src/locking/lock_daemon.c | 40 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index cf33d9732b..fc714052be 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -549,41 +549,21 @@ virLockDaemonClientPreExecRestart(virNetServerClient = *client G_GNUC_UNUSED, void *opaque) { virLockDaemonClient *priv =3D opaque; - virJSONValue *object =3D virJSONValueNewObject(); + virJSONValue *object =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; - if (virJSONValueObjectAppendBoolean(object, "restricted", priv->restri= cted) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set restricted data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendNumberUint(object, "ownerPid", priv->owner= Pid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerPid data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendNumberUint(object, "ownerId", priv->ownerI= d) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerId data in JSON document")); - goto error; - } - if (virJSONValueObjectAppendString(object, "ownerName", priv->ownerNam= e) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerName data in JSON document")); - goto error; - } virUUIDFormat(priv->ownerUUID, uuidstr); - if (virJSONValueObjectAppendString(object, "ownerUUID", uuidstr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot set ownerUUID data in JSON document")); - goto error; - } - return object; + if (virJSONValueObjectAdd(&object, + "b:restricted", priv->restricted, + "u:ownerPid", priv->ownerPid, + "u:ownerId", priv->ownerId, + "s:ownerName", priv->ownerName, + "s:ownerUUID", uuidstr, + NULL) < 0) + return NULL; - error: - virJSONValueFree(object); - return NULL; + return object; } --=20 2.31.1