From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: traps: Mark __le16, __le32, __user variables properly
Date: Mon, 20 Feb 2017 10:49:47 +0000 [thread overview]
Message-ID: <20170220104947.GE9003@leverpostej> (raw)
In-Reply-To: <148758047729.2988.16966413648865610904@sboyd-linaro>
On Mon, Feb 20, 2017 at 12:47:57AM -0800, Stephen Boyd wrote:
> Quoting Luc Van Oostenryck (2017-02-18 17:58:09)
> > On Fri, Feb 17, 2017 at 08:51:12AM -0800, Stephen Boyd wrote:
> >
> > > arch/arm64/kernel/traps.c:567:10: warning: Initializer entry defined twice
> > > arch/arm64/kernel/traps.c:568:10: also defined here
> > This one I find strange. Can you tell which are those two entries?
>
> This is:
>
> static const char *esr_class_str[] = {
> [0 ... ESR_ELx_EC_MAX] = "UNRECOGNIZED EC",
> [ESR_ELx_EC_UNKNOWN] = "Unknown/Uncategorized",
>
> where we initialize the entire array to an "unknown" value once, and
> then fill in the known values after that. This isn't a very common
> pattern, but it is used from time to time to avoid having lots of lines
> to do the same thing.
FWIW, it's a fairly common trick for syscall tables, which is where I
copied it from for the above. Certainly it's not that common elsewhere.
[mark at leverpostej:~/src/linux]% tail -n 11 arch/arm64/kernel/sys.c
#undef __SYSCALL
#define __SYSCALL(nr, sym) [nr] = sym,
/*
* The sys_call_table array must be 4K aligned to be accessible from
* kernel/entry.S.
*/
void * const sys_call_table[__NR_syscalls] __aligned(4096) = {
[0 ... __NR_syscalls - 1] = sys_ni_syscall,
#include <asm/unistd.h>
};
[mark at leverpostej:~/src/linux]% git grep '\[0 \.\.\. ' | grep sys
arch/arc/kernel/sys.c: [0 ... NR_syscalls-1] = sys_ni_syscall,
arch/arm64/kernel/sys.c: [0 ... __NR_syscalls - 1] = sys_ni_syscall,
arch/arm64/kernel/sys32.c: [0 ... __NR_compat_syscalls - 1] = sys_ni_syscall,
arch/c6x/kernel/sys_c6x.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/metag/kernel/sys_metag.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/tile/kernel/compat.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/tile/kernel/sys.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/unicore32/kernel/sys.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/x86/entry/syscall_32.c: [0 ... __NR_syscall_compat_max] = &sys_ni_syscall,
arch/x86/entry/syscall_64.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/x86/um/sys_call_table_32.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/x86/um/sys_call_table_64.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/xtensa/kernel/syscall.c: [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall,
It would be nice to make sparse aware of this somehow, even if it
requires some annotation.
Thanks,
Mark.
WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Stephen Boyd <stephen.boyd@linaro.org>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Punit Agrawal <punit.agrawal@arm.com>
Subject: Re: [PATCH] arm64: traps: Mark __le16, __le32, __user variables properly
Date: Mon, 20 Feb 2017 10:49:47 +0000 [thread overview]
Message-ID: <20170220104947.GE9003@leverpostej> (raw)
In-Reply-To: <148758047729.2988.16966413648865610904@sboyd-linaro>
On Mon, Feb 20, 2017 at 12:47:57AM -0800, Stephen Boyd wrote:
> Quoting Luc Van Oostenryck (2017-02-18 17:58:09)
> > On Fri, Feb 17, 2017 at 08:51:12AM -0800, Stephen Boyd wrote:
> >
> > > arch/arm64/kernel/traps.c:567:10: warning: Initializer entry defined twice
> > > arch/arm64/kernel/traps.c:568:10: also defined here
> > This one I find strange. Can you tell which are those two entries?
>
> This is:
>
> static const char *esr_class_str[] = {
> [0 ... ESR_ELx_EC_MAX] = "UNRECOGNIZED EC",
> [ESR_ELx_EC_UNKNOWN] = "Unknown/Uncategorized",
>
> where we initialize the entire array to an "unknown" value once, and
> then fill in the known values after that. This isn't a very common
> pattern, but it is used from time to time to avoid having lots of lines
> to do the same thing.
FWIW, it's a fairly common trick for syscall tables, which is where I
copied it from for the above. Certainly it's not that common elsewhere.
[mark@leverpostej:~/src/linux]% tail -n 11 arch/arm64/kernel/sys.c
#undef __SYSCALL
#define __SYSCALL(nr, sym) [nr] = sym,
/*
* The sys_call_table array must be 4K aligned to be accessible from
* kernel/entry.S.
*/
void * const sys_call_table[__NR_syscalls] __aligned(4096) = {
[0 ... __NR_syscalls - 1] = sys_ni_syscall,
#include <asm/unistd.h>
};
[mark@leverpostej:~/src/linux]% git grep '\[0 \.\.\. ' | grep sys
arch/arc/kernel/sys.c: [0 ... NR_syscalls-1] = sys_ni_syscall,
arch/arm64/kernel/sys.c: [0 ... __NR_syscalls - 1] = sys_ni_syscall,
arch/arm64/kernel/sys32.c: [0 ... __NR_compat_syscalls - 1] = sys_ni_syscall,
arch/c6x/kernel/sys_c6x.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/metag/kernel/sys_metag.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/tile/kernel/compat.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/tile/kernel/sys.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/unicore32/kernel/sys.c: [0 ... __NR_syscalls-1] = sys_ni_syscall,
arch/x86/entry/syscall_32.c: [0 ... __NR_syscall_compat_max] = &sys_ni_syscall,
arch/x86/entry/syscall_64.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/x86/um/sys_call_table_32.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/x86/um/sys_call_table_64.c: [0 ... __NR_syscall_max] = &sys_ni_syscall,
arch/xtensa/kernel/syscall.c: [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall,
It would be nice to make sparse aware of this somehow, even if it
requires some annotation.
Thanks,
Mark.
next prev parent reply other threads:[~2017-02-20 10:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 16:51 [PATCH] arm64: traps: Mark __le16, __le32, __user variables properly Stephen Boyd
2017-02-17 16:51 ` Stephen Boyd
2017-02-17 17:31 ` Russell King - ARM Linux
2017-02-17 17:31 ` Russell King - ARM Linux
2017-02-17 17:46 ` Stephen Boyd
2017-02-19 1:58 ` Luc Van Oostenryck
2017-02-19 1:58 ` Luc Van Oostenryck
2017-02-20 8:47 ` Stephen Boyd
2017-02-20 10:04 ` Luc Van Oostenryck
2017-02-20 10:04 ` Luc Van Oostenryck
2017-02-20 10:49 ` Mark Rutland [this message]
2017-02-20 10:49 ` Mark Rutland
2017-02-20 21:33 ` Luc Van Oostenryck
2017-02-20 21:33 ` Luc Van Oostenryck
2017-02-21 11:03 ` Will Deacon
2017-02-21 11:03 ` Will Deacon
2017-02-22 13:00 ` Luc Van Oostenryck
2017-02-22 13:00 ` Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 0/5] improve detection of overlapping initializers Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 1/5] use option: '-Woverride-init' Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 2/5] add test case for warnings about overlapping initializers Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 3/5] allow to warn on all " Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 4/5] fix checking of overlapping initializer Luc Van Oostenryck
2017-02-22 15:30 ` [PATCH 5/5] ignore whole-range " Luc Van Oostenryck
2017-02-27 16:34 ` Christopher Li
2017-02-27 21:38 ` Luc Van Oostenryck
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=20170220104947.GE9003@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.