~emersion/mrsh-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] parser: fix build with gcc 10's -Wformat-truncation

Arseny Maslennikov
Details
Message ID
<20210410145804.361763-1-arseny@altlinux.org>
DKIM signature
permerror
Download raw message
Patch: +1 -1
There is no reason for the array to not be static, and this qualifier
prevents type erasure so this file can be compiled with
-Werror=format-truncation.
---
 parser/program.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parser/program.c b/parser/program.c
index 921f7cf..6214751 100644
--- a/parser/program.c
+++ b/parser/program.c
@@ -875,7 +875,7 @@ static struct mrsh_function_definition *function_definition(
}

static bool unspecified_word(struct mrsh_parser *parser) {
	const char *const reserved[] = {
	static const char *const reserved[] = {
		"[[",
		"]]",
		"function",
-- 
2.29.3
Arseny Maslennikov
Details
Message ID
<YHM71oY742qgUg8g@cello>
In-Reply-To
<20210410145804.361763-1-arseny@altlinux.org> (view parent)
DKIM signature
permerror
Download raw message
On Sat, Apr 10, 2021 at 05:58:04PM +0300, Arseny Maslennikov wrote:
> There is no reason for the array to not be static, and this qualifier
> prevents type erasure so this file can be compiled with
> -Werror=format-truncation.
> ---

This fix is actually incomplete, at least on armv7 and i686 — since
we're linking this file into a shared library.
The complete fix has to get rid of pointers at all — we have to make
reserved[i] an array of arrays, or an array of subindexes in a single
static string.
See https://akkadia.org/drepper/dsohowto.pdf,
"2.4.3 Arrays of Data Pointers".

>  parser/program.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/parser/program.c b/parser/program.c
> index 921f7cf..6214751 100644
> --- a/parser/program.c
> +++ b/parser/program.c
> @@ -875,7 +875,7 @@ static struct mrsh_function_definition *function_definition(
>  }
>  
>  static bool unspecified_word(struct mrsh_parser *parser) {
> -	const char *const reserved[] = {
> +	static const char *const reserved[] = {
>  		"[[",
>  		"]]",
>  		"function",
> -- 
> 2.29.3
> 
Reply to thread Export thread (mbox)