From nobody Sun Feb 8 08:48:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1573578101; cv=none; d=zoho.com; s=zohoarc; b=g4Hyu0LiPJB/XmeDIJm1BUfluDl7gZR/31XAR64HE1Xboxm1Es8iqNmZqxWXfnBscJQr+1wIPrUUYkQSutH1woLmH5jBzEfdY59zVEw4tdbj1lWhqnSPva2BaDZF32oNDesobBNlOjx7j/OwABmvzLPWFr41qbrN9IfAhgpE1KE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573578101; 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=ILDGOALyAufR6ANBi0FBTdGAzwnXJ4QaTozdLqSQdkE=; b=IdCZH3wQ7m/AAFsVAhe6FPGjWiI4UGgqlBy5IKMwKG5Rp0B0cqaBq/tP1THmBkLcwqSAdwIeFw3DvCyCOLEXCjJ+aUJrCO9DiC2RprJPCCjDhjhXYf10JWdzMHzTtP3VGFTqIUOqtXn0eGBynmWzsEn6rwJqgp2zYZq3x5BhmRQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1573578101476472.6467153941327; Tue, 12 Nov 2019 09:01:41 -0800 (PST) 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-297-13OCLpE7O-WhZc2qppAy2Q-1; Tue, 12 Nov 2019 12:01:36 -0500 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 CB51B10225BC; Tue, 12 Nov 2019 17:01:30 +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 9231058; Tue, 12 Nov 2019 17:01:30 +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 1B7C94E570; Tue, 12 Nov 2019 17:01:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACH1R0Y012278 for ; Tue, 12 Nov 2019 12:01:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 08D1C60174; Tue, 12 Nov 2019 17:01:27 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5ED4760173 for ; Tue, 12 Nov 2019 17:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573578100; 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=ILDGOALyAufR6ANBi0FBTdGAzwnXJ4QaTozdLqSQdkE=; b=f3uoounhkc9/LFbnxXMtndeKwbubv+NA1xAh9HUij779IbJKfEDw6F/+AUsCgZhjUGkna1 faKZqgrP3hDec7Zj9Yw41aWe8O9Lz6kxW+T6ILTYNT2jJbAYB9xbD3vtE/cGg7l5lPzNM7 1kIC47VB32hVblqQBW8BB8PFakXVkzc= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 18:02:11 +0100 Message-Id: <6345b2e67bc8a7a6da1168666ebe9087f6dab397.1573578043.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/9] Remove VIR_STRNDUP usage that subtracts from a non-NULL pointer 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: 13OCLpE7O-WhZc2qppAy2Q-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" Use g_strndup in all the cases where we check upfront whether a pointer is non-NULL and then use it to calculate the copied length. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel Henrique Barboza --- src/util/virsysinfo.c | 241 ++++++++++++++++++++---------------------- 1 file changed, 112 insertions(+), 129 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 9d013067fe..635e4c4bfb 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -220,23 +220,23 @@ virSysinfoParsePPCSystem(const char *base, virSysinfo= SystemDefPtr *sysdef) cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->family, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->family =3D g_strndup(cur, eol - cur); =20 if ((cur =3D strstr(base, "model")) !=3D NULL) { cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->serial =3D g_strndup(cur, eol - cur); } =20 if ((cur =3D strstr(base, "machine")) !=3D NULL) { cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } =20 if (!def->manufacturer && !def->product && !def->version && @@ -248,7 +248,6 @@ virSysinfoParsePPCSystem(const char *base, virSysinfoSy= stemDefPtr *sysdef) *sysdef =3D def; def =3D NULL; ret =3D 0; - cleanup: virSysinfoSystemDefFree(def); return ret; } @@ -270,18 +269,17 @@ virSysinfoParsePPCProcessor(const char *base, virSysi= nfoDefPtr ret) processor =3D &ret->processor[ret->nprocessor - 1]; =20 virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(processor->processor_socket_destination, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_socket_destination =3D g_strndup(cur, + eol - cur); base =3D cur; =20 if ((cur =3D strstr(base, "cpu")) !=3D NULL) { cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(processor->processor_type, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_type =3D g_strndup(cur, eol - cur); base =3D cur; } =20 @@ -289,9 +287,8 @@ virSysinfoParsePPCProcessor(const char *base, virSysinf= oDefPtr ret) cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(processor->processor_version, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_version =3D g_strndup(cur, eol - cur); base =3D cur; } =20 @@ -354,23 +351,23 @@ virSysinfoParseARMSystem(const char *base, virSysinfo= SystemDefPtr *sysdef) cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->family, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->family =3D g_strndup(cur, eol - cur); =20 if ((cur =3D strstr(base, "model")) !=3D NULL) { cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->serial =3D g_strndup(cur, eol - cur); } =20 if ((cur =3D strstr(base, "machine")) !=3D NULL) { cur =3D strchr(cur, ':') + 1; eol =3D strchr(cur, '\n'); virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } =20 if (!def->manufacturer && !def->product && !def->version && @@ -382,7 +379,6 @@ virSysinfoParseARMSystem(const char *base, virSysinfoSy= stemDefPtr *sysdef) *sysdef =3D def; def =3D NULL; ret =3D 0; - cleanup: virSysinfoSystemDefFree(def); return ret; } @@ -402,8 +398,8 @@ virSysinfoParseARMProcessor(const char *base, virSysinf= oDefPtr ret) eol =3D strchr(tmp_base, '\n'); cur =3D strchr(tmp_base, ':') + 1; virSkipSpaces(&cur); - if (eol && VIR_STRNDUP(processor_type, cur, eol - cur) < 0) - goto error; + if (eol) + processor_type =3D g_strndup(cur, eol - cur); =20 while ((tmp_base =3D strstr(base, "processor")) !=3D NULL) { base =3D tmp_base; @@ -415,10 +411,9 @@ virSysinfoParseARMProcessor(const char *base, virSysin= foDefPtr ret) processor =3D &ret->processor[ret->nprocessor - 1]; =20 virSkipSpaces(&cur); - if (eol && - VIR_STRNDUP(processor->processor_socket_destination, - cur, eol - cur) < 0) - goto error; + if (eol) + processor->processor_socket_destination =3D g_strndup(cur, + eol - cur); =20 processor->processor_type =3D g_strdup(processor_type); =20 @@ -670,29 +665,29 @@ virSysinfoParseBIOS(const char *base, virSysinfoBIOSD= efPtr *bios) cur +=3D 8; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->vendor, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->vendor =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Release Date: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->date, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->date =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "BIOS Revision: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->release, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->release =3D g_strndup(cur, eol - cur); } =20 if (!def->vendor && !def->version && @@ -704,7 +699,6 @@ virSysinfoParseBIOS(const char *base, virSysinfoBIOSDef= Ptr *bios) *bios =3D def; def =3D NULL; ret =3D 0; - cleanup: virSysinfoBIOSDefFree(def); return ret; } @@ -728,50 +722,50 @@ virSysinfoParseX86System(const char *base, virSysinfo= SystemDefPtr *sysdef) cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->manufacturer, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->manufacturer =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Product Name: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->product, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->product =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->serial =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "UUID: ")) !=3D NULL) { cur +=3D 6; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->uuid, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->uuid =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "SKU Number: ")) !=3D NULL) { cur +=3D 12; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->sku, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->sku =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Family: ")) !=3D NULL) { cur +=3D 8; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->family, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->family =3D g_strndup(cur, eol - cur); } =20 if (!def->manufacturer && !def->product && !def->version && @@ -783,7 +777,6 @@ virSysinfoParseX86System(const char *base, virSysinfoSy= stemDefPtr *sysdef) *sysdef =3D def; def =3D NULL; ret =3D 0; - cleanup: virSysinfoSystemDefFree(def); return ret; } @@ -813,43 +806,43 @@ virSysinfoParseX86BaseBoard(const char *base, cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->manufacturer, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->manufacturer =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Product Name: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->product, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->product =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->serial =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Asset Tag: ")) !=3D NULL) { cur +=3D 11; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->asset, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->asset =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Location In Chassis: ")) !=3D NULL) { cur +=3D 21; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->location, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->location =3D g_strndup(cur, eol - cur); } =20 if (!def->manufacturer && !def->product && !def->version && @@ -898,36 +891,36 @@ virSysinfoParseX86Chassis(const char *base, cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->manufacturer, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->manufacturer =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->version, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->version =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->serial, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->serial =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Asset Tag: ")) !=3D NULL) { cur +=3D 11; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->asset, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->asset =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "SKU Number: ")) !=3D NULL) { cur +=3D 12; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(def->sku, cur, eol - cur) < 0) - goto cleanup; + if (eol) + def->sku =3D g_strndup(cur, eol - cur); } =20 if (!def->manufacturer && !def->version && @@ -939,7 +932,6 @@ virSysinfoParseX86Chassis(const char *base, *chassisdef =3D def; def =3D NULL; ret =3D 0; - cleanup: virSysinfoChassisDefFree(def); return ret; } @@ -964,86 +956,80 @@ virSysinfoParseX86Processor(const char *base, virSysi= nfoDefPtr ret) cur +=3D 20; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_socket_destination, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_socket_destination =3D g_strndup(cur, + eol - = cur); } if ((cur =3D strstr(base, "Type: ")) !=3D NULL) { cur +=3D 6; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_type, cur, eol - c= ur) < 0) - return -1; + if (eol) + processor->processor_type =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Family: ")) !=3D NULL) { cur +=3D 8; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_family, cur, eol -= cur) < 0) - return -1; + if (eol) + processor->processor_family =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Manufacturer: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_manufacturer, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_manufacturer =3D g_strndup(cur, eol -= cur); } if ((cur =3D strstr(base, "Signature: ")) !=3D NULL) { cur +=3D 11; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_signature, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_signature =3D g_strndup(cur, eol - cu= r); } if ((cur =3D strstr(base, "Version: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_version, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_version =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "External Clock: ")) !=3D NULL) { cur +=3D 16; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_external_clock, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_external_clock =3D g_strndup(cur, + eol - cur); } if ((cur =3D strstr(base, "Max Speed: ")) !=3D NULL) { cur +=3D 11; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_max_speed, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_max_speed =3D g_strndup(cur, eol - cu= r); } if ((cur =3D strstr(base, "Status: ")) !=3D NULL) { cur +=3D 8; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_status, cur, eol -= cur) < 0) - return -1; + if (eol) + processor->processor_status =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_serial_number, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_serial_number =3D g_strndup(cur, eol = - cur); } if ((cur =3D strstr(base, "Part Number: ")) !=3D NULL) { cur +=3D 13; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(processor->processor_part_number, - cur, eol - cur) < 0) - return -1; + if (eol) + processor->processor_part_number =3D g_strndup(cur, eol - = cur); } =20 base +=3D strlen("Processor Information"); @@ -1074,74 +1060,71 @@ virSysinfoParseX86Memory(const char *base, virSysin= foDefPtr ret) goto next; =20 virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_size, cur, eol - cur) < = 0) - return -1; + if (eol) + memory->memory_size =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Form Factor: ")) !=3D NULL) { cur +=3D 13; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_form_factor, - cur, eol - cur) < 0) - return -1; + if (eol) + memory->memory_form_factor =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Locator: ")) !=3D NULL) { cur +=3D 9; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_locator, cur, eol - cur)= < 0) - return -1; + if (eol) + memory->memory_locator =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Bank Locator: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_bank_locator, - cur, eol - cur) < 0) - return -1; + if (eol) + memory->memory_bank_locator =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Type: ")) !=3D NULL) { cur +=3D 6; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_type, cur, eol - cur) < = 0) - return -1; + if (eol) + memory->memory_type =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Type Detail: ")) !=3D NULL) { cur +=3D 13; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_type_detail, cur, eol - = cur) < 0) - return -1; + if (eol) + memory->memory_type_detail =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Speed: ")) !=3D NULL) { cur +=3D 7; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_speed, cur, eol - cur) <= 0) - return -1; + if (eol) + memory->memory_speed =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Manufacturer: ")) !=3D NULL) { cur +=3D 14; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_manufacturer, cur, eol -= cur) < 0) - return -1; + if (eol) + memory->memory_manufacturer =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Serial Number: ")) !=3D NULL) { cur +=3D 15; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_serial_number, - cur, eol - cur) < 0) - return -1; + if (eol) + memory->memory_serial_number =3D g_strndup(cur, eol - cur); } if ((cur =3D strstr(base, "Part Number: ")) !=3D NULL) { cur +=3D 13; eol =3D strchr(cur, '\n'); virSkipSpacesBackwards(cur, &eol); - if (eol && VIR_STRNDUP(memory->memory_part_number, cur, eol - = cur) < 0) - return -1; + if (eol) + memory->memory_part_number =3D g_strndup(cur, eol - cur); } =20 next: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list