Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Fix year correction in platform_add_date so...



details:   https://anonhg.NetBSD.org/src/rev/c031136aa2c1
branches:  trunk
changeset: 760963:c031136aa2c1
user:      jmmv <jmmv%NetBSD.org@localhost>
date:      Mon Jan 17 22:21:25 2011 +0000

description:
Fix year correction in platform_add_date so that:
* Years in the [90,99] range are considered to be in 1900.
* Years in the [0,89] range are considered to be in 2000.

This makes my MacBookPro2,2 be recognized as from 2007 instead of 1907, which
in turn lets ACPI (and many other things!) work.

Fix proposed by jmcneill@ as an alternative to my workaround in acpi_quirks.c
sent to port-i386@.

diffstat:

 sys/arch/x86/x86/platform.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r daaf53b09c01 -r c031136aa2c1 sys/arch/x86/x86/platform.c
--- a/sys/arch/x86/x86/platform.c       Mon Jan 17 22:08:30 2011 +0000
+++ b/sys/arch/x86/x86/platform.c       Mon Jan 17 22:21:25 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: platform.c,v 1.9 2010/09/06 15:54:27 jmcneill Exp $ */
+/* $NetBSD: platform.c,v 1.10 2011/01/17 22:21:25 jmmv Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "isa.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.9 2010/09/06 15:54:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.10 2011/01/17 22:21:25 jmmv Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -165,10 +165,12 @@
                return;
        if (month == 0 || month > 12 || day == 0 || day > 31)
                return;
-       if (year < 100)
-               year += 1900;
        if (year > 9999)
                return;
+       if (year < 90)
+               year += 2000;
+       else if (year < 100)
+               year += 1900;
        sprintf(datestr, "%04u%02u%02u", year, month, day);
        pmf_set_platform(key, datestr);
 }



Home | Main Index | Thread Index | Old Index