silence some warning in rpcgen
Subsystems (2)
cover 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(-)
Signature · 1 line
2.20.1
PATCH 1/7 rpcgen: rpc_cout: silence unused def parameter
In emit_enum() argument def is not used and can cause a warning. So let's mark it with __attribute__((unused)).
--- tools/rpcgen/rpc_cout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/rpcgen/rpc_cout.c +2 -2
@@ -53,7 +53,7 @@ static void print_ifsizeof(char *prefix, char *type);static void print_ifclose (int indent);static void print_ifstat (int indent,char *prefix,char *type,relation rel,char *amax,char *objname,char *name); -static void emit_enum (definition *def); +static void emit_enum (__attribute__((unused))definition *def);static void emit_program (definition *def);static void emit_union (definition *def);static void emit_struct (definition *def);
@@ -286,7 +286,7 @@ print_ifstat(int indent, char *prefix, char *type, relation rel, }static void -emit_enum (definition *def) +emit_enum (__attribute__((unused))definition *def) {print_ifopen (1 ,"enum" );print_ifarg ("(enum_t *)objp" );
Signature · 1 line
2.20.1
PATCH 2/7 rpcgen: rpc_util: add storeval args to prototype
In reply to Giulio Benettistoreval() prototype has no arguments and this can cause warnings during building. Let's add its arguments to prototype according to its implementation.
--- tools/rpcgen/rpc_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcgen/rpc_util.h +1 -1
@@ -91,7 +91,7 @@ extern int nonfatalerrors;/* * rpc_util routines */ -void storeval (); +void storeval (list **,definition *);#define STOREVAL (list,item) \ storeval(list,item)
Signature · 1 line
2.20.1
PATCH 3/7 rpcgen: rpc_util: add findval args to prototype
In reply to Giulio Benettifindval() prototype has no arguments and this can cause warnings during building. Let's add its arguments to prototype according to its implementation.
--- tools/rpcgen/rpc_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcgen/rpc_util.h +1 -1
@@ -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)
Signature · 1 line
2.20.1
PATCH 4/7 rpcgen: rpc_parse: add get_definition() void argument
In reply to Giulio Benettiget_definition() prototype has no arguments and this can cause warnings during building. Let's add void argument to prototype according to its implementation.
--- tools/rpcgen/rpc_parse.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcgen/rpc_parse.h +1 -1
@@ -153,7 +153,7 @@ struct definition { };typedef struct definition definition ; -definition *get_definition (); +definition *get_definition (void );struct bas_type
Signature · 1 line
2.20.1
PATCH 5/7 rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
In reply to Giulio Benettiformat 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.
--- tools/rpcgen/rpc_cout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/rpcgen/rpc_cout.c +2 -2
@@ -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);
Signature · 1 line
2.20.1
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
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
Quoted 26 lines · Giulio Benetti
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(-)tools/rpcgen/rpc_cout.c +2
-2@@ -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);
Re: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
Quoted 3 lines · Giulio Benetti
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().
what am I missing?
steved.
Re: [nfs-utils PATCH 5/7] rpcgen: rpc_cout: fix potential -Wformat-nonliteral warning
Quoted 19 lines · Steve Dickson
Quoted 3 lines · Giulio Benetti
Hi Steve,
you've missed this patch while applying the series. Can you please commit it?
It is in...
commit
6f4568f1f7395f967cc03995dcfb79a1ac5c11cdAuthor: Giulio Benetti <[email protected]> Date: Mon Jan 6 14:23:04 2020 -0500rpcgen:
rpc_hout: fix potential -Wformat-security warningf_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().
Quoted 4 lines
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
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
PATCH 6/7 rpcgen: rpc_hout: fix potential -Wformat-security warning
In reply to Giulio Benettif_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().
--- tools/rpcgen/rpc_hout.c | 2 ++ 1 file changed, 2 insertions(+)
tools/rpcgen/rpc_hout.c +2 -0
@@ -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
Signature · 1 line
2.20.1
PATCH 7/7 rpcgen: rpc_hout: fix indentation on f_print() argument separator
In reply to Giulio BenettiRemove useless space before closing parenthesys.
--- tools/rpcgen/rpc_hout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcgen/rpc_hout.c +1 -1
@@ -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" }
Signature · 1 line
2.20.1
Quoted 15 lines · Giulio Benetti
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: addget_definition()void argument
rpcgen:rpc_cout: fix potential -Wformat-nonliteral warning
rpcgen:rpc_hout: fix potential -Wformat-security warning
rpcgen:rpc_hout: fix indentation onf_print()argument separator
Quoted 6 lines
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.
Quoted 24 lines · Steve Dickson
Quoted 15 lines · Giulio Benetti
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: addget_definition()void argument
rpcgen:rpc_cout: fix potential -Wformat-nonliteral warning
rpcgen:rpc_hout: fix potential -Wformat-security warning
rpcgen:rpc_hout: fix indentation onf_print()argument separatorQuoted 6 lines
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(-)
Quoted 8 lines
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
Signature · 2 lines
Giulio Benetti Benetti Engineering sas
Quoted 2 lines
steved.
Quoted 27 lines · Giulio Benetti
Quoted 26 lines · Steve Dickson
Quoted 15 lines · Giulio Benetti
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: addget_definition()void argument
rpcgen:rpc_cout: fix potential -Wformat-nonliteral warning
rpcgen:rpc_hout: fix potential -Wformat-security warning
rpcgen:rpc_hout: fix indentation onf_print()argument separatorQuoted 6 lines
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)
Quoted 8 lines
Quoted 6 lines
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.
Quoted 2 lines
Best regards