netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Kees Cook <keescook@chromium.org>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	sparclinux@vger.kernel.org, netdev@vger.kernel.org
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Andy Shevchenko <andy@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next v1 1/2] string: Make memscan() to take const
Date: Thu, 16 Feb 2023 13:42:33 +0200	[thread overview]
Message-ID: <20230216114234.36343-1-andriy.shevchenko@linux.intel.com> (raw)

Make memscan() to take const so it will be easier replace
some memchr() cases with it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/s390/include/asm/string.h          | 4 ++--
 arch/s390/lib/string.c                  | 2 +-
 arch/sparc/include/asm/asm-prototypes.h | 4 ++--
 arch/sparc/include/asm/string.h         | 7 ++++---
 arch/x86/include/asm/string_32.h        | 2 +-
 arch/x86/lib/string_32.c                | 2 +-
 include/linux/string.h                  | 2 +-
 lib/string.c                            | 2 +-
 8 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/arch/s390/include/asm/string.h b/arch/s390/include/asm/string.h
index 3fae93ddb322..0196fd466a39 100644
--- a/arch/s390/include/asm/string.h
+++ b/arch/s390/include/asm/string.h
@@ -120,7 +120,7 @@ static inline void *memchr(const void * s, int c, size_t n)
 #endif
 
 #ifdef __HAVE_ARCH_MEMSCAN
-static inline void *memscan(void *s, int c, size_t n)
+static inline void *memscan(const void *s, int c, size_t n)
 {
 	const void *ret = s + n;
 
@@ -205,7 +205,7 @@ static inline size_t strnlen(const char * s, size_t n)
 #endif
 #else /* IN_ARCH_STRING_C */
 void *memchr(const void * s, int c, size_t n);
-void *memscan(void *s, int c, size_t n);
+void *memscan(const void *s, int c, size_t n);
 char *strcat(char *dst, const char *src);
 char *strcpy(char *dst, const char *src);
 size_t strlen(const char *s);
diff --git a/arch/s390/lib/string.c b/arch/s390/lib/string.c
index 7d8741818239..ec9786fde1dd 100644
--- a/arch/s390/lib/string.c
+++ b/arch/s390/lib/string.c
@@ -331,7 +331,7 @@ EXPORT_SYMBOL(memcmp);
  * the area if @c is not found
  */
 #ifdef __HAVE_ARCH_MEMSCAN
-void *memscan(void *s, int c, size_t n)
+void *memscan(const void *s, int c, size_t n)
 {
 	const void *ret = s + n;
 
diff --git a/arch/sparc/include/asm/asm-prototypes.h b/arch/sparc/include/asm/asm-prototypes.h
index 4987c735ff56..3a82a86a27a6 100644
--- a/arch/sparc/include/asm/asm-prototypes.h
+++ b/arch/sparc/include/asm/asm-prototypes.h
@@ -13,8 +13,8 @@
 #include <asm/oplib.h>
 #include <linux/atomic.h>
 
-void *__memscan_zero(void *, size_t);
-void *__memscan_generic(void *, int, size_t);
+void *__memscan_zero(const void *, size_t);
+void *__memscan_generic(const void *, int, size_t);
 void *__bzero(void *, size_t);
 void VISenter(void); /* Dummy prototype to supress warning */
 #undef memcpy
diff --git a/arch/sparc/include/asm/string.h b/arch/sparc/include/asm/string.h
index 001a17baf2d5..7761a037b377 100644
--- a/arch/sparc/include/asm/string.h
+++ b/arch/sparc/include/asm/string.h
@@ -21,10 +21,11 @@ void *memmove(void *, const void *, __kernel_size_t);
 
 #define memscan(__arg0, __char, __arg2)						\
 ({										\
-	void *__memscan_zero(void *, size_t);					\
-	void *__memscan_generic(void *, int, size_t);				\
-	void *__retval, *__addr = (__arg0);					\
+	void *__memscan_zero(const void *, size_t);				\
+	void *__memscan_generic(const void *, int, size_t);			\
+	const void *__addr = (__arg0);						\
 	size_t __size = (__arg2);						\
+	void *__retval;								\
 										\
 	if(__builtin_constant_p(__char) && !(__char))				\
 		__retval = __memscan_zero(__addr, __size);			\
diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h
index 32c0d981a82a..30245f7707e7 100644
--- a/arch/x86/include/asm/string_32.h
+++ b/arch/x86/include/asm/string_32.h
@@ -223,7 +223,7 @@ static inline void *memset32(uint32_t *s, uint32_t v, size_t n)
  * find the first occurrence of byte 'c', or 1 past the area if none
  */
 #define __HAVE_ARCH_MEMSCAN
-extern void *memscan(void *addr, int c, size_t size);
+extern void *memscan(const void *addr, int c, size_t size);
 
 #endif /* __KERNEL__ */
 
diff --git a/arch/x86/lib/string_32.c b/arch/x86/lib/string_32.c
index 53b3f202267c..4124d6678f72 100644
--- a/arch/x86/lib/string_32.c
+++ b/arch/x86/lib/string_32.c
@@ -198,7 +198,7 @@ EXPORT_SYMBOL(memchr);
 #endif
 
 #ifdef __HAVE_ARCH_MEMSCAN
-void *memscan(void *addr, int c, size_t size)
+void *memscan(const void *addr, int c, size_t size)
 {
 	if (!size)
 		return addr;
diff --git a/include/linux/string.h b/include/linux/string.h
index c062c581a98b..a7bff7ed3cb0 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -150,7 +150,7 @@ extern void * memcpy(void *,const void *,__kernel_size_t);
 extern void * memmove(void *,const void *,__kernel_size_t);
 #endif
 #ifndef __HAVE_ARCH_MEMSCAN
-extern void * memscan(void *,int,__kernel_size_t);
+extern void * memscan(const void *,int,__kernel_size_t);
 #endif
 #ifndef __HAVE_ARCH_MEMCMP
 extern int memcmp(const void *,const void *,__kernel_size_t);
diff --git a/lib/string.c b/lib/string.c
index 3d55ef890106..30a63048d4cc 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -725,7 +725,7 @@ EXPORT_SYMBOL(bcmp);
  * returns the address of the first occurrence of @c, or 1 byte past
  * the area if @c is not found
  */
-void *memscan(void *addr, int c, size_t size)
+void *memscan(const void *addr, int c, size_t size)
 {
 	unsigned char *p = addr;
 
-- 
2.39.1


             reply	other threads:[~2023-02-16 11:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 11:42 Andy Shevchenko [this message]
2023-02-16 11:42 ` [PATCH net-next v1 2/2] dns: use memscan() instead of open coded variant Andy Shevchenko
2023-02-21  0:26 ` [PATCH net-next v1 1/2] string: Make memscan() to take const Jakub Kicinski
2023-02-21  9:37   ` Andy Shevchenko

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=20230216114234.36343-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=agordeev@linux.ibm.com \
    --cc=andy@kernel.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=svens@linux.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).