2020-01-03 21:58:13

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 0/7] silence some warning in rpcgen

Since I'm trying to bump version of nfs-utils to latest in Buildroot, I've
noticed some warning in rpcgen, so I've decided to clean them up by fixing
code or #pragma ignoring them. Hope this is useful. Other warnings are
still there waiting to be fixed and if you find these patches useful I'm
going to complete all warning correction.

Giulio Benetti (7):
rpcgen: rpc_cout: silence unused def parameter
rpcgen: rpc_util: add storeval args to prototype
rpcgen: rpc_util: add findval args to prototype
rpcgen: rpc_parse: add get_definition() void argument
rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
rpcgen: rpc_hout: fix potential -Wformat-security warning
rpcgen: rpc_hout: fix indentation on f_print() argument separator

tools/rpcgen/rpc_cout.c | 8 ++++----
tools/rpcgen/rpc_hout.c | 4 +++-
tools/rpcgen/rpc_parse.h | 2 +-
tools/rpcgen/rpc_util.h | 4 ++--
4 files changed, 10 insertions(+), 8 deletions(-)

--
2.20.1


2020-01-03 21:58:13

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 3/7] rpcgen: rpc_util: add findval args to prototype

findval() prototype has no arguments and this can cause warnings during
building. Let's add its arguments to prototype according to its
implementation.

Signed-off-by: Giulio Benetti <[email protected]>
---
tools/rpcgen/rpc_util.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/rpcgen/rpc_util.h b/tools/rpcgen/rpc_util.h
index bd7b15ca..97b87f2b 100644
--- a/tools/rpcgen/rpc_util.h
+++ b/tools/rpcgen/rpc_util.h
@@ -96,7 +96,7 @@ void storeval(list **, definition *);
#define STOREVAL(list,item) \
storeval(list,item)

-definition *findval();
+definition *findval(list *, char *, int (*)(definition *, char *));

#define FINDVAL(list,item,finder) \
findval(list, item, finder)
--
2.20.1

2020-01-03 21:58:13

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 4/7] rpcgen: rpc_parse: add get_definition() void argument

get_definition() prototype has no arguments and this can cause warnings
during building. Let's add void argument to prototype according to its
implementation.

Signed-off-by: Giulio Benetti <[email protected]>
---
tools/rpcgen/rpc_parse.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/rpcgen/rpc_parse.h b/tools/rpcgen/rpc_parse.h
index 2afae104..6c134dd8 100644
--- a/tools/rpcgen/rpc_parse.h
+++ b/tools/rpcgen/rpc_parse.h
@@ -153,7 +153,7 @@ struct definition {
};
typedef struct definition definition;

-definition *get_definition();
+definition *get_definition(void);


struct bas_type
--
2.20.1

2020-01-03 21:58:28

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 6/7] rpcgen: rpc_hout: fix potential -Wformat-security warning

f_print()'s argument "separator" is not known because it's passed as an
argument and with -Wformat-security will cause a useless warning. Let's
ignore by adding "#pragma GCC diagnostic ignored/warning" before and
after f_print().

Signed-off-by: Giulio Benetti <[email protected]>
---
tools/rpcgen/rpc_hout.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/rpcgen/rpc_hout.c b/tools/rpcgen/rpc_hout.c
index ea1cb24f..999c061f 100644
--- a/tools/rpcgen/rpc_hout.c
+++ b/tools/rpcgen/rpc_hout.c
@@ -467,7 +467,9 @@ pdeclaration(char *name, declaration *dec, int tab, char *separator)
break;
}
}
+#pragma GCC diagnostic ignored "-Wformat-security"
f_print(fout, separator );
+#pragma GCC diagnostic warning "-Wformat-security"
}

static int
--
2.20.1

2020-01-03 21:58:30

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning

format and vecformat must be declared as "char * const" to be really
treated as constant when building with -Werror=format-nonliteral,
otherwise compiler will consider them subject to change throughout the
function.

Signed-off-by: Giulio Benetti <[email protected]>
---
tools/rpcgen/rpc_cout.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/rpcgen/rpc_cout.c b/tools/rpcgen/rpc_cout.c
index f806a86a..df2609c4 100644
--- a/tools/rpcgen/rpc_cout.c
+++ b/tools/rpcgen/rpc_cout.c
@@ -319,8 +319,8 @@ emit_union(definition *def)
case_list *cl;
declaration *cs;
char *object;
- char *vecformat = "objp->%s_u.%s";
- char *format = "&objp->%s_u.%s";
+ char * const vecformat = "objp->%s_u.%s";
+ char * const format = "&objp->%s_u.%s";

print_stat(1,&def->def.un.enum_decl);
f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
--
2.20.1

2020-01-03 21:58:47

by Giulio Benetti

[permalink] [raw]
Subject: [nfs-utils PATCH 7/7] rpcgen: rpc_hout: fix indentation on f_print() argument separator

Remove useless space before closing parenthesys.

