Message ID | 20241030101550.21014-6-stefano.babic@swupdate.org |
---|---|
State | Changes Requested |
Headers | show
Return-Path: <swupdate+bncBD2ZDGN6SEKRBXEORC4QMGQE72HGYBI@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=tLIXPS6W; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbxeorc4qmgqe72hgybi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (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 4Xdjh41wxjz1xwK for <incoming@patchwork.ozlabs.org>; Wed, 30 Oct 2024 21:16:03 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id 38308e7fff4ca-2fcdfdef26dsf9255751fa.3 for <incoming@patchwork.ozlabs.org>; Wed, 30 Oct 2024 03:16:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730283358; cv=pass; d=google.com; s=arc-20240605; b=XGcjrC5Oef2cK8yDyQcvA4+7VXgI3obmWX+iH/ObuStEqAZXA9Pwd1dS8EPOOtQizi ElZ5pL0/IPgD2hXZAA4jjvQ+d7kmt7eYeTsUwP0vuY5nx0cs6JwDIO1qvH93t4E8fPZW gff6xrEJvm8BBDUiJAqGNuQHkfQ4Ok8dZIFNbcVFpt4YVZvj9pQj7rfea+nxT5Uxmx8B ruQ7NfwO+0DQl2EfFMzU/zlBStfVWnnI+e6WelWV9Oq36Nb5ruyyd38Bq1wqkQY+jJXe 9d4ebjBsJQPKUkR0NfV7WLhaCHk0Gg8ASLEMnK3LP8Ake6AE1XHNP8zE1sftYQDLZp2y RiNQ== 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=M7/BvtYlV1qgq+czxjn4mzy5E8FsDWiUJx1i67ihv0Y=; fh=o01vTBviokEvLCnhSJKcR9NZcem8Xeb4vd4Ty7qDcms=; b=P9ioai3ELPKxDkJ9jC8Nc70yrOg4WjBihqs8ec4teiBY2NfdC4UIAOlF5kbyrqCA99 TawC4xpk8RbCy9H1Hnr7Z8NI3lUz/lPASJJ05RPjae7KwMB8ZMgas/Ac8tN9VgxUjooi XNr42RZPVmoSXhzQEjhtPDaHIh2wgfGaMd9SpVn4kl6P9atEVBuyi2rQ7Ns09pIQHj7S aK5IB7CjaYJzcfzEiKXyujnMdLxy4yWRqYW1np9AlB3deVz4gzrjKTgXkRbzKVT/pI73 mHrJ9hw6OKBPaJkLtAxDIOepWvsKUOq3N1Zd0vBErtmfp/9fJfFGdHSKLJZY35JP8k91 j6rA==; 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=OI0eyIHb; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 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=1730283358; x=1730888158; 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=M7/BvtYlV1qgq+czxjn4mzy5E8FsDWiUJx1i67ihv0Y=; b=tLIXPS6WJdXxp/gCSVHaafcNxw26M8xq8Tf0mm5xzBFpNT76HQv0gn8qMdaEwimv77 kzASMCFwfB6H3iWghSX7/f/aowuwvPrxeBJ8jx+iayOgFnZ1RgIqSzEuR4aXyPo3MoMr 3nebhryqUTLEVN0A0Rg4I5X+z+lF/rkk3AY4HWwC+l50Zp2Dd8mEU3HJ7/6hkl6hnKgx OVBREf6xibCVA1ZVeDu3a8FrcaZAUeoWEAHikw1HHFx8CvPqm2EXpmgbiV6ULCI+7C+w pReMnR3IE1w+BONHFC0p8qaTCttJlZOdFdWdlVHG29BhI5nxFQ34KnCHQV2SblKtGILx RZZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730283358; x=1730888158; 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=M7/BvtYlV1qgq+czxjn4mzy5E8FsDWiUJx1i67ihv0Y=; b=X3vRSW7vp6DriLR0ktJsNUk5EdAV7Xf+TWvSYWeVAuCYqYXGeDoaX/L088Gx3LIfK6 WPbqFFzZPkXU4XdyHpMdrTYToICCKs1jD35ZYF/tMee1t9DKi9ilWpBKUH6et1Otdzc9 8u2uwIWff1cAcVnNh3VtOTfqyyWygVHRciz5LUxIzBbkcU7Gm+a7GfzLUgMvwA6GRigi OjDy6WV/vWVEM6WcBtBoXzkw/mEH1Axzx2vfrI4+oxAAI5NHuG1G2V7Xks0HDKDWtNG9 d/9phBPOf8yi7k5Umqe+IcFOcJANZyut25APZo/lE2BhHUt44xgQsumBuCWySjsvSoI6 3iBw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWrvqw3asEkGMisJhF+37k/XYpZLG7yrLVQn2YeWiQe6qwGHQYREYOotn86/EdrCi44DhWO1+lNaw==@patchwork.ozlabs.org X-Gm-Message-State: AOJu0YyMmH88I+NwCCH5cMQTMw/ujlpSDVzFOkjZBFgDWBlQK/C9rIFw tIvb51QH061CccwxgSoT3DBK+A08dKJDyYzimudMuTu/crZ+HjqA X-Google-Smtp-Source: AGHT+IFx0DuUUi36T90CWbwruaIaVYyhhWLtdUAg/OobExqq7dJFUgPwSIKv333IIkDjXBiblPcgBA== X-Received: by 2002:a2e:a7c1:0:b0:2fb:8df3:2291 with SMTP id 38308e7fff4ca-2fcbdfa73f4mr69703831fa.16.1730283357866; Wed, 30 Oct 2024 03:15:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1d11:b0:42c:cb89:ceb with SMTP id 5b1f17b1804b1-4318a288c71ls35017595e9.2.-pod-prod-04-eu; Wed, 30 Oct 2024 03:15:54 -0700 (PDT) X-Received: by 2002:a05:600c:19d3:b0:431:58c4:2eb9 with SMTP id 5b1f17b1804b1-4319ac78f0cmr133193665e9.3.1730283354442; Wed, 30 Oct 2024 03:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730283354; cv=none; d=google.com; s=arc-20240605; b=XA1TFwMx0DIzUy1S4ddqH8WJrgpOgAg4xlSqcHywGTUhHCg29YTPYlPJ5yFNL7jWRg cE+I88bEOkL6h8X0sb8WKa/icE7zIKOltiTYArwyjnKbAXiAblLPRnjHc77/H2kvQSAl OhyX6kZFhSswllHR85ooDwXSM7SOVXcydMOl4IHf6nu6yW2RV3Nlng2TinK1VKo3CiB/ TKQBMCNX+PcXEq1aYLvrMJLE0yEJLaRW0mThJjRV2HzOsRIwNLizCh/4UHl9Btg2xhbJ 2ulQXZy6ubHoPthrcfZ0TTJpbyN6J8iffPvgoNpVzQM7w5cqdr8AlRmWO5Vf0j6uswLU MaUw== 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=YYE8AF2ngYggAx283HMKU8lnemXBa3TFMN6YrlZjHxsx6EJt8l4OF9eYBJqlvq22QK Bd3neh7pbkonoE4rm6PwbIqh2SDB+oLT9O6+lrU+HHHxZafxz8eei+6uNXl/tiiGtJ4C XBueG7CvurG+OcxRbJjBsYlAf8GKaHLVvak8QNI3I/CYuuVCABnz/wJXzh6JYfDeELRl gZxzbvNIJwPGHbzWjAoLhKxGm/8vZzYQSkPOE5bcTi9nRl+Ix0uhtA13PwAfKx5XjM+K DYZiPDVseK0Yz0pA1aaF2P2eXZunwG+lURrwvlDp8gSQR4K48UB48F6x7Abu/YcqVWuw p4oA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=OI0eyIHb; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-431b43a99dbsi2461285e9.0.2024.10.30.03.15.54 for <swupdate@googlegroups.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 03:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MwxNF-1u3RS63QdP-00rDPG; Wed, 30 Oct 2024 11:15:53 +0100 From: Stefano Babic <stefano.babic@swupdate.org> To: swupdate@googlegroups.com Cc: Stefano Babic <stefano.babic@swupdate.org> Subject: [swupdate] [PATCH 05/10] Add helper to concatenate string Date: Wed, 30 Oct 2024 11:15:45 +0100 Message-Id: <20241030101550.21014-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241030101550.21014-1-stefano.babic@swupdate.org> References: <20241030101550.21014-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:OYUs7zdbS3r7kM4bGPvSJ7Delg+Djix66xNnKO+F6t/4NKJupuf ZzmnSdFsyvQNcclU1srshMm5PpYxYvMU262iG7ymRA+HlIX6muBLGmFRtPqeBdBH/gf4ag2 Uc7FtvCJs714yGhimNkRprZeu03z7+1sqr/t8u36XbD2rDh7o4LO/Pb6X7RVZjfSxaSpHe8 kbdsG22DzYafuMvFAsQfg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:DSPPmtErpvM=;UjyOHRybQDD7q3ivRZ6C+xeJtL1 KzC+FZJV/PgPUElJ8STEDvYb4WmlKztA87oaQi1ZRpsneUoZFoPiNd+9VNVbDv6+Qrdizb/1U qnMwk3F+Eo+25IF89+7H2HtnwcuaebcGqOLsVwQJbbqaTcTBGD1CVWylg5DQ7sLWcXU+pu7cR 5v/2dvi9WP09sKAcyzmqjBj1FEyhdRUviy9vOHmnQKS4ysZ24PYsEcIAkGZp2q61v++iTqh41 Z6ZM8isqZM5WBMGpUWE0Om8MsUX/9lurxdNTmY6MReFS/cZ6PBZHvHMr7KOcifxG6PqTSDRxr hr3I7YTk3awlDu9kLgKPNA23XBa/21cMZJ51C3sT+AaGVqKXgfiMLgF3vu/gCk2XIpg/Bnkfh Jr34bncslWn4JTlG+o+MxqTmsThAEXVX7TFkx05MXPjygoUJ2/SWaLobdhq7nqSMIn3WWw6L0 EyCK/DZaJ6j4WV1X/sjFovVB5zcW7r03RZt4NGVFrF8sIIornJ8m4rz1sG2PGsFGMFPrC7fIy Gugg4NYAKkRDmnFg/BsglQgbDRjifUQ3NQEn0L4Ey8iHCfMDqaTVuNBKF3naf9bDmmNz2XRJw aau8d4hzms3ZNq1/WnwvQ5KgMT5hiDZBPUsqbxlyht8jlOtzJdtHu+iFdRj/Cq9IKmgwBDbI9 ubmUtmaU/MXFHOp+Ug7wdIJLV5WV2qPV+t67Pw8iw/pjNsEhjKWszhZ0xrLg+MsDv7nh5mfg7 B/Ez8xAwj4LQY+kuuEadvaNS91GQ89iVg== 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=OI0eyIHb; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 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