From 4fc29e63cc44fe1486b4d8037370a7d74db28999 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:46 +0300 Subject: mips: Return proper error code from console ->setup() hook For unifying console ->setup() handling, which is poorly documented, return error code, rather than non-zero arbitrary number. Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Acked-by: Thomas Bogendoerfer Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-2-andriy.shevchenko@linux.intel.com --- arch/mips/fw/arc/arc_con.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/mips/fw/arc/arc_con.c b/arch/mips/fw/arc/arc_con.c index 365e3913231e..7fdce236b298 100644 --- a/arch/mips/fw/arc/arc_con.c +++ b/arch/mips/fw/arc/arc_con.c @@ -28,7 +28,9 @@ static void prom_console_write(struct console *co, const char *s, static int prom_console_setup(struct console *co, char *options) { - return !(prom_flags & PROM_FLAG_USE_AS_CONSOLE); + if (prom_flags & PROM_FLAG_USE_AS_CONSOLE) + return 0; + return -ENODEV; } static struct console arc_cons = { -- cgit v1.2.3 From f85956b7a29d39745d16ebb6fb81c663018beab1 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:47 +0300 Subject: serial: sunsab: Return proper error code from console ->setup() hook For unifying console ->setup() handling, which is poorly documented, return error code, rather than non-zero arbitrary number. Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Acked-by: David S. Miller Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-3-andriy.shevchenko@linux.intel.com --- drivers/tty/serial/sunsab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 1eb703c980e0..bab551f46963 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c @@ -886,7 +886,7 @@ static int sunsab_console_setup(struct console *con, char *options) * though... */ if (up->port.type != PORT_SUNSAB) - return -1; + return -EINVAL; printk("Console: ttyS%d (SAB82532)\n", (sunsab_reg.minor - 64) + con->index); -- cgit v1.2.3 From 8629d2744d888cc31cb0ad14c9f222c14165f75e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:48 +0300 Subject: serial: sunzilog: Return proper error code from console ->setup() hook For unifying console ->setup() handling, which is poorly documented, return error code, rather than non-zero arbitrary number. Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Acked-by: David S. Miller Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-4-andriy.shevchenko@linux.intel.com --- drivers/tty/serial/sunzilog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index 103ab8c556e7..7ea06bbc6197 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c @@ -1221,7 +1221,7 @@ static int __init sunzilog_console_setup(struct console *con, char *options) int baud, brg; if (up->port.type != PORT_SUNZILOG) - return -1; + return -EINVAL; printk(KERN_INFO "Console: ttyS%d (SunZilog zs%d)\n", (sunzilog_reg.minor - 64) + con->index, con->index); -- cgit v1.2.3 From 9f02842759d8fa4444cd494f847cbe283e3b5815 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:49 +0300 Subject: tty: hvc: Return proper error code from console ->setup() hook For unifying console ->setup() handling, which is poorly documented, return error code, rather than non-zero arbitrary number. Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-5-andriy.shevchenko@linux.intel.com --- drivers/tty/hvc/hvsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c index 66f95f758be0..e8c58f9bd263 100644 --- a/drivers/tty/hvc/hvsi.c +++ b/drivers/tty/hvc/hvsi.c @@ -1128,7 +1128,7 @@ static int __init hvsi_console_setup(struct console *console, char *options) int ret; if (console->index < 0 || console->index >= hvsi_count) - return -1; + return -EINVAL; hp = &hvsi_ports[console->index]; /* give the FSP a chance to change the baud rate when we re-open */ -- cgit v1.2.3 From bba18a1af33e0f0a1ad7d028208b306ef3f3df12 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:50 +0300 Subject: console: Propagate error code from console ->setup() Since console ->setup() hook returns meaningful error codes, propagate it to the caller of try_enable_new_console(). Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Acked-by: Benjamin Herrenschmidt Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-6-andriy.shevchenko@linux.intel.com --- kernel/printk/printk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 8c14835be46c..aaea3ad182e1 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2668,7 +2668,7 @@ early_param("keep_bootcon", keep_bootcon_setup); static int try_enable_new_console(struct console *newcon, bool user_specified) { struct console_cmdline *c; - int i; + int i, err; for (i = 0, c = console_cmdline; i < MAX_CMDLINECONSOLES && c->name[0]; @@ -2691,8 +2691,8 @@ static int try_enable_new_console(struct console *newcon, bool user_specified) return 0; if (newcon->setup && - newcon->setup(newcon, c->options) != 0) - return -EIO; + (err = newcon->setup(newcon, c->options)) != 0) + return err; } newcon->flags |= CON_ENABLED; if (i == preferred_console) { -- cgit v1.2.3 From 504603767ab639c47912be08d62e02b43125e82e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 18 Jun 2020 19:47:51 +0300 Subject: console: Fix trivia typo 'change' -> 'chance' I bet the word 'chance' has to be used in 'had a chance to be called', but, alas, I'm not native speaker... Signed-off-by: Andy Shevchenko Reviewed-by: Petr Mladek Acked-by: Benjamin Herrenschmidt Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200618164751.56828-7-andriy.shevchenko@linux.intel.com --- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index aaea3ad182e1..6623e975675a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2705,7 +2705,7 @@ static int try_enable_new_console(struct console *newcon, bool user_specified) /* * Some consoles, such as pstore and netconsole, can be enabled even * without matching. Accept the pre-enabled consoles only when match() - * and setup() had a change to be called. + * and setup() had a chance to be called. */ if (newcon->flags & CON_ENABLED && c->user_specified == user_specified) return 0; -- cgit v1.2.3 From 6f2fdb298bf8e3207d060d57f2565b13d9300d2f Mon Sep 17 00:00:00 2001 From: Sergey Senozhatsky Date: Sat, 20 Jun 2020 02:22:40 +0900 Subject: hvc: unify console setup naming Use the 'common' foo_console_setup() naming scheme. There are 71 foo_console_setup() callbacks and only one foo_setup_console(). Signed-off-by: Sergey Senozhatsky Cc: Andy Shevchenko Cc: Steven Rostedt Cc: Greg Kroah-Hartman Cc: Jiri Slaby Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200619172240.754910-1-sergey.senozhatsky@gmail.com --- drivers/tty/hvc/hvc_xen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 5ef08905fe05..2a0e51a20e34 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -603,7 +603,7 @@ static void xen_hvm_early_write(uint32_t vtermno, const char *str, int len) { } #endif #ifdef CONFIG_EARLY_PRINTK -static int __init xenboot_setup_console(struct console *console, char *string) +static int __init xenboot_console_setup(struct console *console, char *string) { static struct xencons_info xenboot; @@ -647,7 +647,7 @@ static void xenboot_write_console(struct console *console, const char *string, struct console xenboot_console = { .name = "xenboot", .write = xenboot_write_console, - .setup = xenboot_setup_console, + .setup = xenboot_console_setup, .flags = CON_PRINTBUFFER | CON_BOOT | CON_ANYTIME, .index = -1, }; -- cgit v1.2.3 From 8eda94bde4ff004a942ed95e6348de711b0e6da9 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 2 Jul 2020 22:05:36 +0200 Subject: Replace HTTP links with HTTPS ones: vsprintf Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Reviewed-by: Petr Mladek Reviewed-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200702200536.13389-1-grandmaster@al2klimov.de --- Documentation/core-api/printk-formats.rst | 4 ++-- lib/vsprintf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/core-api/printk-formats.rst b/Documentation/core-api/printk-formats.rst index 8c9aba262b1e..1beac4719e43 100644 --- a/Documentation/core-api/printk-formats.rst +++ b/Documentation/core-api/printk-formats.rst @@ -317,7 +317,7 @@ colon-separators. Leading zeros are always used. The additional ``c`` specifier can be used with the ``I`` specifier to print a compressed IPv6 address as described by -http://tools.ietf.org/html/rfc5952 +https://tools.ietf.org/html/rfc5952 Passed by reference. @@ -341,7 +341,7 @@ The additional ``p``, ``f``, and ``s`` specifiers are used to specify port flowinfo a ``/`` and scope a ``%``, each followed by the actual value. In case of an IPv6 address the compressed IPv6 address as described by -http://tools.ietf.org/html/rfc5952 is being used if the additional +https://tools.ietf.org/html/rfc5952 is being used if the additional specifier ``c`` is given. The IPv6 address is surrounded by ``[``, ``]`` in case of additional specifiers ``p``, ``f`` or ``s`` as suggested by https://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-07 diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 259e55895933..31a674dd2674 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -2134,7 +2134,7 @@ char *fwnode_string(char *buf, char *end, struct fwnode_handle *fwnode, * [4] or [6] and is able to print port [p], flowinfo [f], scope [s] * - '[Ii][4S][hnbl]' IPv4 addresses in host, network, big or little endian order * - 'I[6S]c' for IPv6 addresses printed as specified by - * http://tools.ietf.org/html/rfc5952 + * https://tools.ietf.org/html/rfc5952 * - 'E[achnops]' For an escaped buffer, where rules are defined by combination * of the following flags (see string_escape_mem() for the * details): -- cgit v1.2.3 From bc885f1ab6de0d38c6956a71b0126543b64875b0 Mon Sep 17 00:00:00 2001 From: Bruno Meneguele Date: Fri, 10 Jul 2020 14:44:23 -0300 Subject: doc:kmsg: explicitly state the return value in case of SEEK_CUR The commit 625d3449788f ("Revert "kernel/printk: add kmsg SEEK_CUR handling"") reverted a change done to the return value in case a SEEK_CUR operation was performed for kmsg buffer based on the fact that different userspace apps were handling the new return value (-ESPIPE) in different ways, breaking them. At the same time -ESPIPE was the wrong decision because kmsg /does support/ seek() but doesn't follow the "normal" behavior userspace is used to. Because of that and also considering the time -EINVAL has been used, it was decided to keep this way to avoid more userspace breakage. This patch adds an official statement to the kmsg documentation pointing to the current return value for SEEK_CUR, -EINVAL, thus userspace libraries and apps can refer to it for a definitive guide on what to expect. Signed-off-by: Bruno Meneguele Reviewed-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20200710174423.10480-1-bmeneg@redhat.com --- Documentation/ABI/testing/dev-kmsg | 11 +++++++++++ kernel/printk/printk.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/Documentation/ABI/testing/dev-kmsg b/Documentation/ABI/testing/dev-kmsg index 1e6c28b1942b..a917efc289a2 100644 --- a/Documentation/ABI/testing/dev-kmsg +++ b/Documentation/ABI/testing/dev-kmsg @@ -61,6 +61,17 @@ Description: The /dev/kmsg character device node provides userspace access SEEK_CUR is not supported, returning -ESPIPE (invalid seek) to errno whenever requested. + Other seek operations or offsets are not supported because of + the special behavior this device has. The device allows to read + or write only whole variable length messages (records) that are + stored in a ring buffer. + + Because of the non-standard behavior also the error values are + non-standard. -ESPIPE is returned for non-zero offset. -EINVAL + is returned for other operations, e.g. SEEK_CUR. This behavior + and values are historical and could not be modified without the + risk of breaking userspace. + The output format consists of a prefix carrying the syslog prefix including priority and facility, the 64 bit message sequence number and the monotonic timestamp in microseconds, diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 8c14835be46c..5f6eca65dd9a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -943,6 +943,14 @@ out: return ret; } +/* + * Be careful when modifying this function!!! + * + * Only few operations are supported because the device works only with the + * entire variable length messages (records). Non-standard values are + * returned in the other cases and has been this way for quite some time. + * User space applications might depend on this behavior. + */ static loff_t devkmsg_llseek(struct file *file, loff_t offset, int whence) { struct devkmsg_user *user = file->private_data; -- cgit v1.2.3 From b4a461e72bcb28a512bbdd29a4cb70aede2d68d3 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 21 Jul 2020 16:22:48 +1000 Subject: printk: Make linux/printk.h self-contained As it stands if you include printk.h by itself it will fail to compile because it requires definitions from ratelimit.h. However, simply including ratelimit.h from printk.h does not work due to inclusion loops involving sched.h and kernel.h. This patch solves this by moving bits from ratelimit.h into a new header file which can then be included by printk.h without any worries about header loops. The build bot then revealed some intriguing failures arising out of this patch. On s390 there is an inclusion loop with asm/bug.h and linux/kernel.h that triggers a compile failure, because kernel.h will cause asm-generic/bug.h to be included before s390's own asm/bug.h has finished processing. This has been fixed by not including kernel.h in arch/s390/include/asm/bug.h. Signed-off-by: Herbert Xu Reviewed-by: Andy Shevchenko Reviewed-by: Sergey Senozhatsky Acked-by: Petr Mladek Acked-by: Steven Rostedt (VMware) Signed-off-by: Sergey Senozhatsky Link: https://lore.kernel.org/r/20200721062248.GA18383@gondor.apana.org.au --- arch/s390/include/asm/bug.h | 2 +- include/linux/printk.h | 1 + include/linux/ratelimit.h | 36 +--------------------------------- include/linux/ratelimit_types.h | 43 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 include/linux/ratelimit_types.h diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index 7725f8006fdf..0b25f28351ed 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h @@ -2,7 +2,7 @@ #ifndef _ASM_S390_BUG_H #define _ASM_S390_BUG_H -#include +#include #ifdef CONFIG_BUG diff --git a/include/linux/printk.h b/include/linux/printk.h index fc8f03c54543..34c1a7be3e01 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -7,6 +7,7 @@ #include #include #include +#include extern const char linux_banner[]; extern const char linux_proc_banner[]; diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h index 8ddf79e9207a..b17e0cd0a30c 100644 --- a/include/linux/ratelimit.h +++ b/include/linux/ratelimit.h @@ -2,41 +2,10 @@ #ifndef _LINUX_RATELIMIT_H #define _LINUX_RATELIMIT_H -#include +#include #include #include -#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) -#define DEFAULT_RATELIMIT_BURST 10 - -/* issue num suppressed message on exit */ -#define RATELIMIT_MSG_ON_RELEASE BIT(0) - -struct ratelimit_state { - raw_spinlock_t lock; /* protect the state */ - - int interval; - int burst; - int printed; - int missed; - unsigned long begin; - unsigned long flags; -}; - -#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \ - .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ - .interval = interval_init, \ - .burst = burst_init, \ - } - -#define RATELIMIT_STATE_INIT_DISABLED \ - RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST) - -#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ - \ - struct ratelimit_state name = \ - RATELIMIT_STATE_INIT(name, interval_init, burst_init) \ - static inline void ratelimit_state_init(struct ratelimit_state *rs, int interval, int burst) { @@ -73,9 +42,6 @@ ratelimit_set_flags(struct ratelimit_state *rs, unsigned long flags) extern struct ratelimit_state printk_ratelimit_state; -extern int ___ratelimit(struct ratelimit_state *rs, const char *func); -#define __ratelimit(state) ___ratelimit(state, __func__) - #ifdef CONFIG_PRINTK #define WARN_ON_RATELIMIT(condition, state) ({ \ diff --git a/include/linux/ratelimit_types.h b/include/linux/ratelimit_types.h new file mode 100644 index 000000000000..b676aa419eef --- /dev/null +++ b/include/linux/ratelimit_types.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_RATELIMIT_TYPES_H +#define _LINUX_RATELIMIT_TYPES_H + +#include +#include +#include + +#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ) +#define DEFAULT_RATELIMIT_BURST 10 + +/* issue num suppressed message on exit */ +#define RATELIMIT_MSG_ON_RELEASE BIT(0) + +struct ratelimit_state { + raw_spinlock_t lock; /* protect the state */ + + int interval; + int burst; + int printed; + int missed; + unsigned long begin; + unsigned long flags; +}; + +#define RATELIMIT_STATE_INIT(name, interval_init, burst_init) { \ + .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ + .interval = interval_init, \ + .burst = burst_init, \ + } + +#define RATELIMIT_STATE_INIT_DISABLED \ + RATELIMIT_STATE_INIT(ratelimit_state, 0, DEFAULT_RATELIMIT_BURST) + +#define DEFINE_RATELIMIT_STATE(name, interval_init, burst_init) \ + \ + struct ratelimit_state name = \ + RATELIMIT_STATE_INIT(name, interval_init, burst_init) \ + +extern int ___ratelimit(struct ratelimit_state *rs, const char *func); +#define __ratelimit(state) ___ratelimit(state, __func__) + +#endif /* _LINUX_RATELIMIT_TYPES_H */ -- cgit v1.2.3 From b886690d1bf050525367f552842e3c89567c8ec6 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 31 Jul 2020 21:08:22 +0300 Subject: lib/vsprintf: Replace hidden BUILD_BUG_ON() with static_assert() First of all, there is no compile time check for the SMALL to be ' ' (0x20, i.e. space). Second, for ZEROPAD the check is hidden in the code. For better maintenance replace BUILD_BUG_ON() with static_assert() for ZEROPAD and move it closer to the definition. While at it, introduce check for SMALL. Signed-off-by: Andy Shevchenko Reviewed-by: Steven Rostedt (VMware) Reviewed-by: Sergey Senozhatsky Link: https://lore.kernel.org/r/20200731180825.30575-1-andriy.shevchenko@linux.intel.com Signed-off-by: Sergey Senozhatsky --- lib/vsprintf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 31a674dd2674..f90f09682977 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -381,6 +381,9 @@ int num_to_str(char *buf, int size, unsigned long long num, unsigned int width) #define SMALL 32 /* use lowercase in hex (must be 32 == 0x20) */ #define SPECIAL 64 /* prefix hex with "0x", octal with "0" */ +static_assert(ZEROPAD == ('0' - ' ')); +static_assert(SMALL == ' '); + enum format_type { FORMAT_TYPE_NONE, /* Just a string part */ FORMAT_TYPE_WIDTH, @@ -507,7 +510,7 @@ char *number(char *buf, char *end, unsigned long long num, /* zero or space padding */ if (!(spec.flags & LEFT)) { char c = ' ' + (spec.flags & ZEROPAD); - BUILD_BUG_ON(' ' + ZEROPAD != '0'); + while (--field_width >= 0) { if (buf < end) *buf = c; -- cgit v1.2.3 From 09ceb8d76e6fa2c6a5bfc22eabd0cebe599e1690 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 31 Jul 2020 21:08:23 +0300 Subject: lib/vsprintf: Replace custom spec to print decimals with generic one When printing phandle via %pOFp the custom spec is used. First of all, it has a SMALL flag which makes no sense for decimal numbers. Second, we have already default spec for decimal numbers. Use the latter in the %pOFp case as well. Signed-off-by: Andy Shevchenko Reviewed-by: Steven Rostedt (VMware) Reviewed-by: Sergey Senozhatsky Cc: Pantelis Antoniou Cc: Rob Herring Cc: Joe Perches Cc: Grant Likely Link: https://lore.kernel.org/r/20200731180825.30575-2-andriy.shevchenko@linux.intel.com Signed-off-by: Sergey Senozhatsky --- lib/vsprintf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index f90f09682977..182a3e2e1629 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1979,12 +1979,6 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, char *buf_start = buf; struct property *prop; bool has_mult, pass; - static const struct printf_spec num_spec = { - .flags = SMALL, - .field_width = -1, - .precision = -1, - .base = 10, - }; struct printf_spec str_spec = spec; str_spec.field_width = -1; @@ -2024,7 +2018,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, str_spec.precision = precision; break; case 'p': /* phandle */ - buf = number(buf, end, (unsigned int)dn->phandle, num_spec); + buf = number(buf, end, (unsigned int)dn->phandle, default_dec_spec); break; case 'P': /* path-spec */ p = fwnode_get_name(of_fwnode_handle(dn)); -- cgit v1.2.3 From 30d497a0e1aadd904867081246c310dd0284eb41 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 31 Jul 2020 21:08:24 +0300 Subject: lib/vsprintf: Force type of flags value for gfp_t Sparse is not happy about restricted type being assigned: lib/vsprintf.c:1940:23: warning: incorrect type in assignment (different base types) lib/vsprintf.c:1940:23: expected unsigned long [assigned] flags lib/vsprintf.c:1940:23: got restricted gfp_t [usertype] Force type of flags value to make sparse happy. Signed-off-by: Andy Shevchenko Reviewed-by: Steven Rostedt (VMware) Link: https://lore.kernel.org/r/20200731180825.30575-3-andriy.shevchenko@linux.intel.com Signed-off-by: Sergey Senozhatsky --- lib/vsprintf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 182a3e2e1629..c155769559ab 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1937,7 +1937,7 @@ char *flags_string(char *buf, char *end, void *flags_ptr, names = vmaflag_names; break; case 'g': - flags = *(gfp_t *)flags_ptr; + flags = (__force unsigned long)(*(gfp_t *)flags_ptr); names = gfpflag_names; break; default: -- cgit v1.2.3