nfs-utils: conffile: fix discards const from pointer target
Subsystems (2)
PATCH 2/2 nfs-utils: conffile: fix discards const from pointer target
end is used as the return from strchr(line) which is a const char and then again as the return from strchr(name) which is a char pointer to the strdup(line). Declare a const char * pounter for use in the first case, addressing the warning.
fixes:
conffile.c: In function 'is_tag':
conffile.c:1711:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1711 | end = strchr(line, '=');
| ^
conffile.c: In function 'is_taggedcomment':
conffile.c:1825:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1825 | end = strchr(line, ':');
| ^
--- support/nfs/conffile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
support/nfs/conffile.c +6 -4
@@ -1704,12 +1704,13 @@ static bool is_tag(const char *line, const char *tagname) { char *end; +const char *equal;char *name;bool found = false;/* quick check, is this even an assignment line */ - end =strchr (line,'=' ); -if (end ==NULL ) + equal =strchr (line,'=' ); +if (equal ==NULL )return false;/* skip leading white space before tag name */
@@ -1807,6 +1808,7 @@ static bool is_taggedcomment(const char *line, const char *field) { char *end; +const char *equal;char *name;bool found = false;
@@ -1822,8 +1824,8 @@ is_taggedcomment(const char *line, const char *field) line++;/* quick check, is this even a likely formatted line */ - end =strchr (line,':' ); -if (end ==NULL ) + equal =strchr (line,':' ); +if (equal ==NULL )return false;/* skip leading white space before field name */
Signature · 1 line
2.51.0
Quoted 15 lines · Rudi Heitbaum
end is used as the return from strchr(line) which is a const char and then again as the return from strchr(name) which is a char pointer to the strdup(line). Declare a const char * pounter for use in the first case, addressing the warning.
fixes:
conffile.c: In function 'is_tag':
conffile.c:1711:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1711 | end =strchr(line, '=');
| ^
conffile.c: In function 'is_taggedcomment':
conffile.c:1825:13: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1825 | end =strchr(line, ':');
| ^
Quoted 1 line
Signed-off-by Rudi Heitbaum <[email protected]>
Committed... (tag: nfs-utils-2-8-6-rc2)
steved.
Quoted 43 lines
--- support/nfs/conffile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)support/nfs/conffile.c +6
-4@@ -1704,12 +1704,13 @@ static bool is_tag(const char *line, const char *tagname) { char *end; +const char *equal;char *name;bool found = false;/* quick check, is this even an assignment line */ - end =strchr (line,'=' ); -if (end ==NULL ) + equal =strchr (line,'=' ); +if (equal ==NULL )return false;/* skip leading white space before tag name */ @@ -1807,6 +1808,7 @@ static bool is_taggedcomment(const char *line, const char *field) { char *end; +const char *equal;char *name;bool found = false;@@ -1822,8 +1824,8 @@ is_taggedcomment(const char *line, const char *field) line++;/* quick check, is this even a likely formatted line */ - end =strchr (line,':' ); -if (end ==NULL ) + equal =strchr (line,':' ); +if (equal ==NULL )return false;/* skip leading white space before field name */