[PATCH 3/4] lib/, include/: avoid const-laundering warnings

From: Rasmus Villemoes
Date: Wed Aug 22 2018 - 07:00:22 EST


Even though str*() launders the const away for us, we should and do not
modify the buffer through the returned pointer, so might as well declare
it const.

Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
include/linux/cpumask.h | 2 +-
lib/bitmap.c | 2 +-
lib/parser.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 147bdec42215..82f4e39b4dc6 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -633,7 +633,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
*/
static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
{
- char *nl = strchr(buf, '\n');
+ const char *nl = strchr(buf, '\n');
unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);

return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 730969c681cb..de47d7ebbb5f 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -620,7 +620,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,

int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits)
{
- char *nl = strchrnul(bp, '\n');
+ const char *nl = strchrnul(bp, '\n');
int len = nl - bp;

return __bitmap_parselist(bp, len, 0, maskp, nmaskbits);
diff --git a/lib/parser.c b/lib/parser.c
index 3278958b472a..ffb09e9cc8f4 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -25,7 +25,7 @@
*/
static int match_one(char *s, const char *p, substring_t args[])
{
- char *meta;
+ const char *meta;
int argc = 0;

if (!p)
--
2.16.4