From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Subject: [PATCH 3/4] lib/, include/: avoid const-laundering warnings
Date: Wed, 22 Aug 2018 13:00:08 +0200 [thread overview]
Message-ID: <20180822110009.17583-3-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20180822110009.17583-1-linux@rasmusvillemoes.dk>
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@rasmusvillemoes.dk>
---
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
next prev parent reply other threads:[~2018-08-22 11:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-22 11:00 [PATCH 1/4] string: try to find const-laundering bugs Rasmus Villemoes
2018-08-22 11:00 ` [PATCH 2/4] drivers/base/devtmpfs.c: don't pretend path is const in delete_path Rasmus Villemoes
2018-08-22 11:00 ` Rasmus Villemoes [this message]
2018-08-22 11:00 ` [PATCH 4/4] kernel/, init/: avoid const-laundering warnings Rasmus Villemoes
2018-08-22 11:07 ` [PATCH 1/4] string: try to find const-laundering bugs Joe Perches
2018-08-22 11:40 ` Rasmus Villemoes
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=20180822110009.17583-3-linux@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®