Skip to contentSkip to conversation

f2fs-tools: fix discarded const qualifiers

PATCH In review Juhyung Park 2 participants 4 messages Oct 5 – Oct 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 f2fs-tools: fix discarded const qualifiers

compress.c: In function ‘get_ext’:
compress.c:136:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

  136 |         char *p = strrchr(path, '.');
      |                   ^~~~~~~

f2fscrypt.c: In function ‘hex2byte’:
f2fscrypt.c:210:19: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
210 | h = memchr(hexchars, hex[x], hexchars_size);
| ^
f2fscrypt.c:213:19: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
213 | l = memchr(hexchars, hex[x + 1], hexchars_size);
| ^
f2fscrypt.c: In function ‘parse_salt’:
f2fscrypt.c:371:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
371 | h = memchr(hexchars, *cp++, hexchars_size);
| ^
f2fscrypt.c:372:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
372 | l = memchr(hexchars, *cp++, hexchars_size);
| ^

---
 fsck/compress.c   | 2 +-
 tools/f2fscrypt.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fsck/compress.c +1 -1
index b15f0a41c46e..5314b6b52034 100644
@@ -133,7 +133,7 @@ static bool ext_found(const char *ext)
 
 static const char *get_ext(const char *path)
 {
-	char *p = strrchr(path, '.');
+	const char *p = strrchr(path, '.');
 
 	return p == NULL ? path + strlen(path) : p + 1;
 }
tools/f2fscrypt.c +2 -2
index d5222fb4121b..00c593d45b9e 100644
@@ -202,7 +202,7 @@ static int hex2byte(const char *hex, size_t hex_size, unsigned char *bytes,
 		    size_t bytes_size)
 {
 	size_t x;
-	unsigned char *h, *l;
+	const unsigned char *h, *l;
 
 	if (hex_size % 2)
 		return -EINVAL;
@@ -360,7 +360,7 @@ static void parse_salt(char *salt_str, int flags)
 		cp += 2;
 		goto salt_from_filename;
 	} else if (strncmp(cp, "0x", 2) == 0) {
-		unsigned char *h, *l;
+		const unsigned char *h, *l;
 
 		cp += 2;
 		if (strlen(cp) & 1)
Signature · 8 lines
2.55.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw

PATCH 2/2 f2fs-tools: remove LZ4_MEMORY_USAGE definition

liblz4 defines this from r118's commit back in 2014.

---
 fsck/compress.c | 1 -
 1 file changed, 1 deletion(-)
fsck/compress.c +0 -1
index 5314b6b52034..6fe3cfe6177a 100644
@@ -30,7 +30,6 @@
 #define LZO_WORK_SIZE			ALIGN_UP(LZO1X_1_15_MEM_COMPRESS, 8)
 #endif
 #ifdef HAVE_LIBLZ4
-#define LZ4_MEMORY_USAGE		14
 #define LZ4_MAX_INPUT_SIZE		0x7E000000 /* 2 113 929 216 bytes */
 #define LZ4_MEM_COMPRESS		sizeof(LZ4_stream_t)
 #define LZ4_ACCELERATION_DEFAULT	1
Signature · 8 lines
2.55.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by Chao Yu on v1 1/2
#3 lore raw
In reply to Juhyung Park
Quoted 19 lines · Juhyung Park

compress.c: In function ‘get_ext’:
compress.c:136:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]

   136 |         char *p = strrchr(path, '.');
       |                   ^~~~~~~

f2fscrypt.c: In function ‘hex2byte’:
f2fscrypt.c:210:19: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
210 | h = memchr(hexchars, hex[x], hexchars_size);
| ^
f2fscrypt.c:213:19: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
213 | l = memchr(hexchars, hex[x + 1], hexchars_size);
| ^
f2fscrypt.c: In function ‘parse_salt’:
f2fscrypt.c:371:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
371 | h = memchr(hexchars, *cp++, hexchars_size);
| ^
f2fscrypt.c:372:27: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
372 | l = memchr(hexchars, *cp++, hexchars_size);
| ^

Quoted 1 line

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel