* [linux-next:master 5670/6619] kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]'
@ 2023-09-20 9:40 kernel test robot
2023-09-20 10:10 ` John Ogness
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2023-09-20 9:40 UTC (permalink / raw)
To: Thomas Gleixner
Cc: oe-kbuild-all, Linux Memory Management List, Petr Mladek, John Ogness
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 926f75c8a5ab70567eb4c2d82fbc96963313e564
commit: 06653d57ff283be627a2c769139d73ecc487810f [5670/6619] printk: nbcon: Add emit function and callback function for atomic printing
config: s390-randconfig-r004-20230825 (https://download.01.org/0day-ci/archive/20230920/202309201724.M9BMAQIh-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230920/202309201724.M9BMAQIh-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309201724.M9BMAQIh-lkp@intel.com/
All warnings (new ones prefixed by >>):
kernel/printk/printk.c: In function 'console_flush_all':
>> kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]' [-Warray-bounds]
2871 | char *outbuf = &printk_shared_pbufs.outbuf[0];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from kernel/printk/printk.c:61:
kernel/printk/internal.h:112:17: note: while referencing 'outbuf'
112 | char outbuf[PRINTK_MESSAGE_MAX];
| ^~~~~~
kernel/printk/printk.c:2851:23: note: defined here 'printk_shared_pbufs'
2851 | struct printk_buffers printk_shared_pbufs;
| ^~~~~~~~~~~~~~~~~~~
vim +2871 kernel/printk/printk.c
d818b56f77521e kernel/printk/printk.c John Ogness 2023-09-16 2852
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2853 /*
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2854 * Print one record for the given console. The record printed is whatever
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2855 * record is the next available record for the given console.
03a749e628fdbc kernel/printk/printk.c John Ogness 2022-04-21 2856 *
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2857 * @handover will be set to true if a printk waiter has taken over the
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2858 * console_lock, in which case the caller is no longer holding both the
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2859 * console_lock and the SRCU read lock. Otherwise it is set to false.
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2860 *
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2861 * @cookie is the cookie from the SRCU read lock.
^1da177e4c3f41 kernel/printk.c Linus Torvalds 2005-04-16 2862 *
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2863 * Returns false if the given console has no next record to print, otherwise
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2864 * true.
^1da177e4c3f41 kernel/printk.c Linus Torvalds 2005-04-16 2865 *
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2866 * Requires the console_lock and the SRCU read lock.
^1da177e4c3f41 kernel/printk.c Linus Torvalds 2005-04-16 2867 */
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2868 static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
^1da177e4c3f41 kernel/printk.c Linus Torvalds 2005-04-16 2869 {
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2870 bool is_extended = console_srcu_read_flags(con) & CON_EXTENDED;
d818b56f77521e kernel/printk/printk.c John Ogness 2023-09-16 @2871 char *outbuf = &printk_shared_pbufs.outbuf[0];
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2872 struct printk_message pmsg = {
d818b56f77521e kernel/printk/printk.c John Ogness 2023-09-16 2873 .pbufs = &printk_shared_pbufs,
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2874 };
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2875 unsigned long flags;
896fbe20b4e233 kernel/printk/printk.c John Ogness 2020-07-09 2876
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2877 *handover = false;
78944e549d3667 kernel/printk.c Antonino A. Daplas 2006-08-05 2878
ea308da1198f8c kernel/printk/printk.c John Ogness 2023-01-09 2879 if (!printk_get_next_message(&pmsg, con->seq, is_extended, true))
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2880 return false;
7ff9554bb578ba kernel/printk.c Kay Sievers 2012-05-03 2881
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2882 con->dropped += pmsg.dropped;
896fbe20b4e233 kernel/printk/printk.c John Ogness 2020-07-09 2883
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2884 /* Skip messages of formatted length 0. */
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2885 if (pmsg.outbuf_len == 0) {
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2886 con->seq = pmsg.seq + 1;
084681d14e429c kernel/printk.c Kay Sievers 2012-06-28 2887 goto skip;
084681d14e429c kernel/printk.c Kay Sievers 2012-06-28 2888 }
649e6ee33f73ba kernel/printk.c Kay Sievers 2012-05-10 2889
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2890 if (con->dropped && !is_extended) {
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2891 console_prepend_dropped(&pmsg, con->dropped);
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2892 con->dropped = 0;
6fe29354befe4c kernel/printk/printk.c Tejun Heo 2015-06-25 2893 }
7ff9554bb578ba kernel/printk.c Kay Sievers 2012-05-03 2894
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2895) /*
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2896) * While actively printing out messages, if another printk()
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2897) * were to occur on another CPU, it may wait for this one to
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2898) * finish. This task can not be preempted if there is a
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2899) * waiter waiting to take over.
93d102f094be9b kernel/printk/printk.c John Ogness 2021-07-15 2900 *
93d102f094be9b kernel/printk/printk.c John Ogness 2021-07-15 2901 * Interrupts are disabled because the hand over to a waiter
93d102f094be9b kernel/printk/printk.c John Ogness 2021-07-15 2902 * must not be interrupted until the hand over is completed
93d102f094be9b kernel/printk/printk.c John Ogness 2021-07-15 2903 * (@console_waiter is cleared).
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2904) */
93d102f094be9b kernel/printk/printk.c John Ogness 2021-07-15 2905 printk_safe_enter_irqsave(flags);
c162d5b4338d72 kernel/printk/printk.c Petr Mladek 2018-01-12 2906 console_lock_spinning_enable();
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2907)
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2908 /* Do not trace print latency. */
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2909 stop_critical_timings();
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2910
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2911 /* Write everything out to the hardware. */
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2912 con->write(con, outbuf, pmsg.outbuf_len);
c4fcc617e14879 kernel/printk/printk.c John Ogness 2023-01-09 2913
2d9ef940f89e0a kernel/printk/printk.c Petr Mladek 2022-06-23 2914 start_critical_timings();
dbdda842fe96f8 kernel/printk/printk.c Steven Rostedt (VMware 2018-01-10 2915)
2830eec14afd18 kernel/printk/printk.c John Ogness 2023-01-09 2916 con->seq = pmsg.seq + 1;
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2917
fc956ae0de7fa2 kernel/printk/printk.c John Ogness 2022-11-16 2918 *handover = console_lock_spinning_disable_and_check(cookie);
c162d5b4338d72 kernel/printk/printk.c Petr Mladek 2018-01-12 2919 printk_safe_exit_irqrestore(flags);
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2920 skip:
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2921 return true;
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2922 }
a699449bb13b70 kernel/printk/printk.c John Ogness 2022-04-21 2923
:::::: The code at line 2871 was first introduced by commit
:::::: d818b56f77521ecc5e3eda71dc9b2beb3d6681e3 printk: Make static printk buffers available to nbcon
:::::: TO: John Ogness <john.ogness@linutronix.de>
:::::: CC: Petr Mladek <pmladek@suse.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [linux-next:master 5670/6619] kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]'
2023-09-20 9:40 [linux-next:master 5670/6619] kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]' kernel test robot
@ 2023-09-20 10:10 ` John Ogness
2023-09-20 11:11 ` Petr Mladek
0 siblings, 1 reply; 3+ messages in thread
From: John Ogness @ 2023-09-20 10:10 UTC (permalink / raw)
To: kernel test robot, Thomas Gleixner
Cc: oe-kbuild-all, Linux Memory Management List, Petr Mladek
On 2023-09-20, kernel test robot <lkp@intel.com> wrote:
> kernel/printk/printk.c: In function 'console_flush_all':
>>> kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]' [-Warray-bounds]
> 2871 | char *outbuf = &printk_shared_pbufs.outbuf[0];
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is crazy all the things that get compiled in !CONFIG_PRINTK. We
definitely need to fix that after this rework.
As for this warning, anyone have anything against something like:
#ifdef CONFIG_PRINTK
static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
{
... implementation ...
}
#else
static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
{
*handover = false;
return false;
}
#endif
John
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [linux-next:master 5670/6619] kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]'
2023-09-20 10:10 ` John Ogness
@ 2023-09-20 11:11 ` Petr Mladek
0 siblings, 0 replies; 3+ messages in thread
From: Petr Mladek @ 2023-09-20 11:11 UTC (permalink / raw)
To: John Ogness
Cc: kernel test robot, Thomas Gleixner, oe-kbuild-all,
Linux Memory Management List
On Wed 2023-09-20 12:16:50, John Ogness wrote:
> On 2023-09-20, kernel test robot <lkp@intel.com> wrote:
> > kernel/printk/printk.c: In function 'console_flush_all':
> >>> kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]' [-Warray-bounds]
> > 2871 | char *outbuf = &printk_shared_pbufs.outbuf[0];
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> It is crazy all the things that get compiled in !CONFIG_PRINTK. We
> definitely need to fix that after this rework.
>
> As for this warning, anyone have anything against something like:
>
> #ifdef CONFIG_PRINTK
> static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
> {
> ... implementation ...
> }
> #else
> static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
> {
> *handover = false;
> return false;
> }
> #endif
Looks good to me.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-20 11:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-20 9:40 [linux-next:master 5670/6619] kernel/printk/printk.c:2871:24: warning: array subscript 0 is outside array bounds of 'char[0]' kernel test robot
2023-09-20 10:10 ` John Ogness
2023-09-20 11:11 ` Petr Mladek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox