From nobody Thu May 2 08:59:39 2024 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=1628075025; cv=none; d=zohomail.com; s=zohoarc; b=WozcANw2/WEXEiBtMHVmJUAQwYAk6AbRXWUVupLzOjSS9s4drxaoOEorSYCH+G5HJMId+mcLHMvKgwDiHIs66BKgMUkvCDXvSekrFRgjkuighL4wCpSi7uaZn8TaD9kDa8WpS6vDSg5NN2Md367F7z0xRdU0NZbrgL/OlVsbRbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075025; 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=ZYYzqGQ8MdjQuguNVhS2NSRNCaZbD4F21BAJEhAP1Fc=; b=GTgjfgo8NzxFChFvCi14Ag8i7RR2sEu+PLc8RMBAWRj4HYdmnTdu1svgDC1mTqlCgooi0qB29/e36qib8AVSNf6nkLHXwkniiXUjJH79GHuH0k23PurLKbX6++5ewkHCIGyQox59W9+6g4z0H/nNLMvHcdPYRSD/UTKAXZ9xiVg= 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 16280750251081015.7165397007792; Wed, 4 Aug 2021 04:03: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-380-jNt1lzkUMeqyDFh-AvG9og-1; Wed, 04 Aug 2021 07:03:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8222210066E5; Wed, 4 Aug 2021 11:03:35 +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 5EE6729671; Wed, 4 Aug 2021 11:03:35 +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 163444A707; Wed, 4 Aug 2021 11:03:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2oY6014199 for ; Wed, 4 Aug 2021 07:02:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 622425D9DC; Wed, 4 Aug 2021 11:02:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B71FF5DD68 for ; Wed, 4 Aug 2021 11:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075024; 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=ZYYzqGQ8MdjQuguNVhS2NSRNCaZbD4F21BAJEhAP1Fc=; b=U2Z8/WsbR/iTJCprqGPHe5FWykwkhmb7BW4Z7WuAtuAVC7+ryULvgXEThg0XyUCTJf2cWY 04mKWMwGJC5BtGozrCYb02JpMjnYhJUmVF3UptqYIoc2cSjG3ATmZRa3eKzqArGnety0d7 Qv5p2E2UVPoOQLbOSGFIey83tCPYN7s= X-MC-Unique: jNt1lzkUMeqyDFh-AvG9og-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/23] virInsertElementsN: Rename 'add' argument Date: Wed, 4 Aug 2021 13:02:21 +0200 Message-Id: <704b55a5210ffe8f64f45bd1d93784219b92e78b.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1628075026660100005 Content-Type: text/plain; charset="utf-8" The idea of @add was that the insersion/appension macros would allow adding more than one element but this feature was never implemented. 'add' is nowadays used as a dummy variable consuming the result of the VIR_TYPEMATCH compile time check. Make it obvious that we don't use 'add' by renaming it to 'typematchDummy', marking it as unused and replacing all occurences where the value was used by literal '1'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/viralloc.c | 31 ++++++++++++++++--------------- src/util/viralloc.h | 14 +------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index cd7ae9e7d1..6c76da8537 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -148,7 +148,7 @@ void virShrinkN(void *ptrptr, size_t size, size_t *coun= tptr, size_t toremove) * @size: the size of one element in bytes * @at: index within array where new elements should be added, -1 fo= r end * @countptr: variable tracking number of elements currently allocated - * @add: number of elements to add + * @typematchDummy: helper variable to consume results of compile time che= cks * @newelems: pointer to array of one or more new elements to move into * place (the originals will be zeroed out if successful * and if clearOriginal is true) @@ -160,8 +160,8 @@ void virShrinkN(void *ptrptr, size_t size, size_t *coun= tptr, size_t toremove) * already* done that. * * Re-allocate an array of *countptr elements, each sizeof(*ptrptr) bytes - * long, to be *countptr+add elements long, then appropriately move - * the elements starting at ptrptr[at] up by add elements, copy the + * long, to be *countptr elements long, then appropriately move + * the elements starting at ptrptr[at] up by 1 elements, copy the * items from newelems into ptrptr[at], then store the address of * allocated memory in *ptrptr and the new size in *countptr. If * newelems is NULL, the new elements at ptrptr[at] are instead filled @@ -173,22 +173,23 @@ void virShrinkN(void *ptrptr, size_t size, size_t *co= untptr, size_t toremove) int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr, - size_t add, void *newelems, + size_t typematchDummy G_GNUC_UNUSED, + void *newelems, bool clearOriginal, bool inPlace) { if (at =3D=3D -1) { at =3D *countptr; } else if (at > *countptr) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("out of bounds index - count %zu at %zu add %zu"), - *countptr, at, add); + _("out of bounds index - count %zu at %zu"), + *countptr, at); return -1; } if (inPlace) { - *countptr +=3D add; + *countptr +=3D 1; } else { - virExpandN(ptrptr, size, countptr, add); + virExpandN(ptrptr, size, countptr, 1); } /* memory was successfully re-allocated. Move up all elements from @@ -197,19 +198,19 @@ virInsertElementsN(void *ptrptr, size_t size, size_t = at, * from their original location. Remember that *countptr has * already been updated with new element count! */ - if (at < *countptr - add) { - memmove(*(char**)ptrptr + (size * (at + add)), + if (at < *countptr - 1) { + memmove(*(char**)ptrptr + (size * (at + 1)), *(char**)ptrptr + (size * at), - size * (*countptr - add - at)); + size * (*countptr - 1 - at)); } if (newelems) { - memcpy(*(char**)ptrptr + (size * at), newelems, size * add); + memcpy(*(char**)ptrptr + (size * at), newelems, size); if (clearOriginal) - memset((char*)newelems, 0, size * add); - } else if (inPlace || (at < *countptr - add)) { + memset((char*)newelems, 0, size); + } else if (inPlace || (at < *countptr - 1)) { /* NB: if inPlace, assume memory at the end wasn't initialized */ - memset(*(char**)ptrptr + (size * at), 0, size * add); + memset(*(char**)ptrptr + (size * at), 0, size); } return 0; diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 72e8f13bef..b637bc2ca4 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -43,7 +43,7 @@ void virResizeN(void *ptrptr, size_t size, size_t *alloc,= size_t count, size_t d void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *count= ptr, - size_t add, void *newelem, + size_t typematchDummy, void *newelem, bool clearOriginal, bool inPlace) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *count= ptr, @@ -182,12 +182,6 @@ int virDeleteElementsN(void *ptrptr, size_t size, size= _t at, size_t *countptr, * VIR_INSERT_ELEMENT_INPLACE is identical, but assumes any necessary * memory re-allocation has already been done. * - * Both functions need to send "1" as the "add" argument to - * virInsertElementsN (which has the currently-unused capability of - * inserting multiple items at once). We use this to our advantage by - * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be - * assured ptr and &newelem are of compatible types. - * * These macros are safe to use on arguments with side effects. * * Returns -1 on failure (with OOM error reported), 0 on success @@ -224,12 +218,6 @@ int virDeleteElementsN(void *ptrptr, size_t size, size= _t at, size_t *countptr, * VIR_APPEND_ELEMENT_*INPLACE are identical, but assume any * necessary memory re-allocation has already been done. * - * VIR_APPEND_ELEMENT_* all need to send "1" as the "add" argument to - * virInsertElementsN (which has the currently-unused capability of - * inserting multiple items at once). We use this to our advantage by - * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be - * assured ptr and &newelem are of compatible types. - * * These macros are safe to use on arguments with side effects. * * Returns -1 on failure (with OOM error reported), 0 on success --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075103; cv=none; d=zohomail.com; s=zohoarc; b=LSbicCJl2KViTb1JtDWSqRc3TNnU1G2/NzDN79DBf1NVuIZ547Fi6nnAeqpYZqZQras//it8BlHPX8D2e5x/eeIfMrlUl91qcHOzT9XZ/3o2cpCjmbsthBympZq5P1phGhX5szB53UUqlhKBxjhNxfvdwM6UHge3eqTwrj5Wlhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075103; 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=2o1hjneh60tqpRW/NsNxH3y5R6pBszzWc3b4WvA/dRY=; b=hoBpXxuWDnW/xUMlYGQ3TS3Y/0EMQpjxI/IcSovfhoAfhxll7Cr3aQfsc5XIiLodTx2Rc6crNW8isqlCX7AYoaJScXAjxxa7VNbGRPwKV//2yPdgsS3nq8raUpFrG+xhRzssGT++6w/f3f8nWjvZrY78eOg4s28NZ/Jjjn8222U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628075103849266.0270494157346; Wed, 4 Aug 2021 04:05:03 -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-377-v0E_2GOiO_u31pRGjhX8tw-1; Wed, 04 Aug 2021 07:03:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3CF541074677; Wed, 4 Aug 2021 11:03:38 +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 16BE11002D71; Wed, 4 Aug 2021 11:03:38 +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 C7F94180BAD0; Wed, 4 Aug 2021 11:03:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2pW3014205 for ; Wed, 4 Aug 2021 07:02:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D9B81383C; Wed, 4 Aug 2021 11:02:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCFC55D9DC for ; Wed, 4 Aug 2021 11:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075102; 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=2o1hjneh60tqpRW/NsNxH3y5R6pBszzWc3b4WvA/dRY=; b=CrgsF5WW9NBl8jC07ObK8mRX2Lvw7AW0HZhPslhzbbcW4TBSPwv0PR3FZVn2r9SfXTVP2U bUjLBO0TwTuVEMgnwOgmd1mxaos8V+jdHqtZskAgTADsFVAKl9+xyDrETz6RbFlDfWi+a+ OmYxrX+JQkwlZPmNIhOlKJu7F2+9MfA= X-MC-Unique: v0E_2GOiO_u31pRGjhX8tw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/23] virInsertElementsN: Split out actual insertion code Date: Wed, 4 Aug 2021 13:02:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075105564100002 Content-Type: text/plain; charset="utf-8" Split out the code doing the movement of the elements and insertion from the range checks. This will help in adding an error-free version for appension. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/viralloc.c | 78 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 17 deletions(-) diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 6c76da8537..c1211a5f23 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -148,7 +148,6 @@ void virShrinkN(void *ptrptr, size_t size, size_t *coun= tptr, size_t toremove) * @size: the size of one element in bytes * @at: index within array where new elements should be added, -1 fo= r end * @countptr: variable tracking number of elements currently allocated - * @typematchDummy: helper variable to consume results of compile time che= cks * @newelems: pointer to array of one or more new elements to move into * place (the originals will be zeroed out if successful * and if clearOriginal is true) @@ -168,24 +167,17 @@ void virShrinkN(void *ptrptr, size_t size, size_t *co= untptr, size_t toremove) * with zero. at must be between [0,*countptr], except that -1 is * treated the same as *countptr for convenience. * - * Returns -1 on failure, 0 on success + * Aborts on OOM failure. */ -int -virInsertElementsN(void *ptrptr, size_t size, size_t at, - size_t *countptr, - size_t typematchDummy G_GNUC_UNUSED, - void *newelems, - bool clearOriginal, bool inPlace) +static void +virInsertElementInternal(void *ptrptr, + size_t size, + size_t at, + size_t *countptr, + void *newelems, + bool clearOriginal, + bool inPlace) { - if (at =3D=3D -1) { - at =3D *countptr; - } else if (at > *countptr) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("out of bounds index - count %zu at %zu"), - *countptr, at); - return -1; - } - if (inPlace) { *countptr +=3D 1; } else { @@ -212,10 +204,62 @@ virInsertElementsN(void *ptrptr, size_t size, size_t = at, /* NB: if inPlace, assume memory at the end wasn't initialized */ memset(*(char**)ptrptr + (size * at), 0, size); } +} + + +/** + * virInsertElementsN: + * @ptrptr: pointer to hold address of allocated memory + * @size: the size of one element in bytes + * @at: index within array where new elements should be added, -1 fo= r end + * @countptr: variable tracking number of elements currently allocated + * @typematchDummy: helper variable to consume results of compile time che= cks + * @newelems: pointer to array of one or more new elements to move into + * place (the originals will be zeroed out if successful + * and if clearOriginal is true) + * @clearOriginal: false if the new item in the array should be copied + * from the original, and the original left intact. + * true if the original should be 0'd out on success. + * @inPlace: false if we should expand the allocated memory before + * moving, true if we should assume someone else *has + * already* done that. + * + * Re-allocate an array of *countptr elements, each sizeof(*ptrptr) bytes + * long, to be *countptr elements long, then appropriately move + * the elements starting at ptrptr[at] up by 1 elements, copy the + * items from newelems into ptrptr[at], then store the address of + * allocated memory in *ptrptr and the new size in *countptr. If + * newelems is NULL, the new elements at ptrptr[at] are instead filled + * with zero. at must be between [0,*countptr], except that -1 is + * treated the same as *countptr for convenience. + * + * Returns -1 on failure, 0 on success + */ +int +virInsertElementsN(void *ptrptr, + size_t size, + size_t at, + size_t *countptr, + size_t typematchDummy G_GNUC_UNUSED, + void *newelems, + bool clearOriginal, + bool inPlace) +{ + if (at =3D=3D -1) { + at =3D *countptr; + } else if (at > *countptr) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("out of bounds index - count %zu at %zu"), + *countptr, at); + return -1; + } + + virInsertElementInternal(ptrptr, size, at, countptr, newelems, clearOr= iginal, inPlace); return 0; } + /** * virDeleteElementsN: * @ptrptr: pointer to hold address of allocated memory --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075018; cv=none; d=zohomail.com; s=zohoarc; b=YnfZ1QkCkPqlN19f8rgUBLXxjojM2DMJeXvu9fz0SJoS2nCqTDoDMuyEcMrjdoG0CPZiWuYqdZ5yFJjBRmcZcroTaaa64VFpIU0LfsPeBnjCklMhMtUVOoqdsEQOs+BXuXJDFGTvJDPyNfgHmBgqhqmndDPeWsH+//K2v+feHwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075018; 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=uuGBN9kIzpmhP4xgFPvbdtxat+GsvVzCR4LELjltzKs=; b=kKWuONdNpioHSKVXFXLM6oU81TEXYharWKKjwNew+VTRgpB3EEM6davwRjtwv6HlOX3XKvi4SBSmIuKyRx/qVPvcwjBfIVq0BVe1l973OIJt+55AI99GR2NvFKaj/HTtK1kW2fDVjntJLGQwuDUXfngvzVYVplDOq2sVXcU8NPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628075018570897.5981768723253; Wed, 4 Aug 2021 04:03:38 -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-193-mI6kDO8qM96S7Dj4OaBRog-1; Wed, 04 Aug 2021 07:03:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35E7180430A; Wed, 4 Aug 2021 11:03: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 DA2221036D33; Wed, 4 Aug 2021 11:03:29 +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 A03A34A7C8; Wed, 4 Aug 2021 11:03:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2qxX014211 for ; Wed, 4 Aug 2021 07:02:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C5461383C; Wed, 4 Aug 2021 11:02:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0F075D9DC for ; Wed, 4 Aug 2021 11:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075017; 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=uuGBN9kIzpmhP4xgFPvbdtxat+GsvVzCR4LELjltzKs=; b=R2yzEt76NBcjzte+DiNuAQvCe35gguv1bsY5GoKnYa1cI8Th0YBlGMeig4ihfIC+SyzRix BViFwoUdLJEhleBuV2UjHrjqjQ4QIDkiRZ7PS/lc/d5D3I9RR1VfqhQI1JjFSt+LmINUz9 +hEN45Q1AWpGGLcfTSltmo8gbYoXSTw= X-MC-Unique: mI6kDO8qM96S7Dj4OaBRog-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/23] util: alloc: Introduce virAppendElement helper Date: Wed, 4 Aug 2021 13:02:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075019786100002 Content-Type: text/plain; charset="utf-8" The new wrapper calls virInsertElementInternal with the appropriate arguments without any checks which are unnecessary for appension. This allows to have no return value. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libvirt_private.syms | 1 + src/util/viralloc.c | 30 ++++++++++++++++++++++++++++++ src/util/viralloc.h | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6961cdb137..97ff884f7e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1760,6 +1760,7 @@ vir_g_strdup_vprintf; # util/viralloc.h +virAppendElement; virDeleteElementsN; virExpandN; virInsertElementsN; diff --git a/src/util/viralloc.c b/src/util/viralloc.c index c1211a5f23..17ce5f3dbe 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -260,6 +260,36 @@ virInsertElementsN(void *ptrptr, } +/** + * virAppendElement: + * @ptrptr: pointer to hold address of allocated memory + * @size: the size of one element in bytes + * @countptr: variable tracking number of elements currently allocated + * @typematchDummy: helper variable to consume results of compile time che= cks + * @newelem: pointer to a new element to append to @ptrptr + * (the original will be zeroed out if clearOriginal is true) + * @clearOriginal: false if the new item in the array should be copied + * from the original, and the original left intact. + * true if the original should be 0'd out on success. + * @inPlace: false if we should expand the allocated memory before + * moving, true if we should assume someone else *has + * already* done that. + * + * Re-allocate @ptrptr to fit an extra element and place @newelem at the e= nd. + */ +void +virAppendElement(void *ptrptr, + size_t size, + size_t *countptr, + size_t typematchDummy G_GNUC_UNUSED, + void *newelem, + bool clearOriginal, + bool inPlace) +{ + virInsertElementInternal(ptrptr, size, *countptr, countptr, newelem, c= learOriginal, inPlace); +} + + /** * virDeleteElementsN: * @ptrptr: pointer to hold address of allocated memory diff --git a/src/util/viralloc.h b/src/util/viralloc.h index b637bc2ca4..7669b12e89 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -46,6 +46,14 @@ int virInsertElementsN(void *ptrptr, size_t size, size_t= at, size_t *countptr, size_t typematchDummy, void *newelem, bool clearOriginal, bool inPlace) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); +void virAppendElement(void *ptrptr, + size_t size, + size_t *countptr, + size_t typematchDummy, + void *newelem, + bool clearOriginal, + bool inPlace) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *count= ptr, size_t toremove, bool inPlace) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075029; cv=none; d=zohomail.com; s=zohoarc; b=SUV9zA30tP3VjIx3LSa/zzWK3MHU/f71jcLZN+uM2shNgxZ07+YAUjKPaCHKP9VMJjLNAbn9qiHyJok3Cz+1raqZ7/hbY+gFAT2NUDbvMJ/iuf38UaAXS54m03lckaiTamd+n3/AeGrPOcX0jtehJpmgZxI2YCzmIKcn9eDFSAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075029; 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=gTk5wqsij3bPSa59VkkF5oHOCTW13YZAJML7FqNAxUw=; b=aDYFl6Zhp0Jgly11IqUlBMhEAwdHlqMwn0f30sh+lVIydG0di9V/9Yxmxmlns7Su+0BaXX6VytpiaQxH81sBU+P6UQ4vfiwAGHs+h9gHlAkOSRI6DX41vVy0ZEvePJilKN82pqQxttp1zaUYvx6UYrutJ/dzmL6JRfueMcWPYX4= 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 1628075029867462.3247510164581; Wed, 4 Aug 2021 04:03:49 -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-160-nN_ZSA_xMYK_N3XI-Snfrw-1; Wed, 04 Aug 2021 07:03:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38A04196632A; Wed, 4 Aug 2021 11:03:41 +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 1385760BF4; Wed, 4 Aug 2021 11:03:41 +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 D4A1D4A713; Wed, 4 Aug 2021 11:03:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2ruD014228 for ; Wed, 4 Aug 2021 07:02:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 874255DD68; Wed, 4 Aug 2021 11:02:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8E365D9DC for ; Wed, 4 Aug 2021 11:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075028; 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=gTk5wqsij3bPSa59VkkF5oHOCTW13YZAJML7FqNAxUw=; b=ce7u5ac/iRq3VvzFU2lOGpcKaW2tfIjrzX8+1C1DTLRBOmp2LTDPXmVJLn+DH6L1QHiymC atxMWtvj/ladLlrwdShrOZxu63nuTuJDyYNmT6SHKIjcmal67FDCO6gC42Ft8p0E/w9LP6 ZvVPoR0xuda6LMwKVlqK3VCYnVLRK5g= X-MC-Unique: nN_ZSA_xMYK_N3XI-Snfrw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/23] util: alloc: Reimplement VIR_APPEND_ELEMENT_(COPY_)INPLACE using virAppendElement Date: Wed, 4 Aug 2021 13:02:24 +0200 Message-Id: <7b6263621792f443984936e80a3bdd12ea112bc7.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 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: 1628075031115100001 Content-Type: text/plain; charset="utf-8" VIR_APPEND_ELEMENT_INPLACE and VIR_APPEND_ELEMENT_COPY_INPLACE already ignore the return value from 'virInsertElementsN' which allows a trivial conversion to virAppendElement without the need for 'ignore_value'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/viralloc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 7669b12e89..7397ee3771 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -237,13 +237,13 @@ int virDeleteElementsN(void *ptrptr, size_t size, siz= e_t at, size_t *countptr, virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, = false) #define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \ - ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), \ - &(newelem), true, true)) + virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ + VIR_TYPEMATCH(ptr, &(newelem)), \ + &(newelem), true, true) #define VIR_APPEND_ELEMENT_COPY_INPLACE(ptr, count, newelem) \ - ignore_value(virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), \ - &(newelem), false, true)) + virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ + VIR_TYPEMATCH(ptr, &(newelem)), \ + &(newelem), false, true) /* Quiet version of macros above */ #define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \ --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075018; cv=none; d=zohomail.com; s=zohoarc; b=RpKa2k+KqbM/8B9Iyztemgf/UqK9qcknQuxG4VwtPXDplQGUXVELxPtDmKoC8yLz5p0yDrwc69IbU4vlTV1BotTuJNWr3FJYuFo1C7KGb00ikBQVgUJRJ9sedfTnVMgjT28rn6rSWNvV93BEo8OSsloMXQwtOZjacWMl6BbYpV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075018; 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=Cr4nkMelFzBcLGIgzqrXEqRnaCbbN3nDqaUDrXNpZQw=; b=lHHCTC633f3M7mzgSoF8w9bge76X523429hamWkgGG+ZpynVUomoerwAEZVvL6/E2ERI85N928nKIp0CpFX5hA2m5E89wTvtCW7dSbYoSx3HWNcjXn3JohqJK6K4chhprZDCJ6i9PX8+eERj2WjHM+VM4o/gQ61XjOicKSpBKCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 16280750183141002.1991436788013; Wed, 4 Aug 2021 04:03:38 -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-221--o5aQ8DrMeeFzn22Yuf1bg-1; Wed, 04 Aug 2021 07:03:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 792631966326; Wed, 4 Aug 2021 11:03:30 +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 585446788C; Wed, 4 Aug 2021 11:03: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 0CC72180B7A2; Wed, 4 Aug 2021 11:03:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2sS7014233 for ; Wed, 4 Aug 2021 07:02:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CB1B1383C; Wed, 4 Aug 2021 11:02:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDBA15D9DC for ; Wed, 4 Aug 2021 11:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075017; 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=Cr4nkMelFzBcLGIgzqrXEqRnaCbbN3nDqaUDrXNpZQw=; b=Rq2kq1hqZ7H1zjhUdEabl74cq54FOsuagBQQZEk0of0osffn7grJTj1oeNN4CId9IWGms1 w35SUGPNhJAGCkGq1mohf1AKy5v4oBKqZIVnxYKZScpnp/Z4n7BY/mnH00enjPKsXuqUFk mIrOXKGwJpY1y4xd9Twv3TQrBwvfSgo= X-MC-Unique: -o5aQ8DrMeeFzn22Yuf1bg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/23] util: alloc: Reimplement VIR_APPEND_ELEMENT_COPY using virAppendElement Date: Wed, 4 Aug 2021 13:02:25 +0200 Message-Id: <853b4b8d98c20ac46876b795e613e3d1c7e0cc20.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.16 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: 1628075019773100001 Content-Type: text/plain; charset="utf-8" Use virAppendElement instead of virInsertElementsN to implement VIR_APPEND_ELEMENT_COPY which allows us to remove error handling as the only relevant errors were removed when switching to aborting memory allocation functions. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 29 +++++------------------------ src/conf/nwfilter_conf.c | 12 +++--------- src/conf/virnwfilterobj.c | 8 ++------ src/cpu/cpu_x86.c | 12 ++++-------- src/logging/log_handler.c | 6 ++---- src/openvz/openvz_conf.c | 5 ++--- src/qemu/qemu_domain.c | 6 +----- src/qemu/qemu_hotplug.c | 6 ++---- src/util/viralloc.h | 4 ++-- src/util/virfirewall.c | 8 ++------ tests/nwfilterxml2firewalltest.c | 7 +------ 11 files changed, 26 insertions(+), 77 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 09da4ab952..8d13e2de8e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16573,8 +16573,7 @@ virDomainMemoryInsert(virDomainDef *def, return -1; } - if (VIR_APPEND_ELEMENT_COPY(def->mems, def->nmems, mem) < 0) - return -1; + VIR_APPEND_ELEMENT_COPY(def->mems, def->nmems, mem); virDomainDefSetMemoryTotal(def, memory + mem->size); @@ -17141,10 +17140,7 @@ virDomainDefAddController(virDomainDef *def, int t= ype, int idx, int model) cont->idx =3D idx; cont->model =3D model; - if (VIR_APPEND_ELEMENT_COPY(def->controllers, def->ncontrollers, cont)= < 0) { - VIR_FREE(cont); - return NULL; - } + VIR_APPEND_ELEMENT_COPY(def->controllers, def->ncontrollers, cont); return cont; } @@ -22780,15 +22776,9 @@ virDomainIOThreadIDAdd(virDomainDef *def, iothrid->iothread_id =3D iothread_id; - if (VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, - iothrid) < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(def->iothreadids, def->niothreadids, iothrid); return iothrid; - - error: - virDomainIOThreadIDDefFree(iothrid); - return NULL; } @@ -29304,13 +29294,9 @@ virDomainGraphicsListenAppendAddress(virDomainGrap= hicsDef *def, glisten.address =3D g_strdup(address); - if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten); return 0; - error: - VIR_FREE(glisten.address); - return -1; } @@ -29326,14 +29312,9 @@ virDomainGraphicsListenAppendSocket(virDomainGraph= icsDef *def, glisten.socket =3D g_strdup(socketPath); - if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten); return 0; - - error: - VIR_FREE(glisten.socket); - return -1; } diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 6fced96865..fc81fd97ea 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -394,11 +394,9 @@ virNWFilterRuleDefAddString(virNWFilterRuleDef *nwf, const char *string, size_t maxstrlen) { - char *tmp; + char *tmp =3D g_strndup(string, maxstrlen); - tmp =3D g_strndup(string, maxstrlen); - if (VIR_APPEND_ELEMENT_COPY(nwf->strings, nwf->nstrings, tmp) < 0) - VIR_FREE(tmp); + VIR_APPEND_ELEMENT_COPY(nwf->strings, nwf->nstrings, tmp); return tmp; } @@ -2696,11 +2694,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) } if (entry->rule || entry->include) { - if (VIR_APPEND_ELEMENT_COPY(ret->filterEntries, - ret->nentries, entry) < 0) { - virNWFilterEntryFree(entry); - goto cleanup; - } + VIR_APPEND_ELEMENT_COPY(ret->filterEntries, ret->nentries,= entry); } else { virNWFilterEntryFree(entry); } diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index b64fdb9670..c3b2eb048c 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -371,12 +371,8 @@ virNWFilterObjListAssignDef(virNWFilterObjList *nwfilt= ers, if (!(obj =3D virNWFilterObjNew())) return NULL; - if (VIR_APPEND_ELEMENT_COPY(nwfilters->objs, - nwfilters->count, obj) < 0) { - virNWFilterObjUnlock(obj); - virNWFilterObjFree(obj); - return NULL; - } + VIR_APPEND_ELEMENT_COPY(nwfilters->objs, nwfilters->count, obj); + obj->def =3D def; return obj; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index a4792c21da..0238cef8a3 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -514,9 +514,8 @@ virCPUx86DataAddItem(virCPUx86Data *data, if ((existing =3D virCPUx86DataGet(data, item))) { virCPUx86DataItemSetBits(existing, item); } else { - if (VIR_APPEND_ELEMENT_COPY(data->items, data->len, - *((virCPUx86DataItem *)item)) < 0) - return -1; + VIR_APPEND_ELEMENT_COPY(data->items, data->len, + *((virCPUx86DataItem *)item)); qsort(data->items, data->len, sizeof(virCPUx86DataItem), virCPUx86DataSorter); @@ -1143,11 +1142,8 @@ x86FeatureParse(xmlXPathContextPtr ctxt, return -1; } - if (!feature->migratable && - VIR_APPEND_ELEMENT_COPY(map->migrate_blockers, - map->nblockers, - feature) < 0) - return -1; + if (!feature->migratable) + VIR_APPEND_ELEMENT_COPY(map->migrate_blockers, map->nblockers, fea= ture); if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0) return -1; diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c index dde3506fe9..5c3df37415 100644 --- a/src/logging/log_handler.c +++ b/src/logging/log_handler.c @@ -318,8 +318,7 @@ virLogHandlerNewPostExecRestart(virJSONValue *object, if (!(file =3D virLogHandlerLogFilePostExecRestart(handler, child)= )) goto error; - if (VIR_APPEND_ELEMENT_COPY(handler->files, handler->nfiles, file)= < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(handler->files, handler->nfiles, file); if ((file->watch =3D virEventAddHandle(file->pipefd, VIR_EVENT_HANDLE_READABLE, @@ -401,8 +400,7 @@ virLogHandlerDomainOpenLogFile(virLogHandler *handler, DEFAULT_MODE)) =3D=3D NULL) goto error; - if (VIR_APPEND_ELEMENT_COPY(handler->files, handler->nfiles, file) < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(handler->files, handler->nfiles, file); if ((file->watch =3D virEventAddHandle(file->pipefd, VIR_EVENT_HANDLE_READABLE, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 2a794801ae..07c2cddd92 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -206,8 +206,7 @@ openvzReadNetworkConf(virDomainDef *def, if (virDomainNetAppendIPAddress(net, token, AF_UNSPEC, 0) < 0) goto error; - if (VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, net) < 0) - goto error; + VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, net); token =3D strtok_r(NULL, " ", &saveptr); } @@ -275,7 +274,7 @@ openvzReadNetworkConf(virDomainDef *def, } } - ignore_value(VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, ne= t)); + VIR_APPEND_ELEMENT_COPY(def->nets, def->nnets, net); } } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7e2efc8168..004bfb5d83 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4001,11 +4001,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver, if (j =3D=3D def->npanics) { virDomainPanicDef *panic =3D g_new0(virDomainPanicDef, 1); - if (VIR_APPEND_ELEMENT_COPY(def->panics, - def->npanics, panic) < 0) { - VIR_FREE(panic); - return -1; - } + VIR_APPEND_ELEMENT_COPY(def->panics, def->npanics, panic); } } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6743a8a742..c00e8a7852 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1236,8 +1236,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, virDomainNetGetActualHostdev(net)) = < 0) { goto cleanup; } - if (VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net) < = 0) - goto cleanup; + VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net); /* the rest of the setup doesn't apply to hostdev interfaces, so * we can skip straight to the cleanup (nothing there applies to @@ -1272,8 +1271,7 @@ qemuDomainAttachNetDevice(virQEMUDriver *driver, * locked memory limit). This means we will need to remove it if * there is a failure. */ - if (VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net) < 0) - goto cleanup; + VIR_APPEND_ELEMENT_COPY(vm->def->nets, vm->def->nnets, net); switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 7397ee3771..70cd721bc7 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -234,8 +234,8 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_= t at, size_t *countptr, virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, f= alse) #define VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, = false) + virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, fa= lse) #define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \ virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), \ diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index e79fe52ac8..9594192a7b 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -313,13 +313,9 @@ virFirewallAddRuleFullV(virFirewall *firewall, ADD_ARG(rule, str); if (group->addingRollback) { - ignore_value(VIR_APPEND_ELEMENT_COPY(group->rollback, - group->nrollback, - rule)); + VIR_APPEND_ELEMENT_COPY(group->rollback, group->nrollback, rule); } else { - ignore_value(VIR_APPEND_ELEMENT_COPY(group->action, - group->naction, - rule)); + VIR_APPEND_ELEMENT_COPY(group->action, group->naction, rule); } diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 33ba8b9932..8c82efa060 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -269,12 +269,7 @@ virNWFilterDefToInst(const char *xml, if (!def) return -1; - if (VIR_APPEND_ELEMENT_COPY(inst->filters, - inst->nfilters, - def) < 0) { - virNWFilterDefFree(def); - goto cleanup; - } + VIR_APPEND_ELEMENT_COPY(inst->filters, inst->nfilters, def); for (i =3D 0; i < def->nentries; i++) { if (def->filterEntries[i]->rule) { --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075022; cv=none; d=zohomail.com; s=zohoarc; b=e40piCueXU6fWITkvPPH50b4MTwrprPC0EkmGkPi0pGtpvIz+mUuNpBSDOtqHEM1TCO6EUxWVi1KugWattlKBl2ey2NZAOHcmQ0LBhtmYkda0UAFFngla9/g414To5x2yZ64fF5GvJjphl3A9SBxnyK5jNFlN4MzJaCmzQfplho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075022; 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=wNeGo/9oPx/nUOVne2Mj82gsdoryEfvy802cG6vUSDw=; b=fIOpa7acr0SHFzXtZTo++vxKfEwPmvzQgNqvuVAZX+ZQwiV0CPlpNIMoXWSgrBEAY+B1e2KD3tcmryi5Ihvyk0EETW2Lv3iw9pNH/wD8DqVv2V8ETba2N/gLN6Zdba82I0YBXMRO6dOJ70Bo3yXAwMeDmb2Bd+KEhqnah4P1hZs= 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 1628075022159976.2104324286826; Wed, 4 Aug 2021 04:03:42 -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-210-qqPMNRxYPLKbhuifkcR8_g-1; Wed, 04 Aug 2021 07:03:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E3D610066EB; Wed, 4 Aug 2021 11:03:34 +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 2956310372C2; Wed, 4 Aug 2021 11:03:34 +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 DDCFE180BAB2; Wed, 4 Aug 2021 11:03:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2tAk014238 for ; Wed, 4 Aug 2021 07:02:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC2B81383C; Wed, 4 Aug 2021 11:02:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 160905D9DC for ; Wed, 4 Aug 2021 11:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075021; 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=wNeGo/9oPx/nUOVne2Mj82gsdoryEfvy802cG6vUSDw=; b=ZlK8APM/hdml9TE1hJwKz+i8GcY8FLfj8SIqVnSddD3bwq+Qmvbhf/YXo8PR1MuetSac6L VUCN0KfzBtXoPSBxW/jh79VvNNzAfFg4zwy5+PH/+X/9oD1UhehiaHatgPUtczAmoD9Up/ BnPg42VQ7aHRyNVuT5qSM3WXvH9gnY8= X-MC-Unique: qqPMNRxYPLKbhuifkcR8_g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/23] util: alloc: Reimplement VIR_APPEND_ELEMENT_QUIET using virAppendElement Date: Wed, 4 Aug 2021 13:02:26 +0200 Message-Id: <984552459055dfb5488e2543f422fbd00796744b.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075024188100001 Content-Type: text/plain; charset="utf-8" For now it was an alias to VIR_APPEND_ELEMENT. Use virAppendElement directly until VIR_APPEND_ELEMENT is refactored too and we'll be able to get rid of VIR_APPEND_ELEMENT_QUIET completely. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/viralloc.h | 3 ++- tests/virfilewrapper.c | 9 ++------- tests/virpcimock.c | 10 +++------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 70cd721bc7..c5ca8e9929 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -247,7 +247,8 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_= t at, size_t *countptr, /* Quiet version of macros above */ #define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \ - VIR_APPEND_ELEMENT(ptr, count, newelem) + virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, fal= se) /** * VIR_DELETE_ELEMENT: diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c index 30c63ecf56..3085a190fb 100644 --- a/tests/virfilewrapper.c +++ b/tests/virfilewrapper.c @@ -78,13 +78,8 @@ virFileWrapperAddPrefix(const char *prefix, init_syms(); - if (VIR_APPEND_ELEMENT_QUIET(prefixes, nprefixes, prefix) < 0 || - VIR_APPEND_ELEMENT_QUIET(overrides, noverrides, override) < 0) { - VIR_FREE(prefixes); - VIR_FREE(overrides); - fprintf(stderr, "Unable to add path override for '%s'\n", prefix); - abort(); - } + VIR_APPEND_ELEMENT_QUIET(prefixes, nprefixes, prefix); + VIR_APPEND_ELEMENT_QUIET(overrides, noverrides, override); } diff --git a/tests/virpcimock.c b/tests/virpcimock.c index be513ad918..de39fc65a4 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -428,9 +428,7 @@ pci_device_create_iommu(const struct pciDevice *dev, iommuGroup->iommu =3D dev->iommuGroup; iommuGroup->nDevicesBoundToVFIO =3D 0; /* No device bound to VFIO by d= efault */ - if (VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, - iommuGroup) < 0) - ABORT_OOM(); + VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, iommuGroup); } @@ -544,8 +542,7 @@ pci_device_new_from_stub(const struct pciDevice *data) if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", devid); - if (VIR_APPEND_ELEMENT_QUIET(pciDevices, nPCIDevices, dev) < 0) - ABORT_OOM(); + VIR_APPEND_ELEMENT_QUIET(pciDevices, nPCIDevices, dev); } static struct pciDevice * @@ -716,8 +713,7 @@ pci_driver_new(const char *name, ...) make_file(driverpath, "bind", NULL, -1); make_file(driverpath, "unbind", NULL, -1); - if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0) - ABORT_OOM(); + VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver); } static struct pciDriver * --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075043; cv=none; d=zohomail.com; s=zohoarc; b=RxQ2POAj7YLtWq7BeR8uUyuJuo8GAcHgX6NmAb7ePm7paelE3qXbu0sPNqai1Hhn7vGLVrF6S1NJhx0uezLf+N+pm0jrf3h1C29BLJlYHtdL7nfRelrINURFr7MlSseaWFaPpx9tf5eT60liMEy5IVI4xKh6ZhWS3zfuE5cnqdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075043; 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=HJXo1F/TQaur5DXwHGQki5l/V+SkDACCtkYjBipaOu8=; b=Omk1Ovz+nsOhku00fpqrdS9opHFwb/X6YM9hQj6IucVVCn1+PQXEHZC29Theh7Z0zs2XU4ia9a60AtVmxlmwxnFUovFh986ecUuKgnIpmUgEqF3Bz62KngpZaf86rSD2xi036Y0C+MaR+LQvyQsmVZDMmSekIWWX7gaoFoMtff8= 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 1628075043832792.8035123754856; Wed, 4 Aug 2021 04:04:03 -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-274-1_CQrGe8MRG58_ysEWkuyA-1; Wed, 04 Aug 2021 07:03:39 -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 5B23F1966328; Wed, 4 Aug 2021 11:03:34 +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 0FEE618432; Wed, 4 Aug 2021 11:03:34 +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 CF0734A700; Wed, 4 Aug 2021 11:03:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2vmD014243 for ; Wed, 4 Aug 2021 07:02:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 177381383C; Wed, 4 Aug 2021 11:02:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC325D9DC for ; Wed, 4 Aug 2021 11:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075042; 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=HJXo1F/TQaur5DXwHGQki5l/V+SkDACCtkYjBipaOu8=; b=bYOj6t1CvIZZqBegCCLUO4O/J34qNWJCdZLsGaXXB+/IMS4kIoYos611dDN9zO8qYQnVen 7+uWHhTSBYR5ZCngbELHV6O5x1S7Iux6Z6hTWqFMlbjnQTuezOjCD1L+ulAKQYiW4NwFBy kdUqFTVNSXGAFEP0tpE4NHkIcG8OwD0= X-MC-Unique: 1_CQrGe8MRG58_ysEWkuyA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/23] util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElement Date: Wed, 4 Aug 2021 13:02:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.15 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: 1628075044537100001 Content-Type: text/plain; charset="utf-8" Use virAppendElement instead of virInsertElementsN to implement VIR_APPEND_ELEMENT which allows us to remove error handling as the only relevant errors were removed when switching to aborting memory allocation functions. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_parse_command.c | 18 ++----- src/conf/capabilities.c | 11 +--- src/conf/domain_conf.c | 66 +++++++++-------------- src/conf/network_conf.c | 9 ++-- src/conf/node_device_conf.c | 24 ++++----- src/conf/object_event.c | 8 ++- src/conf/storage_conf.c | 6 +-- src/conf/virdomainobjlist.c | 6 +-- src/cpu/cpu_arm.c | 6 +-- src/cpu/cpu_ppc64.c | 6 +-- src/cpu/cpu_x86.c | 9 ++-- src/esx/esx_driver.c | 7 +-- src/esx/esx_network_driver.c | 3 +- src/hyperv/hyperv_driver.c | 22 +++----- src/hyperv/hyperv_network_driver.c | 3 +- src/libxl/xen_common.c | 17 ++---- src/libxl/xen_xl.c | 21 ++------ src/libxl/xen_xm.c | 12 +---- src/lxc/lxc_container.c | 5 +- src/lxc/lxc_controller.c | 3 +- src/lxc/lxc_native.c | 6 +-- src/network/bridge_driver.c | 4 +- src/node_device/node_device_driver.c | 3 +- src/nwfilter/nwfilter_ebiptables_driver.c | 3 +- src/nwfilter/nwfilter_gentech_driver.c | 10 +--- src/openvz/openvz_conf.c | 3 +- src/qemu/qemu_block.c | 9 ++-- src/qemu/qemu_command.c | 14 +++-- src/qemu/qemu_domain_address.c | 4 +- src/qemu/qemu_driver.c | 15 ++---- src/qemu/qemu_firmware.c | 3 +- src/qemu/qemu_monitor_json.c | 3 +- src/qemu/qemu_namespace.c | 5 +- src/qemu/qemu_process.c | 3 +- src/remote/remote_daemon_dispatch.c | 56 +++++++++---------- src/rpc/virnetdaemon.c | 4 +- src/rpc/virnetmessage.c | 3 +- src/rpc/virnetserver.c | 6 +-- src/security/security_dac.c | 3 +- src/security/security_manager.c | 5 +- src/security/security_selinux.c | 10 +--- src/storage/storage_backend_logical.c | 4 +- src/storage/storage_backend_rbd.c | 3 +- src/util/viralloc.h | 6 +-- src/util/viriscsi.c | 3 +- src/util/virjson.c | 5 +- src/util/virlog.c | 10 +--- src/util/virmdev.c | 7 +-- src/util/virnetdev.c | 3 +- src/util/virnvme.c | 7 ++- src/util/virpci.c | 13 +++-- src/util/virprocess.c | 3 +- src/util/virresctrl.c | 6 +-- src/util/virscsi.c | 7 +-- src/util/virscsivhost.c | 4 +- src/util/virusb.c | 4 +- src/util/virutil.c | 9 +--- src/vbox/vbox_common.c | 13 ++--- src/vmx/vmx.c | 3 +- src/vz/vz_sdk.c | 23 +++----- tests/nwfilterxml2firewalltest.c | 5 +- tests/qemumonitortestutils.c | 11 +--- tests/testutils.c | 10 ++-- tools/virsh-domain.c | 3 +- tools/vsh-table.c | 9 ++-- 65 files changed, 206 insertions(+), 399 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 9b97c262ec..04fd88872c 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -328,10 +328,7 @@ bhyveParseBhyveLPCArg(virDomainDef *def, break; } - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0) { - virDomainChrDefFree(chr); - goto error; - } + VIR_APPEND_ELEMENT(def->serials, def->nserials, chr); } VIR_FREE(type); @@ -459,8 +456,7 @@ bhyveParsePCIDisk(virDomainDef *def, disk->dst[2] =3D 'a' + idx; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto error; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); return 0; @@ -536,8 +532,7 @@ bhyveParsePCINet(virDomainDef *def, if (!mac) virDomainNetGenerateMAC(xmlopt, &net->mac); - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) - goto error; + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); return 0; error: @@ -642,11 +637,8 @@ bhyveParsePCIFbuf(virDomainDef *def, } cleanup: - if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) - goto error; - - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) - goto error; + VIR_APPEND_ELEMENT(def->videos, def->nvideos, video); + VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics); return 0; diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 15c76d791a..72d4146ac3 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -2124,10 +2124,7 @@ virCapabilitiesInitResctrlMemory(virCaps *caps) node->id =3D bank->id; node->cpus =3D virBitmapNewCopy(bank->cpus); - if (VIR_APPEND_ELEMENT(caps->host.memBW.nodes, - caps->host.memBW.nnodes, node) < 0) { - goto cleanup; - } + VIR_APPEND_ELEMENT(caps->host.memBW.nodes, caps->host.memBW.nn= odes, node); } virCapsHostMemBWNodeFree(node); node =3D NULL; @@ -2250,11 +2247,7 @@ virCapabilitiesInitCaches(virCaps *caps) &bank->controls) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(caps->host.cache.banks, - caps->host.cache.nbanks, - bank) < 0) { - goto cleanup; - } + VIR_APPEND_ELEMENT(caps->host.cache.banks, caps->host.cach= e.nbanks, bank); } virCapsHostCacheBankFree(bank); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8d13e2de8e..3415e28b95 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4820,10 +4820,7 @@ virDomainDefAddConsoleCompat(virDomainDef *def) /* create the serial port definition from the console definition */ if (def->nserials =3D=3D 0) { - if (VIR_APPEND_ELEMENT(def->serials, - def->nserials, - def->consoles[0]) < 0) - return -1; + VIR_APPEND_ELEMENT(def->serials, def->nserials, def->consoles[= 0]); /* modify it to be a serial port */ def->serials[0]->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SER= IAL; @@ -7475,9 +7472,10 @@ virDomainNetIPInfoParseXML(const char *source, goto cleanup; for (i =3D 0; i < nnodes; i++) { - if (!(ip =3D virDomainNetIPParseXML(nodes[i])) || - VIR_APPEND_ELEMENT(def->ips, def->nips, ip) < 0) + if (!(ip =3D virDomainNetIPParseXML(nodes[i]))) goto cleanup; + + VIR_APPEND_ELEMENT(def->ips, def->nips, ip); } VIR_FREE(nodes); @@ -7485,9 +7483,10 @@ virDomainNetIPInfoParseXML(const char *source, goto cleanup; for (i =3D 0; i < nnodes; i++) { - if (!(route =3D virNetDevIPRouteParseXML(source, nodes[i], ctxt)) = || - VIR_APPEND_ELEMENT(def->routes, def->nroutes, route) < 0) + if (!(route =3D virNetDevIPRouteParseXML(source, nodes[i], ctxt))) goto cleanup; + + VIR_APPEND_ELEMENT(def->routes, def->nroutes, route); } ret =3D 0; @@ -10120,8 +10119,7 @@ virDomainNetAppendIPAddress(virDomainNetDef *def, goto error; ipDef->prefix =3D prefix; - if (VIR_APPEND_ELEMENT(def->guestIP.ips, def->guestIP.nips, ipDef) < 0) - goto error; + VIR_APPEND_ELEMENT(def->guestIP.ips, def->guestIP.nips, ipDef); return 0; @@ -12464,8 +12462,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= ef *def, /* If no element was found add a new one created by parsing * element. */ if (def->nListens =3D=3D 0) { - if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen); } else { virDomainGraphicsListenDef *glisten =3D &def->listens[0]; @@ -15216,7 +15213,9 @@ virDomainChrTargetTypeToString(int deviceType, int virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev) { - return VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); + VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); + + return 0; } virDomainHostdevDef * @@ -15631,13 +15630,7 @@ int virDomainNetInsert(virDomainDef *def, virDomai= nNetDef *net) virDomainHostdevInsert(def, &net->data.hostdev.def) < 0) return -1; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) { - /* virDomainHostdevInsert just appends new hostdevs, so we are sure - * that the hostdev we've added a few lines above is at the end of - * array. Although, devices are indexed from zero ... */ - virDomainHostdevRemove(def, def->nhostdevs - 1); - return -1; - } + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); return 0; } @@ -15835,8 +15828,7 @@ virDomainNetUpdate(virDomainDef *def, } } else if (newhostdev) { /* add newhostdev to end of def->hostdevs */ - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, newhostdev) = < 0) - return -1; + VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, newhostdev); } def->nets[netidx] =3D newnet; @@ -15952,8 +15944,7 @@ virDomainNetARPInterfaces(virDomainDef *def, iface->addrs->addr =3D g_strdup(entry.ipaddr); - if (VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface) < = 0) - goto cleanup; + VIR_APPEND_ELEMENT(ifaces_ret, ifaces_count, iface); } } } @@ -16649,7 +16640,9 @@ int virDomainShmemDefInsert(virDomainDef *def, virDomainShmemDef *shmem) { - return VIR_APPEND_ELEMENT(def->shmems, def->nshmems, shmem); + VIR_APPEND_ELEMENT(def->shmems, def->nshmems, shmem); + + return 0; } @@ -17237,10 +17230,7 @@ virDomainDefMaybeAddInput(virDomainDef *def, input->type =3D type; input->bus =3D bus; - if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { - VIR_FREE(input); - return -1; - } + VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input); return 0; } @@ -18581,10 +18571,7 @@ virDomainResctrlMonDefParse(virDomainDef *def, if (virResctrlMonitorSetID(domresmon->instance, id) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(resctrl->monitors, - resctrl->nmonitors, - domresmon) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(resctrl->monitors, resctrl->nmonitors, domresmo= n); VIR_FREE(id); VIR_FREE(tmp); @@ -18697,8 +18684,7 @@ virDomainCachetuneDefParse(virDomainDef *def, goto cleanup; } - if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl); ret =3D 0; cleanup: @@ -19063,8 +19049,7 @@ virDomainMemorytuneDefParse(virDomainDef *def, * only append the new @newresctrl object to domain if any of them is * not zero. */ if (newresctrl && (nmons || n)) { - if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, newresctrl) = < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, newresctrl); } ret =3D 0; @@ -22728,8 +22713,7 @@ virDomainDefAddImplicitVideo(virDomainDef *def, vir= DomainXMLOption *xmlopt) if (!(video =3D virDomainVideoDefNew(xmlopt))) return -1; video->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; - if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) - return -1; + VIR_APPEND_ELEMENT(def->videos, def->nvideos, video); return 0; } @@ -28694,7 +28678,9 @@ virDiskNameToBusDeviceIndex(virDomainDiskDef *disk, int virDomainFSInsert(virDomainDef *def, virDomainFSDef *fs) { - return VIR_APPEND_ELEMENT(def->fss, def->nfss, fs); + VIR_APPEND_ELEMENT(def->fss, def->nfss, fs); + + return 0; } virDomainFSDef * diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index fe9919d4ce..e34ac52a68 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -643,8 +643,7 @@ virNetworkDHCPDefParseXML(const char *networkName, if (virNetworkDHCPRangeDefParseXML(networkName, def, cur, &ran= ge) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(def->ranges, def->nranges, range) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->ranges, def->nranges, range); } else if (cur->type =3D=3D XML_ELEMENT_NODE && virXMLNodeNameEqual(cur, "host")) { @@ -652,8 +651,7 @@ virNetworkDHCPDefParseXML(const char *networkName, if (virNetworkDHCPHostDefParseXML(networkName, def, cur, &host, false) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->hosts, def->nhosts, host); } else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) && cur->type =3D=3D XML_ELEMENT_NODE && virXMLNodeNameEqual(cur, "bootp")) { @@ -726,8 +724,7 @@ virNetworkDNSHostDefParseXML(const char *networkName, networkName); goto error; } - if (VIR_APPEND_ELEMENT(def->names, def->nnames, name) < = 0) - goto error; + VIR_APPEND_ELEMENT(def->names, def->nnames, name); } } cur =3D cur->next; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 332b12f997..d12d97f077 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -849,9 +849,7 @@ virNodeDevCapMdevTypesParseXML(xmlXPathContextPtr ctxt, type->name =3D virXPathString("string(./name)", ctxt); - if (VIR_APPEND_ELEMENT(*mdev_types, - *nmdev_types, type) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*mdev_types, *nmdev_types, type); } ret =3D 0; @@ -1574,10 +1572,9 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContex= tPtr ctxt, if (virPCIDeviceAddressParseXML(addrNodes[i], pciAddr) < 0) return -1; - if (VIR_APPEND_ELEMENT(pci_dev->iommuGroupDevices, - pci_dev->nIommuGroupDevices, - pciAddr) < 0) - return -1; + VIR_APPEND_ELEMENT(pci_dev->iommuGroupDevices, + pci_dev->nIommuGroupDevices, + pciAddr); } return 0; @@ -1684,10 +1681,9 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContext= Ptr ctxt, if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) return -1; - if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, - pci_dev->num_virtual_functions, - addr) < 0) - return -1; + VIR_APPEND_ELEMENT(pci_dev->virtual_functions, + pci_dev->num_virtual_functions, + addr); } pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; @@ -1896,9 +1892,9 @@ virNodeDevCapMdevAttributeParseXML(xmlXPathContextPtr= ctxt, return -1; } - return VIR_APPEND_ELEMENT(mdev->attributes, - mdev->nattributes, - attr); + VIR_APPEND_ELEMENT(mdev->attributes, mdev->nattributes, attr); + + return 0; } static int diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 4b571facc8..866d438f89 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -440,8 +440,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn, cb->filter_opaque =3D filter_opaque; cb->legacy =3D legacy; - if (VIR_APPEND_ELEMENT(cbList->callbacks, cbList->count, cb) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(cbList->callbacks, cbList->count, cb); /* When additional filtering is being done, every client callback * is matched to exactly one server callback. */ @@ -454,7 +453,6 @@ virObjectEventCallbackListAddID(virConnectPtr conn, ret++; } - cleanup: virObjectEventCallbackFree(cb); return ret; } @@ -642,8 +640,8 @@ virObjectEventQueuePush(virObjectEventQueue *evtQueue, if (!evtQueue) return -1; - if (VIR_APPEND_ELEMENT(evtQueue->events, evtQueue->count, event) < 0) - return -1; + VIR_APPEND_ELEMENT(evtQueue->events, evtQueue->count, event); + return 0; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 2aa9a3d8f9..ad2eb66417 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -609,11 +609,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, return -1; } - if (VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev) < 0)= { - virStoragePoolSourceDeviceClear(&dev); - return -1; - } - + VIR_APPEND_ELEMENT(source->devices, source->ndevice, dev); } sourcedir =3D virXPathString("string(./dir/@path)", ctxt); diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 43d09692a9..5c40d697dc 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -1027,11 +1027,7 @@ virDomainObjListConvert(virDomainObjList *domlist, virObjectRef(vm); - if (VIR_APPEND_ELEMENT(*vms, *nvms, vm) < 0) { - virObjectRWUnlock(domlist); - virObjectUnref(vm); - goto error; - } + VIR_APPEND_ELEMENT(*vms, *nvms, vm); } virObjectRWUnlock(domlist); diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 1e5ac558b2..09ade1d422 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -282,8 +282,7 @@ virCPUarmVendorParse(xmlXPathContextPtr ctxt, return -1; } - if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) - return -1; + VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor); return 0; } @@ -368,8 +367,7 @@ virCPUarmModelParse(xmlXPathContextPtr ctxt, return -1; } - if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0) - return -1; + VIR_APPEND_ELEMENT(map->models, map->nmodels, model); return 0; } diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index c68a0f3656..4909f61ff1 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -285,8 +285,7 @@ ppc64VendorParse(xmlXPathContextPtr ctxt G_GNUC_UNUSED, return -1; } - if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) - return -1; + VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor); return 0; } @@ -361,8 +360,7 @@ ppc64ModelParse(xmlXPathContextPtr ctxt, model->data.pvr[i].mask =3D pvr; } - if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0) - return -1; + VIR_APPEND_ELEMENT(map->models, map->nmodels, model); return 0; } diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 0238cef8a3..1b829e5658 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -937,8 +937,7 @@ x86VendorParse(xmlXPathContextPtr ctxt, if (virCPUx86VendorToData(string, &vendor->data) < 0) return -1; - if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) - return -1; + VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor); return 0; } @@ -1145,8 +1144,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, if (!feature->migratable) VIR_APPEND_ELEMENT_COPY(map->migrate_blockers, map->nblockers, fea= ture); - if (VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature) < 0) - return -1; + VIR_APPEND_ELEMENT(map->features, map->nfeatures, feature); return 0; } @@ -1679,8 +1677,7 @@ x86ModelParse(xmlXPathContextPtr ctxt, if (x86ModelParseFeatures(model, ctxt, map) < 0) return -1; - if (VIR_APPEND_ELEMENT(map->models, map->nmodels, model) < 0) - return -1; + VIR_APPEND_ELEMENT(map->models, map->nmodels, model); return 0; } diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 75eee49775..5d9687733f 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -5166,8 +5166,7 @@ esxDomainInterfaceAddresses(virDomainPtr domain, else if (ret =3D=3D 0) continue; - if (VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr)= < 0) - goto cleanup; + VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr); } } else { esxVI_String *str; @@ -5182,9 +5181,7 @@ esxDomainInterfaceAddresses(virDomainPtr domain, else if (ret =3D=3D 0) continue; - if (VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr)= < 0) - goto cleanup; - + VIR_APPEND_ELEMENT(iface->addrs, addrs_count, ip_addr); } } diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index 0a0a3dda89..a87ec6a377 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -900,8 +900,7 @@ esxConnectListAllNetworks(virConnectPtr conn, virNetworkPtr net =3D virtualswitchToNetwork(conn, hostVirtual= Switch); if (!net) goto cleanup; - if (VIR_APPEND_ELEMENT(*nets, count, net) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*nets, count, net); } else { ++count; } diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index ff20d5548b..8996394291 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1203,8 +1203,7 @@ hypervDomainDefAppendController(virDomainDef *def, controller->idx =3D idx; - if (VIR_APPEND_ELEMENT(def->controllers, def->ncontrollers, controller= ) < 0) - return -1; + VIR_APPEND_ELEMENT(def->controllers, def->ncontrollers, controller); return 0; } @@ -1270,8 +1269,7 @@ hypervDomainDefAppendDisk(virDomainDef *def, disk->info.addr.drive.target =3D 0; disk->info.addr.drive.unit =3D addr; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - return -1; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); return 0; } @@ -1283,8 +1281,7 @@ hypervDomainDefParseFloppyStorageExtent(virDomainDef = *def, virDomainDiskDef *dis disk->bus =3D VIR_DOMAIN_DISK_BUS_FDC; disk->dst =3D g_strdup("fda"); - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - return -1; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); return 0; } @@ -1456,8 +1453,7 @@ hypervDomainDefParsePhysicalDisk(hypervPrivate *priv, disk->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); result =3D 0; @@ -1579,10 +1575,7 @@ hypervDomainDefParseSerial(virDomainDef *def, Msvm_R= esourceAllocationSettingData serial->source->data.file.path =3D g_strdup(srcPath); - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, serial) < 0) { - virDomainChrDefFree(serial); - return -1; - } + VIR_APPEND_ELEMENT(def->serials, def->nserials, serial); } return 0; @@ -1661,10 +1654,7 @@ hypervDomainDefParseEthernetAdapter(virDomainDef *de= f, /* get bridge name */ ndef->data.bridge.brname =3D g_strdup(vSwitch->data->Name); - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, ndef) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not append d= efinition to domain")); - return -1; - } + VIR_APPEND_ELEMENT(def->nets, def->nnets, ndef); return 0; } diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network= _driver.c index 93ef01c9aa..a794a681b5 100644 --- a/src/hyperv/hyperv_network_driver.c +++ b/src/hyperv/hyperv_network_driver.c @@ -134,8 +134,7 @@ hypervConnectListAllNetworks(virConnectPtr conn, virNetworkPtr net =3D hypervMsvmVirtualSwitchToNetwork(conn, e= ntry); if (!net) goto cleanup; - if (VIR_APPEND_ELEMENT(*nets, count, net) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*nets, count, net); } else { ++count; } diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 284d63a6aa..87f090f979 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -495,10 +495,7 @@ xenParsePCIList(virConf *conf, virDomainDef *def) if (!(hostdev =3D xenParsePCI(entry))) return -1; - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev) < 0= ) { - virDomainHostdevDefFree(hostdev); - return -1; - } + VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); } return 0; @@ -983,8 +980,7 @@ xenParseCharDev(virConf *conf, virDomainDef *def, const= char *nativeFormat) goto cleanup; chr->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; chr->target.port =3D portnum; - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) <= 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->serials, def->nserials, chr); } } else { g_autofree char *serial =3D NULL; @@ -1265,7 +1261,6 @@ xenParseVifList(virConf *conf, virDomainDef *def, con= st char *vif_typename) for (list =3D list->list; list; list =3D list->next) { virDomainNetDef *net =3D NULL; - int rc; if ((list->type !=3D VIR_CONF_STRING) || (list->str =3D=3D NULL)) continue; @@ -1273,11 +1268,7 @@ xenParseVifList(virConf *conf, virDomainDef *def, co= nst char *vif_typename) if (!(net =3D xenParseVif(list->str, vif_typename))) return -1; - rc =3D VIR_APPEND_ELEMENT(def->nets, def->nnets, net); - if (rc < 0) { - virDomainNetDefFree(net); - return -1; - } + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); } return 0; @@ -1339,7 +1330,7 @@ xenParseSxprSound(virDomainDef *def, snddef =3D g_new0(virDomainSoundDef, 1); snddef->model =3D model; - ignore_value(VIR_APPEND_ELEMENT(def->sounds, def->nsounds, snd= def)); + VIR_APPEND_ELEMENT(def->sounds, def->nsounds, snddef); if (!next) break; diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index c0905b08d8..5d4a273ff1 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -796,8 +796,7 @@ xenParseXLDisk(virConf *conf, virDomainDef *def) else disk->bus =3D VIR_DOMAIN_DISK_BUS_IDE; - if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) - goto fail; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); libxl_device_disk_dispose(libxldisk); @@ -855,10 +854,7 @@ xenParseXLInputDevs(virConf *conf, virDomainDef *def) input->type =3D VIR_DOMAIN_INPUT_TYPE_TABLET; else if (STREQ(str, "keyboard")) input->type =3D VIR_DOMAIN_INPUT_TYPE_KBD; - if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) <= 0) { - virDomainInputDefFree(input); - return -1; - } + VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input); } val =3D val->next; } @@ -928,10 +924,7 @@ xenParseXLUSBController(virConf *conf, virDomainDef *d= ef) controller->model =3D usbctrl_type; controller->opts.usbopts.ports =3D usbctrl_ports; - if (VIR_APPEND_ELEMENT(def->controllers, def->ncontrollers, co= ntroller) < 0) { - virDomainControllerDefFree(controller); - return -1; - } + VIR_APPEND_ELEMENT(def->controllers, def->ncontrollers, contro= ller); skipusbctrl: list =3D list->next; @@ -995,10 +988,7 @@ xenParseXLUSB(virConf *conf, virDomainDef *def) hostdev->source.subsys.u.usb.bus =3D busNum; hostdev->source.subsys.u.usb.device =3D devNum; - if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev)= < 0) { - virDomainHostdevDefFree(hostdev); - return -1; - } + VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev); skipusb: list =3D list->next; @@ -1073,8 +1063,7 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) channel->targetType =3D VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN; channel->target.name =3D g_steal_pointer(&name); - if (VIR_APPEND_ELEMENT(def->channels, def->nchannels, channel)= < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->channels, def->nchannels, channel); skipchannel: list =3D list->next; diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index feec25b9f4..ac86ddf9b7 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -255,16 +255,11 @@ xenParseXMDiskList(virConf *conf, virDomainDef *def) continue; /* Maintain list in sorted order according to target device name */ - rc =3D VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); - virDomainDiskDefFree(disk); - - if (rc < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); } ret =3D 0; - cleanup: g_strfreev(disks); return ret; } @@ -402,10 +397,7 @@ xenParseXMInputDevs(virConf *conf, virDomainDef *def) input->type =3D VIR_DOMAIN_INPUT_TYPE_TABLET; else if (STREQ(str, "keyboard")) input->type =3D VIR_DOMAIN_INPUT_TYPE_KBD; - if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) { - virDomainInputDefFree(input); - return -1; - } + VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input); } } return 0; diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 1ff3159fd2..1cadfe70e0 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -794,10 +794,7 @@ static int lxcContainerSetReadOnly(void) tmp =3D g_strdup(mntent.mnt_dir); - if (VIR_APPEND_ELEMENT(mounts, nmounts, tmp) < 0) { - g_free(tmp); - goto cleanup; - } + VIR_APPEND_ELEMENT(mounts, nmounts, tmp); } if (!mounts) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 066e013ed4..8953e0c904 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -597,8 +597,7 @@ static int virLXCControllerAppendNBDPids(virLXCControll= er *ctrl, return -1; for (i =3D 0; i < npids; i++) { - if (VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]) < 0) - return -1; + VIR_APPEND_ELEMENT(ctrl->nbdpids, ctrl->nnbdpids, pids[i]); } return 0; diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 4bdd960e23..9bf079bbb2 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -448,8 +448,7 @@ lxcAddNetworkRouteDefinition(const char *address, 0, false))) return -1; - if (VIR_APPEND_ELEMENT(*routes, *nroutes, route) < 0) - return -1; + VIR_APPEND_ELEMENT(*routes, *nroutes, route); return 0; } @@ -569,8 +568,7 @@ lxcNetworkParseDataIPs(const char *name, g_strfreev(ipparts); - if (VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip) < 0) - return -1; + VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip); return 0; } diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index a711b34c48..c9ee4b1a4e 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4227,9 +4227,7 @@ networkGetDHCPLeases(virNetworkPtr net, lease->clientid =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "client-id")); lease->hostname =3D g_strdup(virJSONValueObjectGetString(lease= _tmp, "hostname")); - if (VIR_APPEND_ELEMENT(leases_ret, nleases, lease) < 0) - goto cleanup; - + VIR_APPEND_ELEMENT(leases_ret, nleases, lease); } else { nleases++; } diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_de= vice_driver.c index 6f8968f1f0..65c163f519 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -1191,8 +1191,7 @@ nodeDeviceParseMdevctlJSON(const char *jsonstring, goto error; } - if (VIR_APPEND_ELEMENT(outdevs, noutdevs, child) < 0) - goto error; + VIR_APPEND_ELEMENT(outdevs, noutdevs, child); } } diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index ec17d43c4e..63ba69f794 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -3315,8 +3315,7 @@ ebtablesGetSubChainInsts(GHashTable *chains, inst->protoidx =3D idx; inst->filtername =3D filter_names[i].key; - if (VIR_APPEND_ELEMENT(*insts, *ninsts, inst) < 0) - return -1; + VIR_APPEND_ELEMENT(*insts, *ninsts, inst); } return 0; diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 43d2a61e55..4ea0f6f0d6 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -266,10 +266,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDef *def, if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(inst->rules, - inst->nrules, - ruleinst) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(inst->rules, inst->nrules, ruleinst); ret =3D 0; cleanup: @@ -316,10 +313,7 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverState= *driver, break; } - if (VIR_APPEND_ELEMENT(inst->filters, - inst->nfilters, - obj) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(inst->filters, inst->nfilters, obj); obj =3D NULL; if (virNWFilterDefToInst(driver, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 07c2cddd92..694b048e2b 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -355,8 +355,7 @@ openvzReadFSConf(virDomainDef *def, } } - if (VIR_APPEND_ELEMENT(def->fss, def->nfss, fs) < 0) - goto error; + VIR_APPEND_ELEMENT(def->fss, def->nfss, fs); VIR_FREE(temp); diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 4691dff4f7..e09c7e66c8 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1962,8 +1962,7 @@ qemuBlockStorageSourceChainDetachPrepareBlockdev(virS= torageSource *src) if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL))) return NULL; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend) < 0) - return NULL; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend); } return g_steal_pointer(&data); @@ -1990,8 +1989,7 @@ qemuBlockStorageSourceChainDetachPrepareDrive(virStor= ageSource *src, if (!(backend =3D qemuBlockStorageSourceDetachPrepare(src, driveAlias)= )) return NULL; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend) < 0) - return NULL; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend); return g_steal_pointer(&data); } @@ -2016,8 +2014,7 @@ qemuBlockStorageSourceChainDetachPrepareChardev(char = *chardevAlias) backend->chardevAlias =3D chardevAlias; backend->chardevAdded =3D true; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend) < 0) - return NULL; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend); return g_steal_pointer(&data); } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 156af4caee..4381ea7d8b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8591,9 +8591,10 @@ qemuBuildInterfaceCommandLine(virQEMUDriver *driver, */ if (driver->privileged && nicindexes && nnicindexes && net->ifname) { - if (virNetDevGetIndex(net->ifname, &nicindex) < 0 || - VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < = 0) + if (virNetDevGetIndex(net->ifname, &nicindex) < 0) goto cleanup; + + VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex); } break; } @@ -11005,8 +11006,7 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDo= mainDiskDef *disk, if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, elem, qemuCap= s) < 0) return NULL; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) - return NULL; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem); return g_steal_pointer(&data); } @@ -11030,8 +11030,7 @@ qemuBuildStorageSourceChainAttachPrepareChardev(vir= DomainDiskDef *disk) if (!(elem =3D qemuBuildStorageSourceAttachPrepareChardev(disk))) return NULL; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) - return NULL; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem); return g_steal_pointer(&data); } @@ -11051,8 +11050,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevOne= (qemuBlockStorageSourceChainD if (qemuBuildStorageSourceAttachPrepareCommon(src, elem, qemuCaps) < 0) return -1; - if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) - return -1; + VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem); return 0; } diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 6cd0cb8c84..40e84cce9c 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2969,12 +2969,10 @@ qemuDomainUSBAddressAddHubs(virDomainDef *def) hub =3D g_new0(virDomainHubDef, 1); hub->type =3D VIR_DOMAIN_HUB_TYPE_USB; - if (VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub); } ret =3D 0; - cleanup: VIR_FREE(hub); return ret; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d8c431b41a..e53f167575 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7245,8 +7245,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, case VIR_DOMAIN_DEVICE_SOUND: sound =3D dev->data.sound; - if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0) - return -1; + VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound); dev->data.sound =3D NULL; break; @@ -7319,8 +7318,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, return -1; } - if (VIR_APPEND_ELEMENT(vmdef->rngs, vmdef->nrngs, dev->data.rng) <= 0) - return -1; + VIR_APPEND_ELEMENT(vmdef->rngs, vmdef->nrngs, dev->data.rng); dev->data.rng =3D NULL; break; @@ -7342,8 +7340,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, case VIR_DOMAIN_DEVICE_REDIRDEV: redirdev =3D dev->data.redirdev; - if (VIR_APPEND_ELEMENT(vmdef->redirdevs, vmdef->nredirdevs, redird= ev) < 0) - return -1; + VIR_APPEND_ELEMENT(vmdef->redirdevs, vmdef->nredirdevs, redirdev); dev->data.redirdev =3D NULL; break; @@ -7369,8 +7366,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, break; case VIR_DOMAIN_DEVICE_INPUT: - if (VIR_APPEND_ELEMENT(vmdef->inputs, vmdef->ninputs, dev->data.in= put) < 0) - return -1; + VIR_APPEND_ELEMENT(vmdef->inputs, vmdef->ninputs, dev->data.input); break; case VIR_DOMAIN_DEVICE_VSOCK: @@ -17665,8 +17661,7 @@ qemuDomainGetResctrlMonData(virQEMUDriver *driver, &res->stats, &res->nstats) < 0) goto error; - if (VIR_APPEND_ELEMENT(*resdata, *nresdata, res) < 0) - goto error; + VIR_APPEND_ELEMENT(*resdata, *nresdata, res); } } diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 5b9926f2bc..17380b7573 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1484,8 +1484,7 @@ qemuFirmwareGetSupported(const char *machine, tmp->name =3D g_strdup(fwpath); tmp->nvram =3D g_strdup(nvrampath); - if (VIR_APPEND_ELEMENT(*fws, *nfws, tmp) < 0) - return -1; + VIR_APPEND_ELEMENT(*fws, *nfws, tmp); } } } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index ca2c3bb6cf..14dca96afc 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9253,8 +9253,7 @@ qemuMonitorJSONGetJobInfo(qemuMonitor *mon, if (!(job =3D qemuMonitorJSONGetJobInfoOne(virJSONValueArrayGet(da= ta, i)))) return -1; - if (VIR_APPEND_ELEMENT(*jobs, *njobs, job) < 0) - return -1; + VIR_APPEND_ELEMENT(*jobs, *njobs, job); } return 0; diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index e7716d1944..ca59b5d95b 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1226,9 +1226,8 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *d= ata, g_free(next); next =3D g_strdup(item.target); - if (addToData && - VIR_APPEND_ELEMENT(data->items, data->nitems, item) < 0) - return -1; + if (addToData) + VIR_APPEND_ELEMENT(data->items, data->nitems, item); if (!isLink) break; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 521fda57da..4730d52f01 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6001,8 +6001,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driv= er, vcpupriv->vcpus !=3D 0) { vcpupriv->alias =3D g_strdup_printf("vcpu%zu", i); - if (VIR_APPEND_ELEMENT(bootHotplug, nbootHotplug, vcpu) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(bootHotplug, nbootHotplug, vcpu); } } diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 65aa20f7d1..99ae25c5f7 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -4120,10 +4120,9 @@ remoteDispatchConnectDomainEventRegister(virNetServe= r *server G_GNUC_UNUSED, callback->callbackID =3D -1; callback->legacy =3D true; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->domainEventCallbacks, - priv->ndomainEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->domainEventCallbacks, + priv->ndomainEventCallbacks, + callback); if ((callbackID =3D virConnectDomainEventRegisterAny(conn, NULL, @@ -4348,10 +4347,9 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSe= rver *server G_GNUC_UNUSED, callback->callbackID =3D -1; callback->legacy =3D true; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->domainEventCallbacks, - priv->ndomainEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->domainEventCallbacks, + priv->ndomainEventCallbacks, + callback); if ((callbackID =3D virConnectDomainEventRegisterAny(conn, NULL, @@ -4422,10 +4420,9 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(= virNetServer *server G_GNUC_ callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->domainEventCallbacks, - priv->ndomainEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->domainEventCallbacks, + priv->ndomainEventCallbacks, + callback); if ((callbackID =3D virConnectDomainEventRegisterAny(conn, dom, @@ -5898,10 +5895,9 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetS= erver *server G_GNUC_UNUSED, callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->networkEventCallbacks, - priv->nnetworkEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->networkEventCallbacks, + priv->nnetworkEventCallbacks, + callback); if ((callbackID =3D virConnectNetworkEventRegisterAny(conn, net, @@ -6018,10 +6014,9 @@ remoteDispatchConnectStoragePoolEventRegisterAny(vir= NetServer *server G_GNUC_UNU callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->storageEventCallbacks, - priv->nstorageEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->storageEventCallbacks, + priv->nstorageEventCallbacks, + callback); if ((callbackID =3D virConnectStoragePoolEventRegisterAny(conn, pool, @@ -6137,10 +6132,9 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virN= etServer *server G_GNUC_UNUS callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->nodeDeviceEventCallbacks, - priv->nnodeDeviceEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->nodeDeviceEventCallbacks, + priv->nnodeDeviceEventCallbacks, + callback); if ((callbackID =3D virConnectNodeDeviceEventRegisterAny(conn, dev, @@ -6256,10 +6250,9 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSe= rver *server G_GNUC_UNUSED, callback->eventID =3D args->eventID; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->secretEventCallbacks, - priv->nsecretEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->secretEventCallbacks, + priv->nsecretEventCallbacks, + callback); if ((callbackID =3D virConnectSecretEventRegisterAny(conn, secret, @@ -6370,10 +6363,9 @@ qemuDispatchConnectDomainMonitorEventRegister(virNet= Server *server G_GNUC_UNUSED callback->eventID =3D -1; callback->callbackID =3D -1; ref =3D callback; - if (VIR_APPEND_ELEMENT(priv->qemuEventCallbacks, - priv->nqemuEventCallbacks, - callback) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(priv->qemuEventCallbacks, + priv->nqemuEventCallbacks, + callback); if ((callbackID =3D virConnectDomainQemuMonitorEventRegister(conn, dom, diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c index b6f3233f64..444fe3dbe7 100644 --- a/src/rpc/virnetdaemon.c +++ b/src/rpc/virnetdaemon.c @@ -237,7 +237,9 @@ collectServers(void *payload, if (!srv) return -1; - return VIR_APPEND_ELEMENT(*data->servers, data->nservers, srv); + VIR_APPEND_ELEMENT(*data->servers, data->nservers, srv); + + return 0; } diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index e0fbd607bf..ca11f1688e 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -593,8 +593,7 @@ int virNetMessageAddFD(virNetMessage *msg, newfd); goto error; } - if (VIR_APPEND_ELEMENT(msg->fds, msg->nfds, newfd) < 0) - goto error; + VIR_APPEND_ELEMENT(msg->fds, msg->nfds, newfd); return 0; error: VIR_FORCE_CLOSE(newfd); diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index cfb65f8b5f..bb1a96b65e 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -1086,16 +1086,12 @@ virNetServerGetClients(virNetServer *srv, for (i =3D 0; i < srv->nclients; i++) { virNetServerClient *client =3D virObjectRef(srv->clients[i]); - if (VIR_APPEND_ELEMENT(list, nclients, client) < 0) { - virObjectUnref(client); - goto cleanup; - } + VIR_APPEND_ELEMENT(list, nclients, client); } *clts =3D g_steal_pointer(&list); ret =3D nclients; - cleanup: virObjectListFreeCount(list, nclients); virObjectUnlock(srv); return ret; diff --git a/src/security/security_dac.c b/src/security/security_dac.c index b874dd4ab6..04b9ecf028 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -121,8 +121,7 @@ virSecurityDACChownListAppend(virSecurityDACChownList *= list, item->remember =3D remember; item->restore =3D restore; - if (VIR_APPEND_ELEMENT(list->items, list->nItems, item) < 0) - return -1; + VIR_APPEND_ELEMENT(list->items, list->nItems, item); return 0; } diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index 0af581bc8b..9906c1691d 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -684,9 +684,8 @@ virSecurityManagerGenLabel(virSecurityManager *mgr, } else { /* The seclabel must be added to @vm prior calling domainGenSe= curityLabel * which may require seclabel to be presented already */ - if (generated && - VIR_APPEND_ELEMENT(vm->seclabels, vm->nseclabels, seclabel= ) < 0) - goto cleanup; + if (generated) + VIR_APPEND_ELEMENT(vm->seclabels, vm->nseclabels, seclabel= ); if (sec_managers[i]->drv->domainGenSecurityLabel(sec_managers[= i], vm) < 0) { if (VIR_DELETE_ELEMENT(vm->seclabels, diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 5f98d4d47a..30fb6028aa 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -125,11 +125,9 @@ virSecuritySELinuxContextListAppend(virSecuritySELinux= ContextList *list, item->remember =3D remember; item->restore =3D restore; - if (VIR_APPEND_ELEMENT(list->items, list->nItems, item) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(list->items, list->nItems, item); ret =3D 0; - cleanup: virSecuritySELinuxContextItemFree(item); return ret; } @@ -1894,11 +1892,7 @@ virSecuritySELinuxSetImageLabelInternal(virSecurityM= anager *mgr, if (!disk_seclabel) return -1; disk_seclabel->labelskip =3D true; - if (VIR_APPEND_ELEMENT(src->seclabels, src->nseclabels, - disk_seclabel) < 0) { - virSecurityDeviceLabelDefFree(disk_seclabel); - return -1; - } + VIR_APPEND_ELEMENT(src->seclabels, src->nseclabels, disk_seclabel); ret =3D 0; } diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 02ede74aeb..c23d0060ed 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -201,9 +201,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, extent.start =3D offset * size; extent.end =3D (offset * size) + length; - if (VIR_APPEND_ELEMENT(vol->source.extents, vol->source.nextent, - extent) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(vol->source.extents, vol->source.nextent, exten= t); } ret =3D 0; diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index a4e8115dc4..28b4b7fae6 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -639,8 +639,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= te *ptr) namedup =3D g_strdup(name); - if (VIR_APPEND_ELEMENT(names, nnames, namedup) < 0) - return NULL; + VIR_APPEND_ELEMENT(names, nnames, namedup); name +=3D strlen(name) + 1; } diff --git a/src/util/viralloc.h b/src/util/viralloc.h index c5ca8e9929..f02d634eea 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -227,12 +227,10 @@ int virDeleteElementsN(void *ptrptr, size_t size, siz= e_t at, size_t *countptr, * necessary memory re-allocation has already been done. * * These macros are safe to use on arguments with side effects. - * - * Returns -1 on failure (with OOM error reported), 0 on success */ #define VIR_APPEND_ELEMENT(ptr, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), -1, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, f= alse) + virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ + VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, fal= se) #define VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) \ virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, fa= lse) diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index ac48527dde..ab4363a5ab 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -369,8 +369,7 @@ virISCSIGetTargets(char **const groups, target =3D g_strdup(groups[1]); - if (VIR_APPEND_ELEMENT(list->targets, list->ntargets, target) < 0) - return -1; + VIR_APPEND_ELEMENT(list->targets, list->ntargets, target); return 0; } diff --git a/src/util/virjson.c b/src/util/virjson.c index b5f553a724..9adcea4fff 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -599,8 +599,9 @@ virJSONValueObjectInsert(virJSONValue *object, ret =3D VIR_INSERT_ELEMENT(object->data.object.pairs, 0, object->data.object.npairs, pair); } else { - ret =3D VIR_APPEND_ELEMENT(object->data.object.pairs, - object->data.object.npairs, pair); + VIR_APPEND_ELEMENT(object->data.object.pairs, + object->data.object.npairs, pair); + ret =3D 0; } if (ret =3D=3D 0) diff --git a/src/util/virlog.c b/src/util/virlog.c index 3ad043d98a..ac35e36148 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1638,10 +1638,7 @@ virLogParseOutputs(const char *src, virLogOutput ***= outputs) * lose the old entry */ at =3D virLogFindOutput(list, noutputs, output->dest, output->name= ); - if (VIR_APPEND_ELEMENT(list, noutputs, output) < 0) { - virLogOutputFree(output); - return -1; - } + VIR_APPEND_ELEMENT(list, noutputs, output); if (at >=3D 0) { virLogOutputFree(list[at]); VIR_DELETE_ELEMENT(list, at, noutputs); @@ -1687,10 +1684,7 @@ virLogParseFilters(const char *src, virLogFilter ***= filters) if (!(filter =3D virLogParseFilter(*next))) return -1; - if (VIR_APPEND_ELEMENT(list, nfilters, filter)) { - virLogFilterFree(filter); - return -1; - } + VIR_APPEND_ELEMENT(list, nfilters, filter); } *filters =3D g_steal_pointer(&list); diff --git a/src/util/virmdev.c b/src/util/virmdev.c index fb89b80da4..d12c7b87a0 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -303,7 +303,9 @@ virMediatedDeviceListAdd(virMediatedDeviceList *list, _("device %s is already in use"), (*dev)->path); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, *dev); + VIR_APPEND_ELEMENT(list->devs, list->count, *dev); + + return 0; } @@ -554,8 +556,7 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(mdev_types, nmdev_types, mdev_type) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(mdev_types, nmdev_types, mdev_type); } if (dirret < 0) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 407270271f..fe531a3260 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -2799,8 +2799,7 @@ static int virNetDevGetMcastList(const char *ifname, /* Only return global multicast MAC addresses for * specified interface */ if (entry->global && STREQ(ifname, entry->name)) { - if (VIR_APPEND_ELEMENT(mcast->entries, mcast->nentries, entry)) - return -1; + VIR_APPEND_ELEMENT(mcast->entries, mcast->nentries, entry); } else { memset(entry, 0, sizeof(virNetDevMcastEntry)); } diff --git a/src/util/virnvme.c b/src/util/virnvme.c index 11da76e760..3ce02b5000 100644 --- a/src/util/virnvme.c +++ b/src/util/virnvme.c @@ -191,11 +191,10 @@ virNVMeDeviceListAdd(virNVMeDeviceList *list, return -1; } - if (!(tmp =3D virNVMeDeviceCopy(dev)) || - VIR_APPEND_ELEMENT(list->devs, list->count, tmp) < 0) { - virNVMeDeviceFree(tmp); + if (!(tmp =3D virNVMeDeviceCopy(dev))) return -1; - } + + VIR_APPEND_ELEMENT(list->devs, list->count, tmp); return 0; } diff --git a/src/util/virpci.c b/src/util/virpci.c index bf42bcf73c..67c3896dd5 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1688,7 +1688,9 @@ virPCIDeviceListAdd(virPCIDeviceList *list, _("Device %s is already in use"), dev->name); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, dev); + VIR_APPEND_ELEMENT(list->devs, list->count, dev); + + return 0; } @@ -1948,9 +1950,8 @@ virPCIGetIOMMUGroupAddressesAddOne(virPCIDeviceAddres= s *newDevAddr, void *opaque *copyAddr =3D *newDevAddr; - if (VIR_APPEND_ELEMENT(*addrList->iommuGroupDevices, - *addrList->nIommuGroupDevices, copyAddr) < 0) - return -1; + VIR_APPEND_ELEMENT(*addrList->iommuGroupDevices, + *addrList->nIommuGroupDevices, copyAddr); return 0; } @@ -2363,9 +2364,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path, goto error; } - if (VIR_APPEND_ELEMENT(*virtual_functions, *num_virtual_functions, - config_addr) < 0) - goto error; + VIR_APPEND_ELEMENT(*virtual_functions, *num_virtual_functions, con= fig_addr); } while (1); VIR_DEBUG("Found %zu virtual functions for %s", diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 67dd599b3e..a391e7f3c6 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -632,8 +632,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t *= *pids) goto cleanup; tmp_pid =3D tmp; - if (VIR_APPEND_ELEMENT(*pids, *npids, tmp_pid) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*pids, *npids, tmp_pid); } if (value < 0) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 1c41d1d356..edbf078654 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -2634,14 +2634,12 @@ virResctrlMonitorGetStats(virResctrlMonitor *monito= r, if (rv < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(stat->vals, stat->nvals, val) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(stat->vals, stat->nvals, val); stat->features[i] =3D g_strdup(resources[i]); } - if (VIR_APPEND_ELEMENT(*stats, *nstats, stat) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*stats, *nstats, stat); } /* Sort in id's ascending order */ diff --git a/src/util/virscsi.c b/src/util/virscsi.c index b1f202eef1..2488b0e5f8 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -254,8 +254,7 @@ virSCSIDeviceSetUsedBy(virSCSIDevice *dev, copy->drvname =3D g_strdup(drvname); copy->domname =3D g_strdup(domname); - if (VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy) < 0) - return -1; + VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy); return 0; } @@ -359,7 +358,9 @@ virSCSIDeviceListAdd(virSCSIDeviceList *list, return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, dev); + VIR_APPEND_ELEMENT(list->devs, list->count, dev); + + return 0; } virSCSIDevice * diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index 396f10d708..afbfddb0fb 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -183,7 +183,9 @@ virSCSIVHostDeviceListAdd(virSCSIVHostDeviceList *list, _("Device %s is already in use"), dev->name); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, dev); + VIR_APPEND_ELEMENT(list->devs, list->count, dev); + + return 0; } diff --git a/src/util/virusb.c b/src/util/virusb.c index 183b8a9792..9e6ec9c9cf 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -447,7 +447,9 @@ virUSBDeviceListAdd(virUSBDeviceList *list, (*dev)->name); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, *dev); + VIR_APPEND_ELEMENT(list->devs, list->count, *dev); + + return 0; } virUSBDevice * diff --git a/src/util/virutil.c b/src/util/virutil.c index 00cd56e2b2..c9de043c40 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -971,13 +971,8 @@ virGetGroupList(uid_t uid, gid_t gid, gid_t **list) if ((*list)[i] =3D=3D gid) goto cleanup; } - if (VIR_APPEND_ELEMENT(*list, i, gid) < 0) { - ret =3D -1; - VIR_FREE(*list); - goto cleanup; - } else { - ret =3D i; - } + VIR_APPEND_ELEMENT(*list, i, gid); + ret =3D i; } cleanup: diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 1ca521321c..6cb5ba8928 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3535,9 +3535,8 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver= *data, IMachine *machine) graphics->data.desktop.display =3D g_strdup(getenv("DISPLAY")); } - if (graphics && - VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) - goto cleanup; + if (graphics) + VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics); gVBoxAPI.UIMachine.GetVRDEServer(machine, &VRDEServer); if (VRDEServer) @@ -3574,8 +3573,7 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriver= *data, IMachine *machine) if (reuseSingleConnection) graphics->data.rdp.replaceUser =3D true; - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < = 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics); } ret =3D 0; @@ -3758,10 +3756,7 @@ vboxDumpNetworks(virDomainDef *def, struct _vboxDriv= er *data, IMachine *machine, if (enabled) { net =3D vboxDumpNetwork(data, adapter); - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) { - VBOX_RELEASE(adapter); - return -1; - } + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); } VBOX_RELEASE(adapter); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 04eabff18a..de86eb1f80 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1893,8 +1893,7 @@ virVMXParseConfig(virVMXContext *ctx, if (!net) continue; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); } /* def:inputs */ diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index e09950812d..1cc9eb8caf 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -553,8 +553,7 @@ prlsdkAddDomainVideoInfoCt(virDomainDef *def, video->type =3D VIR_DOMAIN_VIDEO_TYPE_PARALLELS; video->vram =3D 0; - if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, video) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(def->videos, def->nvideos, video); ret =3D 0; cleanup: @@ -951,10 +950,7 @@ prlsdkGetNetAddresses(PRL_HANDLE sdknet, virDomainNetD= ef *net) if (!(ip =3D prlsdkParseNetAddress(addr))) continue; - if (VIR_APPEND_ELEMENT(net->guestIP.ips, net->guestIP.nips, ip) < = 0) { - VIR_FREE(ip); - goto cleanup; - } + VIR_APPEND_ELEMENT(net->guestIP.ips, net->guestIP.nips, ip); } ret =3D 0; @@ -985,8 +981,7 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDef *net) NULL, gw, 0, true, 0, false= ))) goto cleanup; - if (VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, = route) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, rout= e); } if (*gw6 !=3D '\0') { @@ -995,8 +990,7 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDef *net) NULL, gw6, 0, true, 0, fals= e))) goto cleanup; - if (VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, = route) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(net->guestIP.routes, net->guestIP.nroutes, rout= e); } ret =3D 0; @@ -1132,8 +1126,7 @@ prlsdkAddDomainNetInfo(PRL_HANDLE sdkdom, virDomainDe= f *def) PrlHandle_Free(netAdapter); netAdapter =3D PRL_INVALID_HANDLE; - if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0) - goto error; + VIR_APPEND_ELEMENT(def->nets, def->nnets, net); } return 0; @@ -1248,8 +1241,7 @@ prlsdkAddSerialInfo(PRL_HANDLE sdkdom, PrlHandle_Free(serialPort); serialPort =3D PRL_INVALID_HANDLE; - if (VIR_APPEND_ELEMENT(*serials, *nserials, chr) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(*serials, *nserials, chr); } return 0; @@ -1333,8 +1325,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDef *def) gr->listens[0].type =3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, gr) < 0) - goto error; + VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, gr); return 0; diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 8c82efa060..33648a5077 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -213,10 +213,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDef *def, if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0) goto cleanup; - if (VIR_APPEND_ELEMENT(inst->rules, - inst->nrules, - ruleinst) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(inst->rules, inst->nrules, ruleinst); ruleinst =3D NULL; ret =3D 0; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 143dd954e6..30d475ebe4 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -465,19 +465,10 @@ qemuMonitorTestAddHandler(qemuMonitorTest *test, item->opaque =3D opaque; virMutexLock(&test->lock); - if (VIR_APPEND_ELEMENT(test->items, test->nitems, item) < 0) { - virMutexUnlock(&test->lock); - goto error; - } + VIR_APPEND_ELEMENT(test->items, test->nitems, item); virMutexUnlock(&test->lock); return 0; - - error: - if (freecb) - (freecb)(opaque); - VIR_FREE(item); - return -1; } void * diff --git a/tests/testutils.c b/tests/testutils.c index 58d3300998..682fa142b5 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -812,10 +812,12 @@ int virTestMain(int argc, if (!getenv("LIBVIRT_DEBUG") && !virLogGetNbOutputs()) { if (!(output =3D virLogOutputNew(virtTestLogOutput, virtTestLogClo= se, &testLog, VIR_LOG_DEBUG, - VIR_LOG_TO_STDERR, NULL)) || - VIR_APPEND_ELEMENT(outputs, noutputs, output) < 0 || - virLogDefineOutputs(outputs, noutputs) < 0) { - virLogOutputFree(output); + VIR_LOG_TO_STDERR, NULL))) + return EXIT_FAILURE; + + VIR_APPEND_ELEMENT(outputs, noutputs, output); + + if (virLogDefineOutputs(outputs, noutputs) < 0) { virLogOutputListFree(outputs, noutputs); return EXIT_FAILURE; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f9962f0515..81f3c82094 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3852,8 +3852,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) vol.source =3D g_steal_pointer(&source); vol.target =3D g_steal_pointer(&target); - if (VIR_APPEND_ELEMENT(vols, nvols, vol) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(vols, nvols, vol); } /* print volumes specified by user that were not found in domain d= efinition */ diff --git a/tools/vsh-table.c b/tools/vsh-table.c index 78d1cb27f1..7fb0f13ee6 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -102,8 +102,7 @@ vshTableRowNew(const char *arg, va_list ap) tmp =3D g_strdup(arg); - if (VIR_APPEND_ELEMENT(row->cells, row->ncells, tmp) < 0) - goto error; + VIR_APPEND_ELEMENT(row->cells, row->ncells, tmp); arg =3D va_arg(ap, const char *); } @@ -140,8 +139,7 @@ vshTableNew(const char *arg, ...) if (!header) goto error; - if (VIR_APPEND_ELEMENT(table->rows, table->nrows, header) < 0) - goto error; + VIR_APPEND_ELEMENT(table->rows, table->nrows, header); return table; error: @@ -182,8 +180,7 @@ vshTableRowAppend(vshTable *table, const char *arg, ...) goto cleanup; } - if (VIR_APPEND_ELEMENT(table->rows, table->nrows, row) < 0) - goto cleanup; + VIR_APPEND_ELEMENT(table->rows, table->nrows, row); ret =3D 0; cleanup: --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075026; cv=none; d=zohomail.com; s=zohoarc; b=VBkg6bXIE0ot2yBXR1L3XvzB23IHUML9UM0TqzpGvBl6z15FArsvFeOQH2clHLnTQeddrd64PBKxrGb0ZP+VhMNB3bc6wOQh2exLc6hEtXSPxF2fvxNc6Ph8OZM2tKQSJqW74hUjzI6ww74XoI3ZAGFTDcRyvEbFT1JqAq5Kh9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075026; 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=Lzwi7XqXwWkqwtgPLlgO4cpSUgkzQ0+UlU96xhHql1A=; b=b6PoWPZ2Q+/q49ebhAURlFfujhdNo3MaDI6XUC6u07LYPAQrQ5JTEUR0P058OpZOLytHXjUh6QtsTlZrVDJAmBp1AQq0K6EzF7f1+3xxm94ivHQoLem1tuFMDvgTxsPImNvFgcrhw4B41jn4eD/hzJeLEQsl+LVbjZGuvn8HTYU= 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 1628075026702505.209586270895; Wed, 4 Aug 2021 04:03:46 -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-58-h5WOdnwSNLWVanZHXd5cBA-1; Wed, 04 Aug 2021 07:03:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 163432FD1D; Wed, 4 Aug 2021 11:03:37 +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 EFB91779D0; Wed, 4 Aug 2021 11:03: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 BC3FA4A70B; Wed, 4 Aug 2021 11:03:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2wSI014248 for ; Wed, 4 Aug 2021 07:02:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 306111383C; Wed, 4 Aug 2021 11:02:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8374A5D9DC for ; Wed, 4 Aug 2021 11:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075025; 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=Lzwi7XqXwWkqwtgPLlgO4cpSUgkzQ0+UlU96xhHql1A=; b=LTC/LWXXDtO3p1/Apap8ylikdr2SyU7TD9yQ06b/dZ+u02EUf8kKa955cw5VPFgaKJV1mA RbuTaYNDZf284pRhV3TYYx63wFLm17pdHAUeLoJK1bmJnZZYxCqOOlcxodCVKmDULdI+1w hrpke3gThFLLSbdcs/z0OmjyVXR1w7E= X-MC-Unique: h5WOdnwSNLWVanZHXd5cBA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/23] util: alloc: Completely replace VIR_APPEND_ELEMENT_QUIET by VIR_APPEND_ELEMENT Date: Wed, 4 Aug 2021 13:02:28 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1628075028723100011 Content-Type: text/plain; charset="utf-8" VIR_APPEND_ELEMENT doesn't report any errors now so we can remove VIR_APPEND_ELEMENT_QUIET and replace all uses by VIR_APPEND_ELEMENT Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/viralloc.h | 5 ----- tests/virfilewrapper.c | 4 ++-- tests/virpcimock.c | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index f02d634eea..3a09af65c5 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -243,11 +243,6 @@ int virDeleteElementsN(void *ptrptr, size_t size, size= _t at, size_t *countptr, VIR_TYPEMATCH(ptr, &(newelem)), \ &(newelem), false, true) -/* Quiet version of macros above */ -#define VIR_APPEND_ELEMENT_QUIET(ptr, count, newelem) \ - virAppendElement(&(ptr), sizeof(*(ptr)), &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, fal= se) - /** * VIR_DELETE_ELEMENT: * @ptr: pointer to array of objects (*not* ptr to ptr) diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c index 3085a190fb..aaff39866d 100644 --- a/tests/virfilewrapper.c +++ b/tests/virfilewrapper.c @@ -78,8 +78,8 @@ virFileWrapperAddPrefix(const char *prefix, init_syms(); - VIR_APPEND_ELEMENT_QUIET(prefixes, nprefixes, prefix); - VIR_APPEND_ELEMENT_QUIET(overrides, noverrides, override); + VIR_APPEND_ELEMENT(prefixes, nprefixes, prefix); + VIR_APPEND_ELEMENT(overrides, noverrides, override); } diff --git a/tests/virpcimock.c b/tests/virpcimock.c index de39fc65a4..ead810d412 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -428,7 +428,7 @@ pci_device_create_iommu(const struct pciDevice *dev, iommuGroup->iommu =3D dev->iommuGroup; iommuGroup->nDevicesBoundToVFIO =3D 0; /* No device bound to VFIO by d= efault */ - VIR_APPEND_ELEMENT_QUIET(pciIommuGroups, npciIommuGroups, iommuGroup); + VIR_APPEND_ELEMENT(pciIommuGroups, npciIommuGroups, iommuGroup); } @@ -542,7 +542,7 @@ pci_device_new_from_stub(const struct pciDevice *data) if (pci_device_autobind(dev) < 0) ABORT("Unable to bind: %s", devid); - VIR_APPEND_ELEMENT_QUIET(pciDevices, nPCIDevices, dev); + VIR_APPEND_ELEMENT(pciDevices, nPCIDevices, dev); } static struct pciDevice * @@ -713,7 +713,7 @@ pci_driver_new(const char *name, ...) make_file(driverpath, "bind", NULL, -1); make_file(driverpath, "unbind", NULL, -1); - VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver); + VIR_APPEND_ELEMENT(pciDrivers, nPCIDrivers, driver); } static struct pciDriver * --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075025; cv=none; d=zohomail.com; s=zohoarc; b=XuE9ePSht0wjVCVRxXCkpdwUo49BZuwDCvVVXEgDxr4hLCL/H2fm3kI4ZUwdfgr+eGdbfkDW2HDfDrPHZHLyLbyD3ODeEHx8nYH5MA0SkoZdaLsG1QZHCFXhmcE5fL4IknotzGTR/Jwr3R/mxOaVEC1IIlSujRBrxNPonhWjTvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075025; 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=OhPT5idNa/hhe8g7tCbU/vxtWn29HjT0uTFzqb7dqQM=; b=Aw9qCTuoQn1HNGB5YFtT0ar9Nl/xmwnGd0lPSoJA3dWjgTVdGDuLq8MYkc4znTsx8Swcvcjq1KLQvfiwr6k8sS5qVNpwl1GHCPet8vfG/FUCbYxmTne7y6E22IvwJQM7EwpzqijxEiuxVjs/stQezOxcRQTo2Hdki11EgAiZ60o= 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 1628075025574201.63469159329168; Wed, 4 Aug 2021 04:03: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-426-h5IbYxSeMYqxfkb_0MiWYA-1; Wed, 04 Aug 2021 07:03:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 395EB1966326; Wed, 4 Aug 2021 11:03:37 +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 13F7310372C2; Wed, 4 Aug 2021 11:03:37 +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 D2A1C180BAB4; Wed, 4 Aug 2021 11:03:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B2xW6014258 for ; Wed, 4 Aug 2021 07:02:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 510FD1383C; Wed, 4 Aug 2021 11:02:59 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E6895D9DC for ; Wed, 4 Aug 2021 11:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075024; 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=OhPT5idNa/hhe8g7tCbU/vxtWn29HjT0uTFzqb7dqQM=; b=TuzypKlnBPEbP3oxyynWDX3vdFR/RTXp9LnVuvBdfHTOXoty0pY4va7J8bfYxILfWPmuBY laBoaDKi9LHN9IURpulAUkpZ4ugrq9mgl+8jmOcHr+Y8C2z9jwIoxrhiEey3UE3q848czT qrGPQOE21xfDvGvXXNazwSSr26YM6EI= X-MC-Unique: h5IbYxSeMYqxfkb_0MiWYA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/23] prlsdkAddDomainVideoInfoCt: Remove pointless cleanup section Date: Wed, 4 Aug 2021 13:02:29 +0200 Message-Id: <67c8cef59ab736e467bffe0da46eee7295f80cd4.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075026665100006 Content-Type: text/plain; charset="utf-8" 'video' will only ever be NULL after the 'cleanup' label thus there's no need to use 'virDomainVideoDefFree'. In fact we can fully remove the cleanup section and 'ret' variable by returning directly from failure points. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/vz/vz_sdk.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 1cc9eb8caf..4f0aae91a2 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -542,24 +542,19 @@ prlsdkAddDomainVideoInfoCt(virDomainDef *def, virDomainXMLOption *xmlopt) { virDomainVideoDef *video =3D NULL; - int ret =3D -1; if (def->ngraphics =3D=3D 0) return 0; if (!(video =3D virDomainVideoDefNew(xmlopt))) - goto cleanup; + return -1; video->type =3D VIR_DOMAIN_VIDEO_TYPE_PARALLELS; video->vram =3D 0; VIR_APPEND_ELEMENT(def->videos, def->nvideos, video); - ret =3D 0; - cleanup: - virDomainVideoDefFree(video); - - return ret; + return 0; } static int --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075030; cv=none; d=zohomail.com; s=zohoarc; b=j0cWRcTAAERFF1jmyOtYMypiFGomX7VbcjTDyjViK0Il9stgZV+GrVIWpF1Z9fUDRR+WMJ0Gt3UI6s9txeJUAVmZmAOJpe84EL1YM+ngLrLoyyXF8DALnnfOQb/wopElZ53KcKKzFfaIzAP9XzNBtOCU7mTW8Km+6TpW+vvgX74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075030; 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=sIeHgVYq6skcL5oQIamAieFkfYw3v5p1jP0YITsLAvc=; b=fQgC8NVPIDk/GVXvfiQA3F3Fa6x4+BP2NafUJ/QyPnT6Dai99Y9xf2h4Z40XtMlI+7zuJ5g5Ap4fimrQFraDn1T58rna/sGWuVDSajXy+tEbxFEIHcS2CrSq+nLMIT559yKaQGIgcBGzTysEZKbCKB99b2ZtueDuPe8ST51WM/I= 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 1628075030078906.1052489722; Wed, 4 Aug 2021 04:03:50 -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-508-33v8tHoUMMOq04cb9kfPHg-1; Wed, 04 Aug 2021 07:03:47 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B95D801AC0; Wed, 4 Aug 2021 11:03:40 +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 045741036D33; Wed, 4 Aug 2021 11:03: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 C29B04A70F; Wed, 4 Aug 2021 11:03:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B30q4014264 for ; Wed, 4 Aug 2021 07:03:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 621861383C; Wed, 4 Aug 2021 11:03:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id C14595D9DC for ; Wed, 4 Aug 2021 11:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075029; 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=sIeHgVYq6skcL5oQIamAieFkfYw3v5p1jP0YITsLAvc=; b=bltYg7KtUZe73MN61mVUOsJO+KS1yX0HqNG3Z8WZR8tCc+lPJldhJddO00i74+CJ3ei+Kg neDs/zex5mHFd9NxbAX3p2kIgJRcbBBrPHFXe7Bl1ekzbFDp2THRgeQSDb4GbhbEl7ekah yRuD/moHW2XKDuuKubo1idlL+L5y6wM= X-MC-Unique: 33v8tHoUMMOq04cb9kfPHg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/23] xenParseXMDisk: Use automatic memory clearing and remove 'ret' variable Date: Wed, 4 Aug 2021 13:02:30 +0200 Message-Id: <57d07baa1d50c233c2b22e1a1f90b0c538190cd8.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075031155100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/libxl/xen_xm.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index ac86ddf9b7..f978b94f93 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -238,9 +238,9 @@ xenParseXMDisk(char *entry, int hvm) static int xenParseXMDiskList(virConf *conf, virDomainDef *def) { - char **disks =3D NULL, **entries; + g_auto(GStrv) disks =3D NULL; + GStrv entries; int hvm =3D def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM; - int ret =3D -1; int rc; rc =3D virConfGetValueStringList(conf, "disk", false, &disks); @@ -258,10 +258,7 @@ xenParseXMDiskList(virConf *conf, virDomainDef *def) VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk); } - ret =3D 0; - - g_strfreev(disks); - return ret; + return 0; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075075; cv=none; d=zohomail.com; s=zohoarc; b=YQQeXw7HlEbhFBVgjwK10UuN9RalMHhvrhSS+M2B0KhWJsRr779r8i/7w/O9TLGahj7Bo8DOnicDNu9MZn2VaQe00uSKUyQHVRlU3zEsl6sPEPqRvZvKB0iJ2JJm1aQPt2qFYH5Q/i3cVSEdHjl6Tj8gk0+pWuIpjMxbmkwh/Ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075075; 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=HFjPrK0GZNGT1yZK6Nq6ncewWdZMowWj845Ft7TjJCM=; b=DImLV3gYbj8VX4QD4bQgxYvRt5DtkrMk7N3HHrxE07MSv6IsVDw5evm7cg+m30zRimSrV3d34VjouuFT1Wk+tAxcIbzbEsy4hrOa3pMAMUgFPd5aSJN5CAo78ve+IMdNKg+mtB4+3bokUdqPSKKoohueO6225Rf3R7rtIORpZSw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628075075931756.6010001270265; Wed, 4 Aug 2021 04:04:35 -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-481-t8Ipo4geNO26vHt8QX0avA-1; Wed, 04 Aug 2021 07:03:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E08391084F56; Wed, 4 Aug 2021 11:03:43 +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 C5E64226E9; Wed, 4 Aug 2021 11:03:43 +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 761F5180140E; Wed, 4 Aug 2021 11:03:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B31FH014269 for ; Wed, 4 Aug 2021 07:03:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 796CE1383C; Wed, 4 Aug 2021 11:03:01 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE6755D9DC for ; Wed, 4 Aug 2021 11:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075075; 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=HFjPrK0GZNGT1yZK6Nq6ncewWdZMowWj845Ft7TjJCM=; b=h7ex3DTWCo37LIBz0XUeB6JzIe+6enBAWc+6ZhCeVuf9hS8P2oKKyCpRI+b0euc0IQXM0U sMRdhVlOEbWMoc5+8h5P3YKkEb2k/JL90+9iMzlBQGw77jLKu3ov7pBSZ1MRmUgpGxP8r/ q6waM94iylozAPKXfGEwyWROHu/1Aok= X-MC-Unique: t8Ipo4geNO26vHt8QX0avA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/23] qemuDomainUSBAddressAddHubs: Refactor cleanup Date: Wed, 4 Aug 2021 13:02:31 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1628075076307100001 Content-Type: text/plain; charset="utf-8" 'hub' doesn't need to be freed any more because it's always consumed and NULLed-out by VIR_APPEND element. This also makes the 'ret' variable obsolete. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_domain_address.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 40e84cce9c..392368bd38 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -2942,7 +2942,6 @@ qemuDomainUSBAddressAddHubs(virDomainDef *def) virDomainHubDef *hub =3D NULL; size_t available_ports; size_t hubs_needed =3D 0; - int ret =3D -1; size_t i; available_ports =3D virDomainUSBAddressCountAllPorts(def); @@ -2972,9 +2971,7 @@ qemuDomainUSBAddressAddHubs(virDomainDef *def) VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub); } - ret =3D 0; - VIR_FREE(hub); - return ret; + return 0; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075032; cv=none; d=zohomail.com; s=zohoarc; b=LB3l0cWliHAdsgDD2+k17KmEevyHldUUh0Lp8+NQW9EX+ZqwHpoJXpOu6pawm4xJO2xvaY/P0JxiTTUPP7TkRdvV+EdUqqpaqKO7LBqUB6xPkb4Rl7gJ3EgGzZFQQWvo17ct/9GbFdBYyaQ12hybVdDHoIUiocxnMrBwPhnd/Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075032; 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=R0zq/JbRBRyEbSB2xW9OmhoAU/AKRzwh7PWpmHuOJck=; b=OlRBPS36zzKpvochXQuiIdKFGKbsACLR5JUBmI5YVgydL4fr8f8AXpWWO9DtwWCsviKnNgYoLzyltKfRhb2sQK2fbHcAX7X34DGRVCDHEI3XGFFsvwY/Go1V3PkQbr9E1S7nOSMd5jOLCIuvBR7f5aTzYJU7tExGEDPSviKRGsQ= 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 1628075032243372.88111130053176; Wed, 4 Aug 2021 04:03:52 -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-272-1Ajis5ytOPi35sbGIYBU0Q-1; Wed, 04 Aug 2021 07:03:49 -0400 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 EC2B7100671C; Wed, 4 Aug 2021 11:03:42 +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 CFFB519CBA; Wed, 4 Aug 2021 11:03:42 +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 64DAF4A718; Wed, 4 Aug 2021 11:03:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B32IT014275 for ; Wed, 4 Aug 2021 07:03:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 85BC55D9DC; Wed, 4 Aug 2021 11:03:02 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E402217B73 for ; Wed, 4 Aug 2021 11:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075031; 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=R0zq/JbRBRyEbSB2xW9OmhoAU/AKRzwh7PWpmHuOJck=; b=igA2ZjrSMjOvcp1WBkVTKHzu5TiX31wFUMVcb7j4DQxpkpdWaMQ9a9k4F51K7g4Oew9B2k iN4+God5Hs0JV7Bbo4m0tzTFUCuhECkc3PZed+dNuq3rBrbGIBj2OkBSFNm4TnbzJVXvdT iSHxtzIZ7cl1uhqDO+/uf+CFBOwLGGU= X-MC-Unique: 1Ajis5ytOPi35sbGIYBU0Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/23] virSecuritySELinuxContextListAppend: Remove unreachable cleanup Date: Wed, 4 Aug 2021 13:02:32 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1628075033594100011 Content-Type: text/plain; charset="utf-8" 'item' is always NULLed-out by VIR_APPEND_ELEMENT and 'ret' variable is always 0 when used so both can be removed. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/security/security_selinux.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 30fb6028aa..9ff35a7be5 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -114,7 +114,6 @@ virSecuritySELinuxContextListAppend(virSecuritySELinuxC= ontextList *list, bool remember, bool restore) { - int ret =3D -1; virSecuritySELinuxContextItem *item =3D NULL; item =3D g_new0(virSecuritySELinuxContextItem, 1); @@ -127,9 +126,7 @@ virSecuritySELinuxContextListAppend(virSecuritySELinuxC= ontextList *list, VIR_APPEND_ELEMENT(list->items, list->nItems, item); - ret =3D 0; - virSecuritySELinuxContextItemFree(item); - return ret; + return 0; } static void --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075033; cv=none; d=zohomail.com; s=zohoarc; b=MvmDD1CYCqMQ02v13xC+J29NjxX2nS0WMI90wt613TS3c/T2mQwX+rwgSFynaxWR4PRGBa602XKgnsuk5xeJKTAL3SHOH/xE/cIxGmtWzn2tEn1JsX2ZhGiUimLvZiCvLWOnP3z+SLPPV1zm5vimjeMT0+w7XdFrPs+AtOM6T8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075033; 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=FnMW2ZrFMrF4jhpvC2tQBIJNB2DjYWl8dSZkWhDS8VY=; b=UP9A8yLn9un9Ct5LFwEolvV7hloZYKw9QDmCBpAgFDOUX5sVtHcLyV5fuvmZ3RzyCT4LVZP875BsMcGMZl3LAGcV3j+GElwFMjr7PIwqg7Ya711qHCGZbQOnvFghQk7PV0GbiRshPGWsuVdYn/bveJFRVDU5zbxoa3DJCPkK9ag= 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 1628075033232403.3228523493333; Wed, 4 Aug 2021 04:03:53 -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-518-MBNE9bX9OGmrU-NQx1T1QQ-1; Wed, 04 Aug 2021 07:03:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEE2910066E5; Wed, 4 Aug 2021 11:03: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 9C93160BF4; Wed, 4 Aug 2021 11:03: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 6B2D54A71A; Wed, 4 Aug 2021 11:03:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B33lr014281 for ; Wed, 4 Aug 2021 07:03:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id B999629671; Wed, 4 Aug 2021 11:03:03 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10D9717B73 for ; Wed, 4 Aug 2021 11:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075032; 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=FnMW2ZrFMrF4jhpvC2tQBIJNB2DjYWl8dSZkWhDS8VY=; b=hBIpDWVOUJgkcPjTAQA/AV0zD/Lla/RdebXOxe0eCcajLKU0EnH4WpHELsb9u2gt9znPaO aca+ifiL0GeEHBA1w0hzlfGzWfkjK06Br4q36aD8DiUs4Pb9JaSXWESn7SzTATG8B4huhq IUTHEFrgdAyP3xEeGre9fCf7OgQoTpU= X-MC-Unique: MBNE9bX9OGmrU-NQx1T1QQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/23] qemuDomainAttachDeviceConfig: Remove pointless assignment Date: Wed, 4 Aug 2021 13:02:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 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: 1628075034576100013 Content-Type: text/plain; charset="utf-8" 'dev->data.rng' is NULLed by VIR_APPEND_ELEMENT Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_driver.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e53f167575..a7d76dd00f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7319,8 +7319,6 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, } VIR_APPEND_ELEMENT(vmdef->rngs, vmdef->nrngs, dev->data.rng); - dev->data.rng =3D NULL; - break; case VIR_DOMAIN_DEVICE_MEMORY: --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075035; cv=none; d=zohomail.com; s=zohoarc; b=bP7O4/OOvky+TCr8mmqX9jxg8CjSqzyxcF08wtfMpKcNkXCdsdL9Bh/5jOvUy5q7QD58a29mlEPdtKWxRwpiih/uv5aSf3rPETvfnBEmd+5WVu//UbvdKNxckuGpieCDlD1KHZbgLn74haYtWfGr62TwwqVP38Xbnb5zLEkuPIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075035; 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=NSPxyLNfBEAY1O8Iql4qdSXGV94YX+whVRC4EmVT+A0=; b=K0CaXW54Bq/Chb1lIwwD1V3kYQ+2pEIbWyb1Xd2p9T8VD89kiPZbVxiEnJF4YmZos723fptBV/BzW4qjtAi0SPuweAuqUq/RkXarUI+/sjtXzDNugKyWRYJlwcGV1s446OT+5LJQp8oT/HU6wy9CqVy0JuClCoJmvD66L3z29tU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628075035391552.8530268250353; Wed, 4 Aug 2021 04:03:55 -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-431-uA9_mweuMUea9bIP7uIR5Q-1; Wed, 04 Aug 2021 07:03:52 -0400 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 D778D363A7; Wed, 4 Aug 2021 11:03:46 +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 B8AF6421F; Wed, 4 Aug 2021 11:03:46 +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 80C47181A2A7; Wed, 4 Aug 2021 11:03:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B38XP014295 for ; Wed, 4 Aug 2021 07:03:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 758ED17B73; Wed, 4 Aug 2021 11:03:08 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7CE75D9DC for ; Wed, 4 Aug 2021 11:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075034; 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=NSPxyLNfBEAY1O8Iql4qdSXGV94YX+whVRC4EmVT+A0=; b=S4rBR2G22ZhqmJFRjLdWQRGj1+bQVY6duR9ghYfQMfJpn86I2ie35RWF8WUnCTh+nYi5Yb fRdThT1urPaSo69+EusO8SsJ56OHQH7/eeaBukDGMP+O2IV40CnO2xrq0zwqFIT8syAeNe VtA6eLrB9ysWjtlrqk2icjs6+DUjUzs= X-MC-Unique: uA9_mweuMUea9bIP7uIR5Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/23] virNWFilterRuleDefToRuleInst: Remove pointless assignment Date: Wed, 4 Aug 2021 13:02:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1628075037165100002 Content-Type: text/plain; charset="utf-8" 'ruleinst' is NULLed by VIR_APPEND_ELEMENT Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- tests/nwfilterxml2firewalltest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index 33648a5077..7fefd3ce75 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -214,7 +214,6 @@ virNWFilterRuleDefToRuleInst(virNWFilterDef *def, goto cleanup; VIR_APPEND_ELEMENT(inst->rules, inst->nrules, ruleinst); - ruleinst =3D NULL; ret =3D 0; cleanup: --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075226; cv=none; d=zohomail.com; s=zohoarc; b=K0v6Pqm44TfGGB8ZQhNAPfmpQvULBTguaAL9BZl+f9ZeSHwVnmkjPtGih2hqTWBLOlnsQ6xHi4KRq2KC9yZR20uHrQcW1fPxcKcGFOjj/fXgORCam+DyIYFSUbaXPtrYwtS8Uky3rPZGV3L8b6mXDKGadghh/29a1bu94jAFPAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075226; 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=Y3pT4TLaWzpzn6agiJ/Ngb0SIHMRxkPnIrOnQZ9SV2I=; b=QHxfWGMlXJD974fbDLKyEIsBR8wc48ee81QcqhAp4ijLgULvWacNr3qZt/s2k7hLP4BYYOw0kqxHFf8Z1JHZk01k1hDz0ldbfy+rSHpc7XJy5LLLpyNGJY5RYY6ZiDaCyN/K9S//t4egd4s2wvT6sembNLLsQ7J3Jhtij3qimpU= 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 1628075226316849.9373432359283; Wed, 4 Aug 2021 04:07:06 -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-586-HG972s5QMMmvJpNCHIuKoA-1; Wed, 04 Aug 2021 07:03:54 -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 72BFB363AC; Wed, 4 Aug 2021 11:03:48 +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 4A6CB69321; Wed, 4 Aug 2021 11:03:48 +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 11B474EBD8; Wed, 4 Aug 2021 11:03:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B39lD014300 for ; Wed, 4 Aug 2021 07:03:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8BC5E17B73; Wed, 4 Aug 2021 11:03:09 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0A085D9DC for ; Wed, 4 Aug 2021 11:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075225; 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=Y3pT4TLaWzpzn6agiJ/Ngb0SIHMRxkPnIrOnQZ9SV2I=; b=hkNvL0lgtNejZaZFoSmm5ZTFAjXaKuZbVBBai7KKSJI/+NzQAf06bIsloJazh61EDDGZkO 1YtoywLmrnIXmVwP7Lj1P8Ru4np0l6PwLi9D1Eemw4MYkyVODrpxVrIeydIP4r7051L+6C 9CEtPalg4WNJRoQh9Pne5qiwrZSM/4w= X-MC-Unique: HG972s5QMMmvJpNCHIuKoA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/23] virObjectEventCallbackListAddID: Remove pointless cleanup of 'cb' Date: Wed, 4 Aug 2021 13:02:35 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.15 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: 1628075227927100002 Content-Type: text/plain; charset="utf-8" 'cb' is always NULL when 'virObjectEventCallbackListAddID' is called. Remove the call. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/object_event.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 866d438f89..9ea9ee3496 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -453,7 +453,6 @@ virObjectEventCallbackListAddID(virConnectPtr conn, ret++; } - virObjectEventCallbackFree(cb); return ret; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075103; cv=none; d=zohomail.com; s=zohoarc; b=aksXno+f1p8hAJ7ZhTgxdQOjp+cWwR5V3Cc4IQwNYxeuRzVVEodxJNAJ/Pk6N7gyup7vOhx/hoxtiUMW6Z3VuSb3N8vOKwkT9rPfSpPJcWIhgWkHvhVJSVNKtelyR62DIRyKYlQFnOE3bcnEi3Pyix6LvI48471JLeTNMheUOI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075103; 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=q7NezlKqGa9z971oh9t22/zvk3YMhmBxp84CKpDDzWg=; b=ke3klbXbJjxkS50TKxJ+gXtJLzi9M1GlgvsrV5p10AB08pozIaQShTfUfsONrIVlkWjk0LZrY7gFNL0fuIs3j2VWOoz6b7rwlq3YpAxNMMbjbJjqnNclDin6w/tPsaOSwbXrxvP1XDAGD0OA3TfFmZHieQGrjKdrY1DGS6P6Mj0= 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 162807510357218.498322831888345; Wed, 4 Aug 2021 04:05:03 -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-100-_Gb701p8OnyFTymFHJErUA-1; Wed, 04 Aug 2021 07:03:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73C2C1006710; Wed, 4 Aug 2021 11:03:51 +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 4ABB010372C4; Wed, 4 Aug 2021 11:03:51 +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 1264A181A2E4; Wed, 4 Aug 2021 11:03:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3AJM014306 for ; Wed, 4 Aug 2021 07:03:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BA435D9DC; Wed, 4 Aug 2021 11:03:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04E315DD68 for ; Wed, 4 Aug 2021 11:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075102; 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=q7NezlKqGa9z971oh9t22/zvk3YMhmBxp84CKpDDzWg=; b=ZijbIPr0vY4/6zTfk99yabaBa6mjfFZkVx8PcgiS7Nms1lBxBqlPY141T1MMGImrzkVWGP xFQShWc9XqbWtQxC4qrZoa1puDsEIx2mJ0UKI/LaMSTro466/Jwf41qe8shUljrVVTcPyd CCHwyBauMypIFTFTiyJBqFk+CJ9gQPo= X-MC-Unique: _Gb701p8OnyFTymFHJErUA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/23] virNWFilterRuleDefToRuleInst: Restructure code to avoid cleanup Date: Wed, 4 Aug 2021 13:02:36 +0200 Message-Id: <5d3e59b2649e5987b8b93ba1f6cd988e1a404464.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075105533100001 Content-Type: text/plain; charset="utf-8" Construct the 'ruleinst->vars' hash table separately in a temporary variable so that 'ruleinst' can be allocated on success. This allows us to get rid of the cleanup section. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_gentech_driver.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index 4ea0f6f0d6..c9ffa30839 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -252,8 +252,11 @@ virNWFilterRuleDefToRuleInst(virNWFilterDef *def, GHashTable *vars, virNWFilterInst *inst) { + g_autoptr(GHashTable) tmpvars =3D virHashNew(virNWFilterVarValueHashFr= ee); virNWFilterRuleInst *ruleinst; - int ret =3D -1; + + if (virNWFilterHashTablePutAll(vars, tmpvars) < 0) + return -1; ruleinst =3D g_new0(virNWFilterRuleInst, 1); @@ -261,17 +264,11 @@ virNWFilterRuleDefToRuleInst(virNWFilterDef *def, ruleinst->chainPriority =3D def->chainPriority; ruleinst->def =3D rule; ruleinst->priority =3D rule->priority; - ruleinst->vars =3D virHashNew(virNWFilterVarValueHashFree); - - if (virNWFilterHashTablePutAll(vars, ruleinst->vars) < 0) - goto cleanup; + ruleinst->vars =3D g_steal_pointer(&tmpvars); VIR_APPEND_ELEMENT(inst->rules, inst->nrules, ruleinst); - ret =3D 0; - cleanup: - virNWFilterRuleInstFree(ruleinst); - return ret; + return 0; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075030; cv=none; d=zohomail.com; s=zohoarc; b=A6s8SQdgsDk5IB48Piwo8rfW5qpNPcalDqHpYGnc5+jNrwSmCqF3GtjaRhnx4w4cpWLQV/qkZPh75UzifofJ9xafk5Vny/DcNnvGgIbg9N7a23VjzFdgKC1aKjnbBXNBoN7IhRT2bGmTE/JiQ9fvMvnMSzaDWYAADV60hlUAgac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075030; 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=j1TvzTgR0UQ1XMPrM3nAkP7HuNxIMytY0Je9VllxjgY=; b=KtCmbhxY6XmZLZcan5kiHxWqeZR8S85mdDssnL18qRHDekFuiRPwH0LvHqNo8eF7qiq8obRJ+Gk+MTiDSmb7EiROcrEbEI/3tIILgNMZCeHhWZuJO1spc/sYyvbdF5hUOuYhRslUJIegEbfXY4rXuLvKgY13EvbjEEqBMr969j8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628075030750913.2906659633519; Wed, 4 Aug 2021 04:03:50 -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-107-XIUs5_2HPIe4jK2C95n_cA-1; Wed, 04 Aug 2021 07:03:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 22B5434820; Wed, 4 Aug 2021 11:03:40 +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 ED9EE1002D71; Wed, 4 Aug 2021 11:03:39 +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 BDC5D4A70E; Wed, 4 Aug 2021 11:03:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3BjK014315 for ; Wed, 4 Aug 2021 07:03:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id A651517B73; Wed, 4 Aug 2021 11:03:11 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09A1A5D9DC for ; Wed, 4 Aug 2021 11:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075029; 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=j1TvzTgR0UQ1XMPrM3nAkP7HuNxIMytY0Je9VllxjgY=; b=FWKM3WhouYRKEi6V4AAvtZibArAoMpGwWnG98+S+rHvGPcVgJd9KUU61P0d9f9m7OXnsCw K1zpJkI+J4D7NrtZCbcFrTJhd9Ic0egb1IIrXJcaPQziPSze1FkeqcFQqi60k/cMdn+kPJ XOosHzTaj3mtwWOJ5LXpxCGaDYBYBT0= X-MC-Unique: XIUs5_2HPIe4jK2C95n_cA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/23] virNWFilterIncludeDefToRuleInst: Refactor cleanup Date: Wed, 4 Aug 2021 13:02:37 +0200 Message-Id: <8a3214fbd647a3e6708f9738b0270bc55a25d4ff.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075031295100004 Content-Type: text/plain; charset="utf-8" Use automatic memory freeing for 'tmpvars' and move the allocation of tmpvars earlier so that we are guaranteed that 'obj' will always be appended to 'inst->filters' and thus don't need cleanup for it. By moving the reset of 'inst' to the block when virNWFilterDefToInst fails we can get rid of the rest of the cleanup section and remove the 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/nwfilter/nwfilter_gentech_driver.c | 32 +++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter= _gentech_driver.c index c9ffa30839..ecba16d55c 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -281,20 +281,20 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStat= e *driver, virNWFilterInst *inst) { virNWFilterObj *obj; - GHashTable *tmpvars =3D NULL; + g_autoptr(GHashTable) tmpvars =3D NULL; virNWFilterDef *childdef; virNWFilterDef *newChilddef; - int ret =3D -1; VIR_DEBUG("Instantiating filter %s", inc->filterref); - if (!(obj =3D virNWFilterObjListFindInstantiateFilter(driver->nwfilter= s, - inc->filterref))) - goto cleanup; /* create a temporary hashmap for depth-first tree traversal */ - if (!(tmpvars =3D virNWFilterCreateVarsFrom(inc->params, - vars))) - goto cleanup; + if (!(tmpvars =3D virNWFilterCreateVarsFrom(inc->params, vars))) + return -1; + + /* 'obj' is always appended to 'inst->filters' thus we don't unlock it= */ + if (!(obj =3D virNWFilterObjListFindInstantiateFilter(driver->nwfilter= s, + inc->filterref))) + return -1; childdef =3D virNWFilterObjGetDef(obj); @@ -311,24 +311,18 @@ virNWFilterIncludeDefToRuleInst(virNWFilterDriverStat= e *driver, } VIR_APPEND_ELEMENT(inst->filters, inst->nfilters, obj); - obj =3D NULL; if (virNWFilterDefToInst(driver, childdef, tmpvars, useNewFilter, foundNewFilter, - inst) < 0) - goto cleanup; - - ret =3D 0; - cleanup: - if (ret < 0) + inst) < 0) { virNWFilterInstReset(inst); - virHashFree(tmpvars); - if (obj) - virNWFilterObjUnlock(obj); - return ret; + return -1; + } + + return 0; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1628075031; cv=none; d=zohomail.com; s=zohoarc; b=LrhA37/mP0L0jGtb0YwiVp+d9duopMUDnlkMYhVsnD+5WPpRjQYzJJDIggxWHaqkhzpOEh++3SHY96nO5UPbbnly3fADfTPCEJIhBpCxNjSZYZoJ3MYNqlwgJPIs1MAtV/VGWbvUoNBto6dGC9I01xmIhaRYqpY/6n/yVOrVq+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075031; 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=ed3FBXbzOAZs3SE3GCz35oCPf2O+a3qvmW+od9lYaqM=; b=kbYCrUaQnn7XZ3TYBNmqU4pGjTpP2nMqC+Dei3+2+Nph07cIyKEXKhVpl9t4PVqjo+r4hPdtIKzUz+gpK3/V1WaYKKSRsEYe0DxuH0sHe8IL/rVSMAcWWNPB7h/8JSMh+B5lfqibwhYbmG6sXoq4UVcVSjHNwWbK+xLxUWM0Z3I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 162807503183229.61902096671713; Wed, 4 Aug 2021 04:03:51 -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-451-S-xaoPm2MguSe-JBX_N_xg-1; Wed, 04 Aug 2021 07:03:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC0FE1966333; Wed, 4 Aug 2021 11:03:42 +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 8E1274EF67; Wed, 4 Aug 2021 11:03:42 +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 552C71801028; Wed, 4 Aug 2021 11:03:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3CT5014321 for ; Wed, 4 Aug 2021 07:03:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B6D545DD68; Wed, 4 Aug 2021 11:03:12 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2358C5D9DC for ; Wed, 4 Aug 2021 11:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075030; 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=ed3FBXbzOAZs3SE3GCz35oCPf2O+a3qvmW+od9lYaqM=; b=TO8KLW3i/DfSNDiy0H4fk1GDRWm5z/7wWE/ItxwtiBu0JFyvsYjV46XlCi/655h88qZxLQ C1M7z1o4SK6jRgbkhrC57d3aPIVPHRlsDn3ArOYeEy1WB3KnbjqDdTjiipNPJYx1u75bRF Pr3syxbBdItGUFVh2b3o5DRXoZgX/NU= X-MC-Unique: S-xaoPm2MguSe-JBX_N_xg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/23] qemuProcessSetupHotpluggableVcpus: Use automatic memory freeing Date: Wed, 4 Aug 2021 13:02:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1628075033436100009 Content-Type: text/plain; charset="utf-8" 'bootHotplug' can be auto-freed when terminating the function and moving the declaration of 'vcpuprops' to the loop which uses it along with automatic freeing allows us to simplify cleanup in certain cases. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_process.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4730d52f01..68d9de798d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5985,12 +5985,11 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dr= iver, qemuCgroupEmulatorAllNodesData *emulatorCgroup =3D NULL; virDomainVcpuDef *vcpu; qemuDomainVcpuPrivate *vcpupriv; - virJSONValue *vcpuprops =3D NULL; size_t i; int ret =3D -1; int rc; - virDomainVcpuDef **bootHotplug =3D NULL; + g_autofree virDomainVcpuDef **bootHotplug =3D NULL; size_t nbootHotplug =3D 0; for (i =3D 0; i < maxvcpus; i++) { @@ -6005,10 +6004,8 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dri= ver, } } - if (nbootHotplug =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (nbootHotplug =3D=3D 0) + return 0; qsort(bootHotplug, nbootHotplug, sizeof(*bootHotplug), qemuProcessVcpusSortOrder); @@ -6017,6 +6014,7 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *driv= er, goto cleanup; for (i =3D 0; i < nbootHotplug; i++) { + g_autoptr(virJSONValue) vcpuprops =3D NULL; vcpu =3D bootHotplug[i]; if (!(vcpuprops =3D qemuBuildHotpluggableCPUProps(vcpu))) @@ -6033,16 +6031,12 @@ qemuProcessSetupHotpluggableVcpus(virQEMUDriver *dr= iver, if (rc < 0) goto cleanup; - - virJSONValueFree(vcpuprops); } ret =3D 0; cleanup: qemuCgroupEmulatorAllNodesRestore(emulatorCgroup); - VIR_FREE(bootHotplug); - virJSONValueFree(vcpuprops); return ret; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075124; cv=none; d=zohomail.com; s=zohoarc; b=PNYpDZ3+UsEwuk7L8HMABXQmEoOBp7eZl86vAaiUyWoCh45DQMfw2PLPv0hyPo1wccn4cO3OlEd2A/alC+2asq/7sYoUI0WP9OTeZ/Za2s/zfAk6o2iEIjXy++qk3CRiejWexcBrRbiCyl2udPHCj6cwEVHsDPvAAFxNg6hqVAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075124; 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=rnHx1+yTFCqFhF1nA1k+s1yWDiUKkm/PiVuD+3uKxoY=; b=csNXijIHcfqpWg1iCCAx4pbp+ka5lExAIHwCu+NwxtKJnk7Rqoi7ZGlZCCTqdlPEWEgy18hQFrHcEbrliI1BSRtZ2BhKERjG0edyGxPI9CfFcOU8Ea3oBOkak9Dy5N9bRu6+E58NHjdi6hLuQf10/3RJM2EJbYEhsc9ge7POtwc= 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 1628075124643721.9493978284827; Wed, 4 Aug 2021 04:05:24 -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-540-qvNfYh1SNNC1VTfs8XT5Ig-1; Wed, 04 Aug 2021 07:03:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97242363A4; Wed, 4 Aug 2021 11:03:46 +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 79D1260CC4; Wed, 4 Aug 2021 11:03:46 +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 481DC4A71C; Wed, 4 Aug 2021 11:03:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3DtT014326 for ; Wed, 4 Aug 2021 07:03:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id C936C1383C; Wed, 4 Aug 2021 11:03:13 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2778E5D9DC for ; Wed, 4 Aug 2021 11:03:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075123; 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=rnHx1+yTFCqFhF1nA1k+s1yWDiUKkm/PiVuD+3uKxoY=; b=ZVhDLfHK9m+6yNTMtsdCpZxttPog+eaF0/5dyF6yz1t8PovPTVhqmsE90t49c7S6k4vx1r Ctm56hOsleTcbh1/KixmHw+vvEIWfzBOgHDKHdnJDRTv2QpahmY3AmfbsduGd8b90vTEQW wH9m088EIllAbhf0C0ZuzOIAtQUn1ZY= X-MC-Unique: qvNfYh1SNNC1VTfs8XT5Ig-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/23] virNetServerGetClients: Remove pointless cleanup Date: Wed, 4 Aug 2021 13:02:39 +0200 Message-Id: <45cb9cfcb469081131f1f2c6058a290fcfd89959.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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: 1628075126684100001 Content-Type: text/plain; charset="utf-8" 'list' will always be NULL when reaching 'virObjectListFreeCount' thus we can remove the call as well as the 'ret' variable which was only ever equal to 'nclients' at the point when we returned the value. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/rpc/virnetserver.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index bb1a96b65e..b3214883ee 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -1077,7 +1077,6 @@ int virNetServerGetClients(virNetServer *srv, virNetServerClient ***clts) { - int ret =3D -1; size_t i; size_t nclients =3D 0; virNetServerClient **list =3D NULL; @@ -1090,11 +1089,10 @@ virNetServerGetClients(virNetServer *srv, } *clts =3D g_steal_pointer(&list); - ret =3D nclients; - virObjectListFreeCount(list, nclients); virObjectUnlock(srv); - return ret; + + return nclients; } virNetServerClient * --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075039; cv=none; d=zohomail.com; s=zohoarc; b=Q4i9RNXQgtHXEOsS2qW25cTxvxY3Zm0MfSaVsn48KrJQzhLm8r0T52ygbZO+Dw15ezUuFvulO0gIu3zXP4AoG1wAw3OmJCDV1gtyFt2xkWC6gPeqwS2hL4iPlocW5HviVJ/Caip6xdiDSvrD0eQKlimdeLvqx844S2wBMmxAs+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075039; 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=brZHelzbI6PTj+bvsRJcOzq6OfPSlIxJCLpXr0nVxjY=; b=kCGqUERN4MFfZhvr1DdzzvNoKhj44CRu4/LZrZWLKNrmEsed8Sg9yRtpVlRsrcodaps+LfB8Gmt/h/K3o84JfA/viRMIoXCX8cVgcrVHIg5gI22Gcn3Lc4xylvA9Yvwm1dMy/+LRtCsbLuiYpKS6i3n86ODubxYIQBqtIZQiOU4= 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 1628075039216131.58103524540877; Wed, 4 Aug 2021 04:03:59 -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-488-LTmiWc3SPuWn9X1jznG5Gg-1; Wed, 04 Aug 2021 07:03:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D962980292B; Wed, 4 Aug 2021 11:03:49 +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 B126C1002D71; Wed, 4 Aug 2021 11:03:49 +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 7AD22181A2AC; Wed, 4 Aug 2021 11:03:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3Ea6014331 for ; Wed, 4 Aug 2021 07:03:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id DB41217D85; Wed, 4 Aug 2021 11:03:14 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 444BA5D9DC for ; Wed, 4 Aug 2021 11:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075038; 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=brZHelzbI6PTj+bvsRJcOzq6OfPSlIxJCLpXr0nVxjY=; b=JUBMLzbtCbbF5wlwHxvVz8a7qVQ4jBN0VUwtGB4OW3EhfNNTb6Yvs8D1ICPWYMgX7rgJOj rrQTxtoytP7nnV0KOazhKz6pFY/aBfEpxjSfnq20Gwxr6oz1Ohak8WTbtNDNA+MHtVZTtD QBA2LXQsVjVZOWjghdwQsZ1Rk2VCKF0= X-MC-Unique: LTmiWc3SPuWn9X1jznG5Gg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/23] lxcNetworkParseDataIPs: Automatically free string list Date: Wed, 4 Aug 2021 13:02:40 +0200 Message-Id: <44b58b35212bfbdbb7f0402c880aed1b12cb0fbe.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.84 on 10.5.11.22 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: 1628075039610100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/lxc/lxc_native.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 9bf079bbb2..347d5f4139 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -548,7 +548,7 @@ lxcNetworkParseDataIPs(const char *name, lxcNetworkParseData *parseData) { int family =3D AF_INET; - char **ipparts =3D NULL; + g_auto(GStrv) ipparts =3D NULL; g_autofree virNetDevIPAddr *ip =3D g_new0(virNetDevIPAddr, 1); if (STREQ(name, "ipv6") || STREQ(name, "ipv6.address")) @@ -561,13 +561,9 @@ lxcNetworkParseDataIPs(const char *name, virReportError(VIR_ERR_INVALID_ARG, _("Invalid CIDR address: '%s'"), value->str); - - g_strfreev(ipparts); return -1; } - g_strfreev(ipparts); - VIR_APPEND_ELEMENT(parseData->ips, parseData->nips, ip); return 0; --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075226; cv=none; d=zohomail.com; s=zohoarc; b=F/4UaKxm4DOs9p3m13Q3BlE449uf8gTXDkBuxYzx/csiQlKVsUlTN9H5VAosnst5cG79DeVpvVscaOdJBSBb3sBZMgDycqD4LQeOSwfjOov8npPg7Sc0rlmp96SsXInqJmmjBJtQz8C084+mSwRi8qY2SJ0QHqW3oCaY4YbEOOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075226; 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=VwK9AaPrRqiYvbjbOlrx+DIjY8QTBsYPG4sRXdn4ZU0=; b=kfs+D5k9xSVNXhhBSNWoJraI/ftBmr15Qs1utgtXbcdXs4BxZm0/rizic3sz3LTjRAg54IMBCPGFl8BKMA39anuVgDvt2XZz2Om53l4rhWUzWZBdLVx3x+Tg9SLQrw89sfHCiiQ886RWSgIL3Oyi8mOoIHa9Q7yWTt8DpLYUgoA= 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 1628075226256473.41053993180776; Wed, 4 Aug 2021 04:07:06 -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-327-zdC2AzLPMyqQKzLJ-MbT2A-1; Wed, 04 Aug 2021 07:03:59 -0400 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 9DC921084F71; Wed, 4 Aug 2021 11:03:52 +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 803D269CBA; Wed, 4 Aug 2021 11:03:52 +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 4E1B850039; Wed, 4 Aug 2021 11:03:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3Fj3014336 for ; Wed, 4 Aug 2021 07:03:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id F14E717B73; Wed, 4 Aug 2021 11:03:15 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52B935D9DC for ; Wed, 4 Aug 2021 11:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075225; 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=VwK9AaPrRqiYvbjbOlrx+DIjY8QTBsYPG4sRXdn4ZU0=; b=JJlp2V01sgUlLMk17Wob+fCWGGUu6MwUaiRLo0YJ+szr8Sd69SNLDjMEf9hFD66XOHRy1W +kk0/LjYOXqXARrhO9oEgb6jh4qs5X3Yv0h2FJwRgJ+f8VQQI0/NoBaJ3A2RqwxEHqb0jO ByZA6iwgYt5eW+yzlQAc59xrbzm+8+s= X-MC-Unique: zdC2AzLPMyqQKzLJ-MbT2A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/23] virStorageBackendLogicalParseVolExtents: Declare one variable per line Date: Wed, 4 Aug 2021 13:02:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: 1628075227888100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/storage/storage_backend_logical.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index c23d0060ed..cffa2c8849 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -121,10 +121,13 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= Def *vol, g_autoptr(GRegex) re =3D NULL; g_autoptr(GError) err =3D NULL; g_autoptr(GMatchInfo) info =3D NULL; - int nextents, ret =3D -1; + int nextents; + int ret =3D -1; const char *regex_unit =3D "(\\S+)\\((\\S+)\\)"; size_t i; - unsigned long long offset, size, length; + unsigned long long offset; + unsigned long long size; + unsigned long long length; virStorageVolSourceExtent extent; g_autofree char *regex =3D NULL; --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075039; cv=none; d=zohomail.com; s=zohoarc; b=aPWu1dwKLAEHUk/jTRxbZhpqV/n0PSrLdTVHAzDhQLptOLdmOqyVYMhUpmMnDHFXehcz7Y7xKuby5K70874IC6JRHYFSFHy2FyW4ItlE4NWqXYaPcAtBH9B5F18x6pR0Fi4wWptuereV50W/3E6rxoIvxNS2DAie7W/YsL4jmMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075039; 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=fcLKluAibg4QFrZBGd/1PelF5nBm+agm2wO+8fzQC64=; b=MBZt6Envp/GNecbMCfO1tm75PLrmED674bc2MJq+y40fSq9gcz/sir6ayBNVlDSIlLO7BlaLGqrhdgwwRdwmPQIquIn5KjYcws8G+qlRS+RPjfvMAF3B6n77zZA1bOj7Oq6D87QxXWijdk54zSsOFBUjS3tJHFLDhtBGj2/W1FU= 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 1628075039257485.10742534735266; Wed, 4 Aug 2021 04:03:59 -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-38-0oD0234hO4OSz8CddKvUXw-1; Wed, 04 Aug 2021 07:03:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8A9661084F64; Wed, 4 Aug 2021 11:03:49 +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 3B95F29676; Wed, 4 Aug 2021 11:03:49 +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 02DB0181A2AA; Wed, 4 Aug 2021 11:03:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3HF1014344 for ; Wed, 4 Aug 2021 07:03:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30ED317B73; Wed, 4 Aug 2021 11:03:17 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BE095D9DC for ; Wed, 4 Aug 2021 11:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075038; 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=fcLKluAibg4QFrZBGd/1PelF5nBm+agm2wO+8fzQC64=; b=dONFGeV/umCl/NC6PMQITpwPcTj2HB0s1UaNlDpKrmHWXHDVR8yiK0Vc9wJMAiAIYtHbBw O+qmrnXJ06m6WlNga0VohNGJMqQBWhrXO2AM8gw7lUmEdAEJ30xQ8W+b0T6ttmPwanPNO2 NLy3hpLrF4ORVmOmIm+wKtipsUARo2c= X-MC-Unique: 0oD0234hO4OSz8CddKvUXw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/23] virStorageBackendLogicalParseVolExtents: Move 'extents' inside the loop Date: Wed, 4 Aug 2021 13:02:42 +0200 Message-Id: <3a5cd8810df61b81c29cc6132097fb6790d75a86.1628074874.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.14 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: 1628075039624100002 Content-Type: text/plain; charset="utf-8" It's used only inside the loop filling the extents, move it there and restructure the code so that 'extent.path' doesn't have to be freed. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/storage/storage_backend_logical.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index cffa2c8849..90e7c9e41d 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -128,11 +128,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolD= ef *vol, unsigned long long offset; unsigned long long size; unsigned long long length; - virStorageVolSourceExtent extent; g_autofree char *regex =3D NULL; - memset(&extent, 0, sizeof(extent)); - /* Assume 1 extent (the regex for 'devices' is "(\\S+)") and only * check the 'stripes' field if we have a striped, mirror, or one of * the raid (raid1, raid4, raid5*, raid6*, or raid10) segtypes in which @@ -189,11 +186,12 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= Def *vol, * is the whole matched string. */ for (i =3D 0; i < nextents; i++) { - size_t j; g_autofree char *offset_str =3D NULL; + virStorageVolSourceExtent extent; + size_t j =3D (i * 2) + 1; + + memset(&extent, 0, sizeof(extent)); - j =3D (i * 2) + 1; - extent.path =3D g_match_info_fetch(info, j); offset_str =3D g_match_info_fetch(info, j + 1); if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { @@ -201,6 +199,8 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, _("malformed volume extent offset value")); goto cleanup; } + + extent.path =3D g_match_info_fetch(info, j); extent.start =3D offset * size; extent.end =3D (offset * size) + length; @@ -210,7 +210,6 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, ret =3D 0; cleanup: - VIR_FREE(extent.path); return ret; } --=20 2.31.1 From nobody Thu May 2 08:59:39 2024 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=1628075291; cv=none; d=zohomail.com; s=zohoarc; b=bHZ/XPdf3BgiVAcCApT0m4vmpilDJcFZJYWRB/t1WAG5TCIGdNXJhWZ432EIKhYUGsBs7DWm8goI9PB7RYkaFIFALzv+YmERKoMTwXLDGShilAy/Yq+xaz0JuiI+s6FaP0eG/peIXil/osgeGypDU1eC8bYqDVU6DcfdVQGi0TA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628075291; 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=uSa/MhY//gijkhbv4tqLSwNUBW9pbAtlgRp/aKNR1k0=; b=N9Ub13yaZMI5ARtzo/CTxlHxuGEdkxToRocFWp0Su6hZWdhTZ3mPSpmwdEbEy+L982u5ZId6Vr5Z1rktL4XyWyy1Cjt7WOeRPI/SstQ1j4bid3aqXt2EmKi/CSAIiE4NCkMCufQKHEq4UReoc59YoCdi3Gc0dQll1x7MCdsUFZ4= 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 1628075291729493.9816833880269; Wed, 4 Aug 2021 04:08:11 -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-139-IandtuZlM-2tZXZuAcB6Sg-1; Wed, 04 Aug 2021 07:04:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7B4513938C; Wed, 4 Aug 2021 11:03:56 +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 5B36B60BF4; Wed, 4 Aug 2021 11:03:56 +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 2985B181A3F0; Wed, 4 Aug 2021 11:03:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 174B3I3w014351 for ; Wed, 4 Aug 2021 07:03:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42EBF17B73; Wed, 4 Aug 2021 11:03:18 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0274295E5 for ; Wed, 4 Aug 2021 11:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628075290; 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=uSa/MhY//gijkhbv4tqLSwNUBW9pbAtlgRp/aKNR1k0=; b=VQHWLtWNjI8269XZNSOVOmPnwuiDcE5bcaRkVauF/7aZlpPY5syARplteHXl5IQoMwhCrY mq+Vd1UwtH3LDZDQv8wt2AoHnXgMHI+AmvWiK8hrncgBFIwECafmc23qm3qGme1lJozDC5 xYQFGVWUGqWP9ytszorl4XVy6Gd7+J8= X-MC-Unique: IandtuZlM-2tZXZuAcB6Sg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/23] virStorageBackendLogicalParseVolExtents: Remove 'cleanup' and 'ret' Date: Wed, 4 Aug 2021 13:02:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 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: 1628075292554100001 Content-Type: text/plain; charset="utf-8" The function was inconsistently using 'return -1' and 'goto cleanup;' unify it by removing the cleanup label and 'ret' variable. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/storage/storage_backend_logical.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index 90e7c9e41d..ed490b0201 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -122,7 +122,6 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, g_autoptr(GError) err =3D NULL; g_autoptr(GMatchInfo) info =3D NULL; int nextents; - int ret =3D -1; const char *regex_unit =3D "(\\S+)\\((\\S+)\\)"; size_t i; unsigned long long offset; @@ -144,20 +143,20 @@ virStorageBackendLogicalParseVolExtents(virStorageVol= Def *vol, if (virStrToLong_i(groups[5], NULL, 10, &nextents) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent stripes value")); - goto cleanup; + return -1; } } if (virStrToLong_ull(groups[6], NULL, 10, &length) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent length value")); - goto cleanup; + return -1; } if (virStrToLong_ull(groups[7], NULL, 10, &size) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent size value")); - goto cleanup; + return -1; } /* Allocate space for 'nextents' regex_unit strings plus a comma for e= ach */ @@ -179,7 +178,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, if (!g_regex_match(re, groups[3], 0, &info)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent devices value")); - goto cleanup; + return -1; } /* Each extent has a "path:offset" pair, and match #0 @@ -197,7 +196,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= f *vol, if (virStrToLong_ull(offset_str, NULL, 10, &offset) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume extent offset value")); - goto cleanup; + return -1; } extent.path =3D g_match_info_fetch(info, j); @@ -207,10 +206,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolD= ef *vol, VIR_APPEND_ELEMENT(vol->source.extents, vol->source.nextent, exten= t); } - ret =3D 0; - - cleanup: - return ret; + return 0; } --=20 2.31.1