public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Rudi Heitbaum <rudi@heitbaum.com>
To: linux-nfs@vger.kernel.org
Cc: rudi@heitbaum.com
Subject: [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target
Date: Sun, 15 Feb 2026 07:06:18 +0000	[thread overview]
Message-ID: <aZFwasmAQKAa7nCc@1eac07209f0d> (raw)

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


             reply	other threads:[~2026-02-15  7:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-15  7:06 Rudi Heitbaum [this message]
2026-02-24 12:53 ` [PATCH 2/2] nfs-utils: conffile: fix discards const from pointer target Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aZFwasmAQKAa7nCc@1eac07209f0d \
    --to=rudi@heitbaum.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox