From patchwork Mon Feb 26 14:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 775870 Delivered-To: patch@linaro.org Received: by 2002:a5d:6103:0:b0:33d:da16:65b6 with SMTP id v3csp348969wrt; Mon, 26 Feb 2024 06:13:04 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX3JqLAnHNiyWb5uQ+hgTyI9trEHMkpzcPVRLUSIydYXtxD0BQBUmX8IslRXXKBXsrG/HYMDlGVtdlo/W9ip9C9 X-Google-Smtp-Source: AGHT+IFTfOPgh3a5dVLLg8qN2SdRLdW17eFW1t419F2LwoSEK6xrNUeUspiooPiWVf6p02CZMkAy X-Received: by 2002:ac8:5f91:0:b0:42e:7ece:8f96 with SMTP id j17-20020ac85f91000000b0042e7ece8f96mr6155504qta.19.1708956784602; Mon, 26 Feb 2024 06:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708956784; cv=none; d=google.com; s=arc-20160816; b=oe2CiJyCIdEYQcMXi7i3IKYEIXzVLovzgMG5kW2n+2CyAaOb2rqiMeQ5Yqr/LtEMTp HSVI1X+5IYwccV6OHAEqZEHkLevyJ8Z2MJ/eL8FLma+WiAAkpjy2XBGwcLjQ/T2xFH0i ynA4ho6ffHsy5mWO8iAJkTfQGY46G0io1G/npUoddsNv6T75s6YljYrgYmw2WjXdToP1 RlS4Rl7tGWCnJvHPRXM1m4o+TtZOAmkYSx4fc9RkqWO/dJiLYkNGWawMz2cNkboJtEkm jzpDNoHlVc4ccjznSqnGx9jMfPfMrfEUQzNI22Ek3UipHRiNozm1f8nzoATl8H1dEgH4 nrnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ECJWBAuFizFY5M+8BFfcvUn+iW291fgpghDCdO55uQY=; fh=ZBsiCBGz5jaXAQ4DyGdtDqpkDJPpebqEUZWnvrNsvRY=; b=eMTiH4FQiM0a10SOL8l/bkE+nlm5uAjegBUyIzK7ef3UdtBZnl3oj5dvorBqI5MuUo kT9tldTDr6xdn9NQuFkkiKUk3lXAEOL1244EjuWKZyjBR5KknFWvlLMWgvA5MSJdQc33 1zunnKL6zIYhEd5y2a88i+Uz9veeCPw4iCDs5iCU7SpDS2z4rY8Kyie+6/dciya+pl7G nMmeNaieARg1u03MoExRTIZ5p9dBOUuUiUqhoQfZwCkDbpi5TGkq+0OIb977ceU8eiCK 96PP42XRBdF1uEXp6xPBt/tDfAW5sLqSdXstaWbUv5qfe6D+kVEC4zA63QLW7Xwr3cJz tIoA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yPR99tnn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g26-20020ac870da000000b0042e80d034desi2780616qtp.66.2024.02.26.06.13.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Feb 2024 06:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yPR99tnn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rebhh-0003Bz-6F; Mon, 26 Feb 2024 09:11:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rebhd-0003BR-Ev for qemu-devel@nongnu.org; Mon, 26 Feb 2024 09:11:33 -0500 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rebhb-00024l-Pt for qemu-devel@nongnu.org; Mon, 26 Feb 2024 09:11:33 -0500 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2d204e102a9so36270061fa.0 for ; Mon, 26 Feb 2024 06:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708956690; x=1709561490; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ECJWBAuFizFY5M+8BFfcvUn+iW291fgpghDCdO55uQY=; b=yPR99tnn/j98GrzA5rhv2EpShQjrtUSgsqSBFpdxnFXCHdC+WMPfwDyUGvv8WZuWlk tANTbiqOLqgtsVt1/btZpmsrmWscyrPZrH0dQe90JArkLaQZTO9wyZE1utETGXCGcOMb z0DUEme3tGQ3V8NhSuaf8EHHR7gchRex4pB5/nRtJ2xqtStSPEDDcraV3MuYPqpZrdz0 a8lkmZMFXqJSHB28yhjjQm9ZK7pbZUAr3SYziv2tQXZhRmiIDQnjhA+9NSq3g/yzLf/P 9/Y7STi0mlzh7FBx3pu5rvea+NGXJadVp/0PDkPf54x8vVCt2tewG745ehBJqWs9M7wW tFHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708956690; x=1709561490; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ECJWBAuFizFY5M+8BFfcvUn+iW291fgpghDCdO55uQY=; b=m/Ex5bk+BrnGf35MFj2uYsXolod4LTGXLCQxDctneuKAGG4hglojQabBqhq6Gqsg80 a56t2kVTM4sJhcHsWI3cRZ9juDmSl133iYuyF2I7QkIwimFKxqvWWmsXJ9408xfN+PwD nPHmdCht71Z6OZDa9WCL0Ne8ECXGdt/r6vuMLQrds4/ekbYBtiDECkXm//8tzVUOOO3t xUk/T76QkNokctTzESQrY6qy7Hf4keRcxUfd+nrw//wSQgUfqexLjcbIQCt2QTL6mH/j oXMmasjm+xRqGsNkxlnTczOGLErveMpZrZKrAdwZ5VqQKyDEIIyv8Ma4IwPfBsjD4cJj xGow== X-Forwarded-Encrypted: i=1; AJvYcCWXlMDIjoblbZn1iOE/MvSGG92DPRGrytep2tIRy31QyMebEqfaZ0B+AogujSEN+es+hyvV0LwcgLZgjS45wp5/LksMRK0= X-Gm-Message-State: AOJu0YyAe+O3XSk9aNtw4X6FsNuic8RxiMZJc4weNKk0buEcNtt0e+5a SnRyeM3YNyISK8V3oNqiYklAewhhhUcel1ylzTAOORXb3Aijgpj5bL7DcKFkXDA= X-Received: by 2002:a05:6512:3b2c:b0:512:f719:aec5 with SMTP id f44-20020a0565123b2c00b00512f719aec5mr4068070lfv.9.1708956689785; Mon, 26 Feb 2024 06:11:29 -0800 (PST) Received: from m1x-phil.lan ([176.187.223.153]) by smtp.gmail.com with ESMTPSA id gq9-20020a170906e24900b00a3fa275de38sm2438554ejb.162.2024.02.26.06.11.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 26 Feb 2024 06:11:29 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , qemu-devel@nongnu.org, Steve Sistare Cc: "Dr. David Alan Gilbert" , Jason Wang , Michael Roth , Peter Xu , Fabiano Rosas , =?utf-8?q?Ma?= =?utf-8?q?rc-Andr=C3=A9_Lureau?= Subject: [PATCH v6 3/5] util: strv_from_strList Date: Mon, 26 Feb 2024 15:11:05 +0100 Message-ID: <20240226141108.73664-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240226141108.73664-1-philmd@linaro.org> References: <20240226141108.73664-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=philmd@linaro.org; helo=mail-lj1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Steve Sistare Signed-off-by: Steve Sistare Reviewed-by: Marc-André Lureau Message-ID: <1708638470-114846-4-git-send-email-steven.sistare@oracle.com> Message-ID: --- include/qemu/strList.h | 8 ++++++++ util/strList.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/qemu/strList.h b/include/qemu/strList.h index 4e2e78624e..b13bd539c3 100644 --- a/include/qemu/strList.h +++ b/include/qemu/strList.h @@ -22,4 +22,12 @@ */ strList *str_split(const char *str, const char *delim); +/* + * Produce and return a NULL-terminated array of strings from @list. + * The result is g_malloc'd and all strings are g_strdup'd. The result + * can be freed using g_strfreev, or by declaring a local variable with + * g_auto(GStrv). + */ +char **strv_from_strList(const strList *list); + #endif diff --git a/util/strList.c b/util/strList.c index 7588c7c797..6da6762c08 100644 --- a/util/strList.c +++ b/util/strList.c @@ -22,3 +22,17 @@ strList *str_split(const char *str, const char *delim) return res; } + +char **strv_from_strList(const strList *list) +{ + const strList *tail; + int i = 0; + char **argv = g_new(char *, QAPI_LIST_LENGTH(list) + 1); + + for (tail = list; tail != NULL; tail = tail->next) { + argv[i++] = g_strdup(tail->value); + } + argv[i] = NULL; + + return argv; +}