Signed-off-by: Giulio Benetti <[email protected]>
---
tools/rpcgen/rpc_hout.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/rpcgen/rpc_hout.c b/tools/rpcgen/rpc_hout.c
index 999c061f..ed668778 100644
--- a/tools/rpcgen/rpc_hout.c
+++ b/tools/rpcgen/rpc_hout.c
@@ -468,7 +468,7 @@ pdeclaration(char *name, declaration *dec, int tab, char *separator)
}
}
#pragma GCC diagnostic ignored "-Wformat-security"
- f_print(fout, separator );
+ f_print(fout, separator);
#pragma GCC diagnostic warning "-Wformat-security"
}

--
2.20.1

2020-01-07 19:07:29

by Steve Dickson

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 0/7] silence some warning in rpcgen



On 1/3/20 4:50 PM, Giulio Benetti wrote:
> Since I'm trying to bump version of nfs-utils to latest in Buildroot, I've
> noticed some warning in rpcgen, so I've decided to clean them up by fixing
> code or #pragma ignoring them. Hope this is useful. Other warnings are
> still there waiting to be fixed and if you find these patches useful I'm
> going to complete all warning correction.
>
> Giulio Benetti (7):
> rpcgen: rpc_cout: silence unused def parameter
> rpcgen: rpc_util: add storeval args to prototype
> rpcgen: rpc_util: add findval args to prototype
> rpcgen: rpc_parse: add get_definition() void argument
> rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
> rpcgen: rpc_hout: fix potential -Wformat-security warning
> rpcgen: rpc_hout: fix indentation on f_print() argument separator
>
> tools/rpcgen/rpc_cout.c | 8 ++++----
> tools/rpcgen/rpc_hout.c | 4 +++-
> tools/rpcgen/rpc_parse.h | 2 +-
> tools/rpcgen/rpc_util.h | 4 ++--
> 4 files changed, 10 insertions(+), 8 deletions(-)
>
Committed (tag: nfs-utils-2-4-3-rc5)

I must admit this code is actually being used... I assume they do the right thing...

The rpcgen we been using is the old one that came out
of the glibc code at https://github.com/thkukuk/rpcsvc-proto

I wonder what the difference is....

steved.

2020-01-09 16:04:26

by Giulio Benetti

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 0/7] silence some warning in rpcgen

On 1/7/20 8:06 PM, Steve Dickson wrote:
>
>
> On 1/3/20 4:50 PM, Giulio Benetti wrote:
>> Since I'm trying to bump version of nfs-utils to latest in Buildroot, I've
>> noticed some warning in rpcgen, so I've decided to clean them up by fixing
>> code or #pragma ignoring them. Hope this is useful. Other warnings are
>> still there waiting to be fixed and if you find these patches useful I'm
>> going to complete all warning correction.
>>
>> Giulio Benetti (7):
>> rpcgen: rpc_cout: silence unused def parameter
>> rpcgen: rpc_util: add storeval args to prototype
>> rpcgen: rpc_util: add findval args to prototype
>> rpcgen: rpc_parse: add get_definition() void argument
>> rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
>> rpcgen: rpc_hout: fix potential -Wformat-security warning
>> rpcgen: rpc_hout: fix indentation on f_print() argument separator
>>
>> tools/rpcgen/rpc_cout.c | 8 ++++----
>> tools/rpcgen/rpc_hout.c | 4 +++-
>> tools/rpcgen/rpc_parse.h | 2 +-
>> tools/rpcgen/rpc_util.h | 4 ++--
>> 4 files changed, 10 insertions(+), 8 deletions(-)
>>
> Committed (tag: nfs-utils-2-4-3-rc5)
>
> I must admit this code is actually being used... I assume they do the right thing...
>
> The rpcgen we been using is the old one that came out
> of the glibc code at https://github.com/thkukuk/rpcsvc-proto
>
> I wonder what the difference is....

I can check it and use that one as upstream maybe and update it here in
nfs-utils if you see that it makes sense.

Best regards
--
Giulio Benetti
Benetti Engineering sas

> steved.
>

2020-01-09 18:45:01

by Steve Dickson

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 0/7] silence some warning in rpcgen



