OpenCloudOS-Kernel/arch/powerpc/platforms/maple
Daniel Axtens 00b912b0c8 powerpc: Remove broken GregorianDay()
GregorianDay() is supposed to calculate the day of the week
(tm->tm_wday) for a given day/month/year. In that calcuation it
indexed into an array called MonthOffset using tm->tm_mon-1. However
tm_mon is zero-based, not one-based, so this is off-by-one. It also
means that every January, GregoiranDay() will access element -1 of
the MonthOffset array.

It also doesn't appear to be a correct algorithm either: see in
contrast kernel/time/timeconv.c's time_to_tm function.

It's been broken forever, which suggests no-one in userland uses
this. It looks like no-one in the kernel uses tm->tm_wday either
(see e.g. drivers/rtc/rtc-ds1305.c:319).

tm->tm_wday is conventionally set to -1 when not available in
hardware so we can simply set it to -1 and drop the function.
(There are over a dozen other drivers in drivers/rtc that do
this.)

Found using UBSAN.

Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org> # as an example of what UBSan finds.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: rtc-linux@googlegroups.com
Signed-off-by: Daniel Axtens <dja@axtens.net>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2015-12-16 12:54:04 +11:00
..
Kconfig powerpc: Kconfig: remove BE-only platforms from LE kernel build 2015-09-29 22:57:00 +10:00
Makefile powerpc: Merge maple support code to arch/powerpc/platforms/maple 2005-10-29 22:07:56 +10:00
maple.h powerpc/maple: Move controller ops from ppc_md to controller_ops 2015-04-11 20:49:17 +10:00
pci.c powerpc/maple: Move controller ops from ppc_md to controller_ops 2015-04-11 20:49:17 +10:00
setup.c powerpc/maple: Move controller ops from ppc_md to controller_ops 2015-04-11 20:49:17 +10:00
time.c powerpc: Remove broken GregorianDay() 2015-12-16 12:54:04 +11:00