Skip to contentSkip to conversation

Fix typecast warning with clang

PATCH In review Khem Raj 2 participants 2 messages Dec 19, 2024 – Jan 3, 2025

Subsystems (2)
lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 Fix typecast warning with clang

Fixes
file.c:200:8: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]

Cc Benjamin Coddington <[email protected]>
Cc Steve Dickson <[email protected]>

---
v2: Make base as const char pointer insread of trying type punning

 support/nsm/file.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
support/nsm/file.c +2 -1
index de122b0f..68f99bf0 100644
@@ -184,7 +184,8 @@ static char *
 nsm_make_temp_pathname(const char *pathname)
 {
 	size_t size;
-	char *path, *base;
+	char *path;
+	const char *base;
 	int len;
 
 	size = strlen(pathname) + sizeof(".new") + 1;
#1 lore raw
Quoted 6 lines · Khem Raj

Fixes
file.c:200:8: error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]

Cc Benjamin Coddington <[email protected]>
Cc Steve Dickson <[email protected]>

Committed... (tag: nfs-utils-2-8-3-rc1)

steved.

Quoted 21 lines

---
v2: Make base as const char pointer insread of trying type punning

  support/nsm/file.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
support/nsm/file.c +2 -1
index de122b0f..68f99bf0 100644
@@ -184,7 +184,8 @@ static char *
  nsm_make_temp_pathname(const char *pathname)
  {
  	size_t size;
-	char *path, *base;
+	char *path;
+	const char *base;
  	int len;
 
  	size = strlen(pathname) + sizeof(".new") + 1;