mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/4] vsprintf: constify pointers where appropriate
Date: Mon, 28 Sep 2020 17:34:28 +0200	[thread overview]
Message-ID: <20200928153431.1095-1-a.fatoum@pengutronix.de> (raw)

No functional change, but makes code bit more future proof when it is
extended.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 lib/vsprintf.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6fe0283e8466..3e5f4db75ac8 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -41,7 +41,8 @@ static int skip_atoi(const char **s)
 #define SMALL	32		/* Must be 32 == 0x20 */
 #define SPECIAL	64		/* 0x */
 
-static char *number(char *buf, char *end, unsigned long long num, int base, int size, int precision, int type)
+static char *number(char *buf, const char *end, unsigned long long num, int base, int size,
+		    int precision, int type)
 {
 	/* we are called with base 8, 10 or 16, only, thus don't need "G..."  */
 	static const char digits[16] = "0123456789ABCDEF"; /* "GHIJKLMNOPQRSTUVWXYZ"; */
@@ -146,7 +147,8 @@ static char *number(char *buf, char *end, unsigned long long num, int base, int
 #define PAGE_SIZE 4096
 #endif
 
-static char *string(char *buf, char *end, char *s, int field_width, int precision, int flags)
+static char *string(char *buf, const char *end, const char *s, int field_width,
+		    int precision, int flags)
 {
 	int len, i;
 
@@ -176,7 +178,8 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio
 }
 
 #ifndef __PBL__
-static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int precision, int flags)
+static char *symbol_string(char *buf, const char *end, const void *ptr, int field_width,
+			   int precision, int flags)
 {
 	unsigned long value = (unsigned long) ptr;
 #ifdef CONFIG_KALLSYMS
@@ -191,7 +194,7 @@ static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int
 }
 
 static noinline_for_stack
-char *ip4_addr_string(char *buf, char *end, const u8 *addr, int field_width,
+char *ip4_addr_string(char *buf, const char *end, const u8 *addr, int field_width,
 		      int precision, int flags, const char *fmt)
 {
 	char ip4_addr[sizeof("255.255.255.255")];
@@ -212,8 +215,8 @@ char *ip4_addr_string(char *buf, char *end, const u8 *addr, int field_width,
 }
 
 static noinline_for_stack
-char *uuid_string(char *buf, char *end, const u8 *addr, int field_width,
-		int precision, int flags, const char *fmt)
+char *uuid_string(char *buf, const char *end, const u8 *addr, int field_width,
+		  int precision, int flags, const char *fmt)
 {
 	char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
 	char *p = uuid;
@@ -259,8 +262,8 @@ char *uuid_string(char *buf, char *end, const u8 *addr, int field_width,
 }
 
 static noinline_for_stack
-char *address_val(char *buf, char *end, const void *addr,
-		int field_width, int precision, int flags, const char *fmt)
+char *address_val(char *buf, const char *end, const void *addr,
+		  int field_width, int precision, int flags, const char *fmt)
 {
 	unsigned long long num;
 
@@ -314,7 +317,8 @@ char *address_val(char *buf, char *end, const void *addr,
  * function pointers are really function descriptors, which contain a
  * pointer to the real address.
  */
-static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags)
+static char *pointer(const char *fmt, char *buf, const char *end, const void *ptr,
+		     int field_width, int precision, int flags)
 {
 	switch (*fmt) {
 	case 'S':
@@ -350,7 +354,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
 	return number(buf, end, (unsigned long) ptr, 16, field_width, precision, flags);
 }
 #else
-static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags)
+static char *pointer(const char *fmt, char *buf, const char *end, const void *ptr,
+		     int field_width, int precision, int flags)
 {
 	flags |= SMALL;
 	if (field_width == -1) {
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2020-09-28 15:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-28 15:34 Ahmad Fatoum [this message]
2020-09-28 15:34 ` [PATCH 2/4] vsprintf: add %pe format specifier for printing symbolic error names Ahmad Fatoum
2020-09-28 15:34 ` [PATCH 3/4] vsprintf: retire strerrorp in favor of %pe Ahmad Fatoum
2020-09-28 15:34 ` [PATCH 4/4] treewide: replace strerror(-PTR_ERR(errno)) with %pe format specifier Ahmad Fatoum
2020-09-29  6:42 ` [PATCH 1/4] vsprintf: constify pointers where appropriate Sascha Hauer

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=20200928153431.1095-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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