On 1/9/20 9:00 AM, Giulio Benetti wrote:
> On 1/7/20 8:06 PM, Steve Dickson wrote:
>>
>>
>> On 1/3/20 4:50 PM, Giulio Benetti wrote:
>>> Since I'm trying to bump version of nfs-utils to latest in Buildroot, I've
>>> noticed some warning in rpcgen, so I've decided to clean them up by fixing
>>> code or #pragma ignoring them. Hope this is useful. Other warnings are
>>> still there waiting to be fixed and if you find these patches useful I'm
>>> going to complete all warning correction.
>>>
>>> Giulio Benetti (7):
>>> ?? rpcgen: rpc_cout: silence unused def parameter
>>> ?? rpcgen: rpc_util: add storeval args to prototype
>>> ?? rpcgen: rpc_util: add findval args to prototype
>>> ?? rpcgen: rpc_parse: add get_definition() void argument
>>> ?? rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
>>> ?? rpcgen: rpc_hout: fix potential -Wformat-security warning
>>> ?? rpcgen: rpc_hout: fix indentation on f_print() argument separator
>>>
>>> ? tools/rpcgen/rpc_cout.c? | 8 ++++----
>>> ? tools/rpcgen/rpc_hout.c? | 4 +++-
>>> ? tools/rpcgen/rpc_parse.h | 2 +-
>>> ? tools/rpcgen/rpc_util.h? | 4 ++--
>>> ? 4 files changed, 10 insertions(+), 8 deletions(-)
>>>
>> Committed (tag: nfs-utils-2-4-3-rc5)
>>
>> I must admit this code is actually being used... I assume they do the right thing...
>>
>> The rpcgen we been using is the old one that came out
>> of the glibc code at https://github.com/thkukuk/rpcsvc-proto
>>
>> I wonder what the difference is....
>
> I can check it and use that one as upstream maybe and update it here in nfs-utils if you see that it makes sense.
That would be interest... If they both generate the same
code... two are probably not needed...

but I bet either code base as not changed in 40 yrs ;-)

steved.

>
> Best regards

2020-01-15 16:29:55

by Giulio Benetti

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning

Hi Steve,

you've missed this patch while applying the series. Can you please
commit it?

Thank you
Kind regards
--
Giulio Benetti
Benetti Engineering sas

On 1/3/20 10:50 PM, Giulio Benetti wrote:
> format and vecformat must be declared as "char * const" to be really
> treated as constant when building with -Werror=format-nonliteral,
> otherwise compiler will consider them subject to change throughout the
> function.
>
> Signed-off-by: Giulio Benetti <[email protected]>
> ---
> tools/rpcgen/rpc_cout.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/rpcgen/rpc_cout.c b/tools/rpcgen/rpc_cout.c
> index f806a86a..df2609c4 100644
> --- a/tools/rpcgen/rpc_cout.c
> +++ b/tools/rpcgen/rpc_cout.c
> @@ -319,8 +319,8 @@ emit_union(definition *def)
> case_list *cl;
> declaration *cs;
> char *object;
> - char *vecformat = "objp->%s_u.%s";
> - char *format = "&objp->%s_u.%s";
> + char * const vecformat = "objp->%s_u.%s";
> + char * const format = "&objp->%s_u.%s";
>
> print_stat(1,&def->def.un.enum_decl);
> f_print(fout, "\tswitch (objp->%s) {\n", def->def.un.enum_decl.name);
>

2020-01-16 23:23:27

by Steve Dickson

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning



On 1/15/20 11:29 AM, Giulio Benetti wrote:
> Hi Steve,
>
> you've missed this patch while applying the series. Can you please commit it?
It is in...

commit 6f4568f1f7395f967cc03995dcfb79a1ac5c11cd
Author: Giulio Benetti <[email protected]>
Date: Mon Jan 6 14:23:04 2020 -0500

rpcgen: rpc_hout: fix potential -Wformat-security warning

f_print()'s argument "separator" is not known because it's passed as an
argument and with -Wformat-security will cause a useless warning. Let's
ignore by adding "#pragma GCC diagnostic ignored/warning" before and
after f_print().

Signed-off-by: Giulio Benetti <[email protected]>
Signed-off-by: Steve Dickson <[email protected]>

what am I missing?

steved.

2020-01-16 23:23:50

by Giulio Benetti

[permalink] [raw]
Subject: Re: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning

On 1/16/20 9:07 PM, Steve Dickson wrote:
>
>
> On 1/15/20 11:29 AM, Giulio Benetti wrote:
>> Hi Steve,
>>
>> you've missed this patch while applying the series. Can you please commit it?
> It is in...
>
> commit 6f4568f1f7395f967cc03995dcfb79a1ac5c11cd
> Author: Giulio Benetti <[email protected]>
> Date: Mon Jan 6 14:23:04 2020 -0500
>
> rpcgen: rpc_hout: fix potential -Wformat-security warning
>
> f_print()'s argument "separator" is not known because it's passed as an
> argument and with -Wformat-security will cause a useless warning. Let's
> ignore by adding "#pragma GCC diagnostic ignored/warning" before and
> after f_print().
>
> Signed-off-by: Giulio Benetti <[email protected]>
> Signed-off-by: Steve Dickson <[email protected]>
>
> what am I missing?

Ah you've merged them together, now I see:
[5/7] https://patchwork.kernel.org/patch/11317493/
[6/7] https://patchwork.kernel.org/patch/11317489/

I didn't notice it while pull rebasing from upstream, because I have
another patch similar to that after bumping to latest version of rpcgen.

Sorry for the noise and thank you!
Best regards
--
Giulio Benetti
Benetti Engineering sas