From nobody Sun Feb 8 14:59:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1670518798; cv=none; d=zohomail.com; s=zohoarc; b=Ag3MM9FF6lr/8hP4b0e2HcLwmNqIoyX0modrCfx3DwyC1ztH63Y89cQMfHBQwtpSSTmf/PmCBT6QQwNNVtIGOcY/yEvkP+lWURnLcB5iYjfizUmTZPzTKZ+1ACaNGPcBihoanf8G0OsEaBsVRFrkrmEPQ0Dxp3n+45c/iHctiv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670518798; 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=avbUR3J/2ZUHGONOgM4BcitHGJGcj3ICQhrYZ/50QE4=; b=hh1pU23vJkt8ySEsVcYdp1ddopOWtEjutIMJHsHtHNckipmtRbSVLO+FsOpdtmL0t9SeNQJbccNdVkXMCY3Gj/oHA3n+g9dyUlEhqzqIK8G7tSJFH2QWFvWjd4ilQRiint2oll4yyxX4obEdYAMTWO5fwb8IriRTI/WdZa959yE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1670518798739494.25518716883767; Thu, 8 Dec 2022 08:59:58 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-147-LCX4mBeCNuSbkdCSvRhtnA-1; Thu, 08 Dec 2022 11:59:52 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C252D38164D9; Thu, 8 Dec 2022 16:59:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD23E492B04; Thu, 8 Dec 2022 16:59:48 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C06FA194704B; Thu, 8 Dec 2022 16:59:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4FA461946A41 for ; Thu, 8 Dec 2022 16:59:46 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 24ABB42222; Thu, 8 Dec 2022 16:59:46 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCFCA17582 for ; Thu, 8 Dec 2022 16:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670518797; 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=avbUR3J/2ZUHGONOgM4BcitHGJGcj3ICQhrYZ/50QE4=; b=basP3FakjxHU6Dhy7OtuGe4dB/mXBAlw73epX/r+ln1A62FFEPLMiGA8HGckrGXnWEiI6R pH+wzVlSVQSP8xebhPa9Uo9e6iSkVDm+1w1Hx/eFJGDDWM48dhqsUZUDh+96bwBHt2lmir 0ikkhM/eX7AZFG4R7Oxc/69b0atnggI= X-MC-Unique: LCX4mBeCNuSbkdCSvRhtnA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/2] virnetdev: Make virNetDevGenerateName() return 1 if no name was generated Date: Thu, 8 Dec 2022 17:59:42 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1670518799844100003 Content-Type: text/plain; charset="utf-8"; x-default="true" A caller might be interested in the case when @ifname was already set and it wasn't a template. In such case the virNetDevGenerateName() does not touch the @ifname at all and returns 0 to indicate success. Make it return 1 to distinguish this case from the other case, in which a new name was generated. Signed-off-by: Michal Privoznik --- src/util/virnetdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 66cfc5d781..82dbb486f2 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -3595,7 +3595,9 @@ virNetDevReserveName(const char *name) * Note: if string pointed by @ifname is NOT a template or NULL, leave * it unchanged and return it directly. * - * Returns 0 on success, -1 on failure. + * Returns: 1 if @ifname already contains a valid name, + * 0 on success (@ifname was generated), + * -1 on failure. */ int virNetDevGenerateName(char **ifname, virNetDevGenNameType type) @@ -3609,7 +3611,7 @@ virNetDevGenerateName(char **ifname, virNetDevGenName= Type type) if (*ifname && (strchr(*ifname, '%') !=3D strrchr(*ifname, '%') || strstr(*ifname, "%d") =3D=3D NULL)) { - return 0; + return 1; } =20 if (maxIDd <=3D (double)INT_MAX) --=20 2.37.4