public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target
@ 2026-02-15  7:06 Rudi Heitbaum
  2026-02-24 12:53 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Rudi Heitbaum @ 2026-02-15  7:06 UTC (permalink / raw)
  To: linux-nfs; +Cc: rudi

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, ':');
          |             ^

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
---
 support/nfs/conffile.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 137fac8d..8d242c2f 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -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 */
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target
  2026-02-15  7:06 [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target Rudi Heitbaum
@ 2026-02-24 12:53 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2026-02-24 12:53 UTC (permalink / raw)
  To: Rudi Heitbaum, linux-nfs



On 2/15/26 2:06 AM, Rudi Heitbaum wrote:
> 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, ':');
>            |             ^
> 
> Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
Committed... (tag: nfs-utils-2-8-6-rc2)

steved.
> ---
>   support/nfs/conffile.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
> index 137fac8d..8d242c2f 100644
> --- a/support/nfs/conffile.c
> +++ b/support/nfs/conffile.c
> @@ -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 */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-24 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-15  7:06 [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target Rudi Heitbaum
2026-02-24 12:53 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox