From nobody Sat Nov 23 22:15:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1730116139; cv=none; d=zohomail.com; s=zohoarc; b=bZhzIaq5TbGLz2jKxMWXKEUtSX38RNWDgn1blo/kq3pmoqQpLp/dVrPxl5goQn55XEC484LCLF1AbbKaLLabnGlczCy6SnEnuYVhcV6RWfoZVN6qbcRtHpVuTOPRoqEp9PxRoUmzY0vHuMNOK2HAfhSmCr3HBrxZ+q3enUgQukc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730116139; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AqhKPSM5xXuNkzAtrPGMWoAWoIrp+3rMwKupZfOosL4=; b=Le4MACut+94m5hab6hfP50kzEo2/du1qEztLrkm3QLSFlM75fStuiMr65dWT3Crcps09OZe2unIZ05AHg14QUFe/zNQ5Rnx0k52BwKfvYz6OexERTMajccM+10o0ygTQHFJEtYyLkkVookPiyI2d97APhnVOYDJ413orqAfq+zo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1730116138984904.1908999455337; Mon, 28 Oct 2024 04:48:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.826409.1240645 (Exim 4.92) (envelope-from ) id 1t5OEf-0002iO-8B; Mon, 28 Oct 2024 11:48:37 +0000 Received: by outflank-mailman (output) from mailman id 826409.1240645; Mon, 28 Oct 2024 11:48:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5OEf-0002iH-5X; Mon, 28 Oct 2024 11:48:37 +0000 Received: by outflank-mailman (input) for mailman id 826409; Mon, 28 Oct 2024 11:48:36 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t5OEe-0002iB-AO for xen-devel@lists.xenproject.org; Mon, 28 Oct 2024 11:48:36 +0000 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [2a00:1450:4864:20::331]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8f8530cc-9522-11ef-99a3-01e77a169b0f; Mon, 28 Oct 2024 12:48:34 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4314c4cb752so42495085e9.2 for ; Mon, 28 Oct 2024 04:48:34 -0700 (PDT) Received: from localhost ([213.195.115.182]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193595470sm105903895e9.15.2024.10.28.04.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 04:48:33 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8f8530cc-9522-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730116113; x=1730720913; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AqhKPSM5xXuNkzAtrPGMWoAWoIrp+3rMwKupZfOosL4=; b=WQ2bGXTvRON86uizdnfE+gfvnmhwlCGsnBEg21F78JUMJnoNwpJg9piptteA07ZUcF 3Ry2lASR+afjV80xFd4UltNm+pC5AeA/k35H0Ics4UD4wvsSf4gpbyQxg2D1AgN/1tHX vuO6nK1ygQfnwUEd9yK2sYtrTwjAjPVEOauTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730116113; x=1730720913; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AqhKPSM5xXuNkzAtrPGMWoAWoIrp+3rMwKupZfOosL4=; b=T7MeJsSfH9fzBcBU549/BTburMbnE9P4z3jSwUmL9envY5/xb/syLwlsZaHrejnX0R flpGnCfjGAn8NHUkaHCLFVNStBoyFbj7E3X4tSdhQmh6mFC2Y6IICmcEuQmLzRyPRHl9 gBgm4NZPQh63iEHv2F5AVUnUQt0AwU+iiR8PVuL2DVl9vXrSvmkaGWd9gb5v87PjU01x l4iaBtfvlONNSpFDxv1Q9+u/4VMpq16xOey6ftpwajqb+Sj3jDvZpk12o7AC4zT9NhoL PcJNQxnkSK3TifIfOafC5uL9Lt9DvF8Ja3IHkRGGO+OESLzJaBNcZ9TO9Vajdot+YKA0 uPWg== X-Gm-Message-State: AOJu0YyCdoXwy6n0cVC0eavUVqu14vUl0mLb9L9vRTqp/IMy1E76vNZB eJoTC6SMBtpvfLGPOkBRceFcFTyYjT2IPIgGMyDyHQ1yLZswqTA1e6pPJgP8soU8wbmuSA7IyXz T X-Google-Smtp-Source: AGHT+IGjjq6kuwJwR17w7R3+QqZiR7ijGZIKUJiMjb+pTIi7caBpfjQK/pMvijDmePU5y/fuN7ve6w== X-Received: by 2002:a05:600c:3ca3:b0:42c:b74c:d8c3 with SMTP id 5b1f17b1804b1-4319ad3032dmr68672515e9.32.1730116113450; Mon, 28 Oct 2024 04:48:33 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Anthony PERARD , Juergen Gross Subject: [PATCH] tools/libxl: remove usage of VLA arrays Date: Mon, 28 Oct 2024 12:48:31 +0100 Message-ID: <20241028114831.27487-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1730116141119116600 Clang 19 complains with the following error when building libxl: libxl_utils.c:48:15: error: variable length array folded to constant array = as an extension [-Werror,-Wgnu-folding-constant] 48 | char path[strlen("/local/domain") + 12]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Replace the usage of strlen() with ARRAY_SIZE(), which allows the literal string length to be known at build time. Note ARRAY_SIZE() accounts for the NUL terminator while strlen() didn't, hence subtract 1 from the total size calculation. Signed-off-by: Roger Pau Monn=C3=A9 Acked-by: Andrew Cooper Acked-by: Anthony PERARD Reviewed-by: Frediano Ziglio --- tools/libs/light/libxl_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c index 10398a6c8611..b3f5e751cc3f 100644 --- a/tools/libs/light/libxl_utils.c +++ b/tools/libs/light/libxl_utils.c @@ -45,7 +45,7 @@ unsigned long libxl_get_required_shadow_memory(unsigned l= ong maxmem_kb, unsigned char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid) { unsigned int len; - char path[strlen("/local/domain") + 12]; + char path[ARRAY_SIZE("/local/domain") + 11]; char *s; =20 snprintf(path, sizeof(path), "/local/domain/%d/name", domid); @@ -141,7 +141,7 @@ int libxl_cpupool_qualifier_to_cpupoolid(libxl_ctx *ctx= , const char *p, char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid) { unsigned int len; - char path[strlen("/local/pool") + 12]; + char path[ARRAY_SIZE("/local/pool") + 11]; char *s; =20 snprintf(path, sizeof(path), "/local/pool/%d/name", poolid); --=20 2.46.0