From nobody Mon Feb 9 16:34:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612448061; cv=none; d=zohomail.com; s=zohoarc; b=JknEroHplHm8Nb0d9oTMPAldVJxhSpVTPc2vikPSFv1rkuwLLWmZbYj6NQcC2356x/5wQjyOCeZE7AE4yvfbUzOo5F+/OELyR3tml1kuuzMI6+EKGuBFPLU8K5DPldwhZrqL07qVu7qA9DSwS9GL420ciuqGrqVE+hju4fwL4/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612448061; 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=UcEZyUaB0mqRgwKjsa/BisM+lA6z9EwyX/cjNIdiRwM=; b=XfodGFpYJ+W61hHb48y7CzSH/A/o1tnFezOKU84k91E+dFYWSuOtTwrUih+WZCsaSj9+wpMflaajZFo1CrOu3xFbK3kb3SH97AfOXyO8r1npRkLEDYwd12R6wjP5VHVbKoisJDQ7DHkTxdu3B6SlgdI1dz6o6+5pCLCONknDrvA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 16124480618371007.0127303458943; Thu, 4 Feb 2021 06:14:21 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-_D4EGT_kM-eSXokAsYtKbw-1; Thu, 04 Feb 2021 09:14:16 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3856107ACC7; Thu, 4 Feb 2021 14:14:09 +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 BFB932BFE2; Thu, 4 Feb 2021 14:14:09 +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 87FA318089CC; Thu, 4 Feb 2021 14:14:09 +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 114EDphT031604 for ; Thu, 4 Feb 2021 09:13:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id E63375D9EF; Thu, 4 Feb 2021 14:13:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id 681525D9C9 for ; Thu, 4 Feb 2021 14:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612448058; 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=UcEZyUaB0mqRgwKjsa/BisM+lA6z9EwyX/cjNIdiRwM=; b=XyLzXvmca5fm+87kV4sRQrf/oIIKVfshusPFmyaLvO9/pmT9v4S1Iedcd86Q5RtHU6FCps HJm+6tY7f+o1hqbZzWFjWTvkZkneORh4WgwJSWvXPqXhuXk0svy9LzPpRz8S/mHQZ0Q3Rm UQJlAOnVdxomGnhvNsnydqnhgCVTsD8= X-MC-Unique: _D4EGT_kM-eSXokAsYtKbw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/12] vsh: Accept NULL @list in vshCompleterFilter() Date: Thu, 4 Feb 2021 15:13:29 +0100 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) Content-Type: text/plain; charset="utf-8" The aim of vshCompleterFilter() is to take a string list and a prefix and remove all strings from the list that don't have the desired prefix. The function is used to filter out those strings returned by a completer callback that don't correspond with user's (partial) input. For instance, domain name completer virshDomainNameCompleter() returns all domain names and then vshCompleterFilter() refines the list so that only domains with correct prefix of their name are offered to user. This was a design choice - it allows us to have shorter completers as they do not have to copy the list filtering over and over. Having said all of that, it may happen that a completer does not return anything (e.g. there is no domain in requested state, virsh is not connected and thus completer exited early, etc.). In that case, the string list is NULL and vshCompleterFilter() can simply return early. Signed-off-by: Michal Privoznik --- tools/vsh.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 3cb657f582..13bf525acc 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2703,7 +2703,7 @@ vshCompleterFilter(char ***list, size_t i; =20 if (!list || !*list) - return -1; + return 0; =20 list_len =3D virStringListLength((const char **) *list); newList =3D g_new0(char *, list_len + 1); @@ -2802,9 +2802,8 @@ vshReadlineParse(const char *text, int state) /* For string list returned by completer we have to do * filtering based on @text because completer returns all * possible strings. */ - if (completer_list && - (vshCompleterFilter(&completer_list, text) < 0 || - virStringListMerge(&list, &completer_list) < 0)) { + if (vshCompleterFilter(&completer_list, text) < 0 || + virStringListMerge(&list, &completer_list) < 0) { goto cleanup; } } --=20 2.26.2