From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19C7D80C for ; Tue, 27 Sep 2022 13:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3E6BC433D7; Tue, 27 Sep 2022 13:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284559; bh=n6vTZCyTn3fjGmfDlGpFKj4XD812C86b9jJJrat0UaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fww58ksY0/HNpSio73JGVSzwP3DMpjMUuGJzg+3i+ovIXqc/sHUYV55FfZoLtTImI eLh91fDkn6amEs5or4Edq2yrmBxoOLeVBspE0qYXnH0MQop0ahsAA2+FeHYXZwcu92 ft8PN9wbJLkA6aL7gaxXkDeE/YM1Jkx8/zn3j2kAM4ksmFdu07XFl/wO8ch9n0rKUZ VXbWwuxtfWacOMNan3IZiOqpzFkZD+C4DjUq0d65qvA/eT/H6AhB/PUwfqq9B8/Ks4 qP86MnyGbLfZy8xhDpYo/S45ZoFonyArLmsESISwrqbBfqUh1VEet3a0fRLSZgtTIP qf1PKrGMfpvAg== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Boqun Feng Subject: [PATCH v10 03/27] kallsyms: add static relationship between `KSYM_NAME_LEN{,_BUFFER}` Date: Tue, 27 Sep 2022 15:14:34 +0200 Message-Id: <20220927131518.30000-4-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This adds a static assert to ensure `KSYM_NAME_LEN_BUFFER` gets updated when `KSYM_NAME_LEN` changes. The relationship used is one that keeps the new size (512+1) close to the original buffer size (500). Co-developed-by: Boqun Feng Signed-off-by: Boqun Feng Signed-off-by: Miguel Ojeda --- scripts/kallsyms.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 25e2fe5fbcd4..411ff5058b51 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -32,8 +32,18 @@ #define KSYM_NAME_LEN 128 -/* A substantially bigger size than the current maximum. */ -#define KSYM_NAME_LEN_BUFFER 499 +/* + * A substantially bigger size than the current maximum. + * + * It cannot be defined as an expression because it gets stringified + * for the fscanf() format string. Therefore, a _Static_assert() is + * used instead to maintain the relationship with KSYM_NAME_LEN. + */ +#define KSYM_NAME_LEN_BUFFER 512 +_Static_assert( + KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, + "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" +); struct sym_entry { unsigned long long addr; -- 2.37.3