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

dev is passed by nfs_parse_devname to nfs_parse_... as a copy of the
device name, the parser destructively modifies dev, so pass as non const
so that it can be modified without warning.

fixes:
    parse_dev.c: In function 'nfs_parse_simple_hostname':
    parse_dev.c:89:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       89 |         colon = strchr(dev, ':');
          |               ^
    parse_dev.c:100:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      100 |         comma = strchr(dev, ',');
          |               ^
    parse_dev.c: In function 'nfs_parse_square_bracket':
    parse_dev.c:146:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
      146 |         cbrace = strchr(dev, ']');
          |                ^

Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
---
 utils/mount/parse_dev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/utils/mount/parse_dev.c b/utils/mount/parse_dev.c
index 2ade5d5d..a6354bba 100644
--- a/utils/mount/parse_dev.c
+++ b/utils/mount/parse_dev.c
@@ -79,7 +79,7 @@ static int nfs_pdn_missing_brace_err(void)
 /*
  * Standard hostname:path format
  */
-static int nfs_parse_simple_hostname(const char *dev,
+static int nfs_parse_simple_hostname(char *dev,
 				     char **hostname, char **pathname)
 {
 	size_t host_len, path_len;
@@ -134,7 +134,7 @@ static int nfs_parse_simple_hostname(const char *dev,
  * There could be anything in between the brackets, but we'll
  * let DNS resolution sort it out later.
  */
-static int nfs_parse_square_bracket(const char *dev,
+static int nfs_parse_square_bracket(char *dev,
 				    char **hostname, char **pathname)
 {
 	size_t host_len, path_len;
@@ -185,7 +185,7 @@ static int nfs_parse_square_bracket(const char *dev,
  * with the mount request and failing with a cryptic error message
  * later.
  */
-static int nfs_parse_nfs_url(__attribute__((unused)) const char *dev,
+static int nfs_parse_nfs_url(__attribute__((unused)) char *dev,
 			     __attribute__((unused)) char **hostname,
 			     __attribute__((unused)) char **pathname)
 {
-- 
2.51.0


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

end of thread, other threads:[~2026-02-24 12:52 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:05 [PATCH 1/2] nfs-utils: mount.nfs: fix discards const from pointer target Rudi Heitbaum
2026-02-24 12:52 ` Steve Dickson

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