Message ID | 20241030163957.2822282-6-stefano.babic@swupdate.org |
---|---|
State | Accepted |
Headers | show
Return-Path: <swupdate+bncBD2ZDGN6SEKRBYWCRG4QMGQEPF2WGAI@googlegroups.com> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=EJzO2Z3m; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbywcrg4qmgqepf2wgai@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XdtCF2DyZz1xwc for <incoming@patchwork.ozlabs.org>; Thu, 31 Oct 2024 03:40:08 +1100 (AEDT) Received: by mail-wm1-x33b.google.com with SMTP id 5b1f17b1804b1-4315d98a75fsf73785e9.2 for <incoming@patchwork.ozlabs.org>; Wed, 30 Oct 2024 09:40:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730306405; cv=pass; d=google.com; s=arc-20240605; b=YkXTzwclIVpaIHMB/q5bdZgqxI1wzWznl2XjMHM/tFSr4fW3RjfDsESYmZsZpe18gE JnrmeM1LgWxoEZrC4J+F08qCOYNW2xUNZmaGoAtd9pJTTkP0nZ7ZjoLjObtGkE3lPeyL ntVvdU/4xzNFqK1sCa1fVMmYZVDjrWx7Nl/kPSylS8wDXrC/ygtnvmRDb+WrQ1EtNTZC 98CUaTDIH6AUsyLNnTYAXwrPd87OF0Gj+j1ko+JpGrHkRKhsymrsPp9dkUmgBokUBxtI fVdfCvBc72Uhfiw8TWkxf4oXVvYMBbCLtfWaPf//3VvcJuVihQwoifock6Z1kfD68dFN BZcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=khOQzAtbKuqw9HRUcgXEL9ccPMoM40jXdqBaVNS7uC4=; fh=bVIVgafs+OZ4kmHTh4caIaf6TByE1AWg+lhCI9Bo/ZQ=; b=CTmNjvT0DHDlAQOmsYOcPrJx+9rZyweXLPH5xqDR6/foqLUA7MJ7Aap+968msCCgvZ Ru5HmWKyH7PNdOR9Viezakv4X+8J8t10Cc3Axy5gHOX0ImB1LAqtJy88FP4HUvMGZM65 ShlJ56TJ2uyKB7CKcyHkJuCfmPP1bDTcHByodg9TRKWq5ftlC0EebfcAODfVJfLGoFZi 5t8/NeL4YvPhBBBpUxJS9/6KTKKA3N12KoFcwv+M6IH4KkquZ520FR004iZQPiT4mSVM gk3UXF3h6+I8yTjzfM/8zUhhENwULhDfDMYVCIw5wBV2dn+hECU9hT3bPxOLsziJJewU GsgA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=BvCRGrpz; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1730306405; x=1730911205; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=khOQzAtbKuqw9HRUcgXEL9ccPMoM40jXdqBaVNS7uC4=; b=EJzO2Z3mN6Gu9YygM8elo9WUTJkhh5+GJ6Qxdquf7L1vA/DqQqYa35Uo8bJmQKRt8b vubUF9/lZSaf/pjqf7np7eQ12qmF/e7JfdQe/ZslbpuOrCrDUyhP2WJxr4g35lm+CKsk /y0eiIxwXJ3kdOHbBKD7ub1G1yYyGTPFnDWt5+f4ywoCymCymU4tnLyrodzs0xMUZ7XE IWa3iPABkvZUwoqDz8NPMqobT4Fr+k0Jq73+7YsDiQ2h+tUgeOqr/IjTkTlTcjHRWdvW 2L7dl8Cw/v4Co6kJnLqh0dbktsQngT1zydPJUqWUH+dvn4CX0bU5U7NbJ0HIGhqgtDzz ahaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730306405; x=1730911205; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=khOQzAtbKuqw9HRUcgXEL9ccPMoM40jXdqBaVNS7uC4=; b=WydBAfc+PI6IrbkmKUGrAR96dfjbBNp50g2z+ASU7rRzigjXBVSphk1hOQZe2fE4bK VVe2vJ/bNtb5Y5ioFO2ctLROB0nFN2NFvAbkHLdx4+XRkZNr78uoSo+qZoix0pzwbWGE 6vJ39op21v4SjHU0JNWqnX2AqdM2cPpWJbmC98bj85kQ3oNIoBp8RYBR65eCWTko0+zd gaiVfm4Mt+vmVEGEvbWtmpQAXWeGRXV3AyKUA5rroFuGSYQUUkhs84h/2EceJ1AfcDog evb8slnavi5CoBYxIbuNxZlYkfykV2y49r96gryqHcCChFB0dOxYmL4aK5gBnFSr+5vC 5vcg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUidnvf0HDmQGD2FFR/+h5bH2IaaWqo5NanVePdRoj5OqXTPYFhUSdFnQMbDEY+pJiB2g/Q+sI6uQ==@patchwork.ozlabs.org X-Gm-Message-State: AOJu0YyunzxSNwEAwPaDbBlhJDedAh/dpJey6H3S6txFntXRNwom/68A nZuQsN4AfjW0Wgt68TFegJKZwLxlVoTpZFM2AwZv1tdsdL2yVB9H X-Google-Smtp-Source: AGHT+IHG5M2CjmqtW8Hd9uGtLJ4J458OisHYm0UHajPhv7OjyzUgS25xMh9vtCnEGgepAnEgPgxjQg== X-Received: by 2002:a05:600c:3593:b0:430:54a4:5ad7 with SMTP id 5b1f17b1804b1-4319ac76449mr150495745e9.1.1730306403497; Wed, 30 Oct 2024 09:40:03 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:4fc3:b0:431:4fa0:2e0a with SMTP id 5b1f17b1804b1-4327b80876fls364695e9.1.-pod-prod-09-eu; Wed, 30 Oct 2024 09:40:00 -0700 (PDT) X-Received: by 2002:a05:600c:1c03:b0:42c:af2a:dcf4 with SMTP id 5b1f17b1804b1-4319ad141admr115353665e9.27.1730306400137; Wed, 30 Oct 2024 09:40:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730306400; cv=none; d=google.com; s=arc-20240605; b=hEoaDdobWgj5t7cps7OSu4m9JMH0hin/Z7UCJGoVj+x/+PB52c6Yq4RDP2eed319yq wEe82SL1o8FBuYCx+G0tSm+jgnqkTAJSbQ2E7S3Qe9X2HD7IB2JGRH/ZiyMVeX1WrKQQ /8JX8YOcuin9QntpwW4jv6aFGq3UHzWtl5uLg6xC31jyNYQzDA2kalL0cAYKILNl5Ir8 qiOlVZ9Fid1YFxO15u3yWf9kQabtY9yt2ukoLVL3q6p2dV+l8UZWSG83fLwhhYQmpoFF LzevmNzdmj873E+UdwSlQgjP33HcVe0ZEBolwe6NbFRZOnmgmL1ovyzfHFmPNuHxhtGF I1ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=hFE26uUs6MfS7Rr78afufNCkEx6rJRGJSHtsm5fVA0c=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=PcH4HHYkpM7+ovlEisyYx4/BHbddTQAuLkwml+N09H9bGzsqRB6db5C7md10mJhJhd sw601kTVL05iKeCB04UJOwuVOxH6se0KUUDMIceEG9YVtChtyvnWbNwe20jpYRzQjcUO TPNf6XhQIOzOt8I5w42JkxqcbPRULC7cIl1AShbZUHPaIMD32y81bejec7G3x4BAeMre JnM5tY3FdaA5Mb7cyWefC7cihJLWhTne++n/qrZ89TV+GBNOmZZFq+ScFWXt+HoRct4X SETSkFELZWNO4a0lzTNBHZG3in71WzZitBujIFzq6DpUomer7K6bmmCA8hKQ4POgI1pG OFDg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=BvCRGrpz; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.134]) by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-431bd9067d5si431785e9.2.2024.10.30.09.40.00 for <swupdate@googlegroups.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 09:40:00 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) client-ip=212.227.126.134; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1M5fZ4-1tCGXN2y0w-00DDd4; Wed, 30 Oct 2024 17:39:59 +0100 From: Stefano Babic <stefano.babic@swupdate.org> To: swupdate@googlegroups.com Cc: Stefano Babic <stefano.babic@swupdate.org> Subject: [swupdate] [PATCH V2 05/10] Add helper to concatenate string Date: Wed, 30 Oct 2024 17:39:52 +0100 Message-Id: <20241030163957.2822282-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241030163957.2822282-1-stefano.babic@swupdate.org> References: <20241030163957.2822282-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:PHJ5Sxomlw6VkdV73S7prDsP8hZO4PZB201QlVK0rRUfJjR6/Br aPFAv7lC2WCu1MU8QeeRt29UUEr/teqxjEE7138WOIVqjODhJxX76RPE5mdel/9pIUxs4d4 U6CLBNhOK3JghAGrYhzj73k7HBCDT44M51/GZwY3RNS7Shvr0M+SwuujW+SwStYtFe6/aBC GA3qjFl9E58VfmDoAF7XA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:blW89Xk/EyQ=;91mgKlTPSDWluMvZ8zwh5Hqstr3 ocqk0ZvxU0lVoHT/YYK2t2BJUZrPApbMMVSAe1yHpC8QQvBsu1J58mUHTefD6GDaykudxleIi vxIqSpvi/NMA0UA/CZTgPQ0PZaTNynrI+GtxfpC1zsTAYXOg2JgLxoOVkKqBPSENbREhWAxya mw48XEm60TJ71/Ical+2o7oxqWu3pHdc3SjLfcZZPxMecH2RKBSFv7XXqgqKpnIUdPTj8+IUl qYD9/y/pDifVbp0bgZKCamcBpGumhavbs65gNcPmOXYQ3PWC/CpV2bfi6pihbKWiUZYGP24gQ KZBUtUiobThKU7I3wTnMI5w2wiEBBA/30RTdD2ELep2WqkmR6lZWPVUuD5BFQSKiTnDG18rVN wukWy6HC6UxXTIrO6ni4j4TPUWV3XcMIvILn3Sj/JxR4gltkflkS1B8AsojdT85AbK6Mq3x3j 5P6eEz7rC84A8mlLAkigqtpx2MBm4pkmxFvjgrdQEFy54Nqed9OmiRY1fHCdr1ilH/X3xxsao h8kLYvonfb8fH6y4QcsskrQ6UHXDhX19xWI4Op9vx7yJ1AMu4OZuqAr3/OOnsx6L6vp7RLywC sIgO3i8i36cIHYOCgHtdngSxGGkW3A76s6h4jOTmr0RvKF8QLyK67bA8SSPqK2nx9GGrv4C3w IC5MaczRLlKVOxGSEI1TtPSSTQqbqFYXx9reVB+DPFQo5+guzvY8XOdrawJRSrmm5AINuoGGN HPj/EbAW7c6jZQhvx+EZyVbDxvJpl4jng== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=BvCRGrpz; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: <swupdate.googlegroups.com> X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: <https://groups.google.com/group/swupdate/post>, <mailto:swupdate@googlegroups.com> List-Help: <https://groups.google.com/support/>, <mailto:swupdate+help@googlegroups.com> List-Archive: <https://groups.google.com/group/swupdate List-Subscribe: <https://groups.google.com/group/swupdate/subscribe>, <mailto:swupdate+subscribe@googlegroups.com> List-Unsubscribe: <mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>, <https://groups.google.com/group/swupdate/subscribe> |
Series |
Introduce BTRFS Snapshot Handler
|
expand
|
diff --git a/core/util.c b/core/util.c index d50176fc..32104279 100644 --- a/core/util.c +++ b/core/util.c @@ -7,6 +7,7 @@ #include <stdio.h> #include <stdlib.h> +#include <stdarg.h> #include <unistd.h> #include <string.h> #include <ctype.h> @@ -295,6 +296,23 @@ char *mstrcat(const char **nodes, const char *delim) return dest; } +char *swupdate_strcat(int n, ...) +{ + const char *nodes[n + 1]; + + va_list valist; + + va_start(valist, n); + + for(int i = 0; i < n; i++) + nodes[i] = va_arg(valist, const char *); + nodes[n] = NULL; + + va_end(valist); + + return mstrcat(nodes, NULL); +} + /* * Alocate and return a string as part of * another string diff --git a/include/util.h b/include/util.h index dcfbd4f0..068f0195 100644 --- a/include/util.h +++ b/include/util.h @@ -237,6 +237,7 @@ int syslog_init(void); char **splitargs(char *args, int *argc); char *mstrcat(const char **nodes, const char *delim); +char *swupdate_strcat(int n, ...); char** string_split(const char* a_str, const char a_delim); char *substring(const char *src, int first, int len); char *string_tolower(char *s);
Just using strcat() is painful and there is already a function to generate (and allocate) a string from an array of strings. Add a helper function to concatenate two strings - this returns a new allocated string that must be freed by the caller. Signed-off-by: Stefano Babic <stefano.babic@swupdate.org> --- core/util.c | 18 ++++++++++++++++++ include/util.h | 1 + 2 files changed, 19 insertions(+) -- 2.34.1