From owner-freebsd-bugs@FreeBSD.ORG Fri May 9 03:30:01 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83DDD10656C5 for ; Fri, 9 May 2008 03:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1CD518FC1A for ; Fri, 9 May 2008 03:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m493U0rf096399 for ; Fri, 9 May 2008 03:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m493U0Ic096396; Fri, 9 May 2008 03:30:00 GMT (envelope-from gnats) Resent-Date: Fri, 9 May 2008 03:30:00 GMT Resent-Message-Id: <200805090330.m493U0Ic096396@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, KOIE Hidetaka Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDC2C1065733 for ; Fri, 9 May 2008 03:29:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 3E3E28FC18 for ; Fri, 9 May 2008 03:29:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m493S2Fq079016 for ; Fri, 9 May 2008 03:28:02 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m493S2Xn079015; Fri, 9 May 2008 03:28:02 GMT (envelope-from nobody) Message-Id: <200805090328.m493S2Xn079015@www.freebsd.org> Date: Fri, 9 May 2008 03:28:02 GMT From: KOIE Hidetaka To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/123542: dev.cpu.0.temperature: -49 using k8temp X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 May 2008 03:30:06 -0000 >Number: 123542 >Category: kern >Synopsis: dev.cpu.0.temperature: -49 using k8temp >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri May 09 03:30:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: KOIE Hidetaka >Release: FreeBSD 8.0-CURRENT amd64 >Organization: surigiken >Environment: reeBSD guriandgura 8.0-CURRENT FreeBSD 8.0-CURRENT #1: Thu May 8 20:42:22 JST 2008 root@guriandgura:/usr/obj/usr/src/sys/GURIANDGURA amd64 >Description: sysctl dev.cpu.0.temperature returns -49. -49 is K8TEMP_MINTEMP. >How-To-Repeat: guriandgura# sysctl dev.cpu.0.temperature dev.cpu.0.temperature: -49 >Fix: k8temp_sysctl() uses max(uint) that is defined: static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } But, the arguments are int32_t, so -49 is interpreted 4294967247. Use imax() instead of max(). #In k8temp, we assume sizeof (int32_t) == sizeof (int). Patch attached with submission follows: Index: k8temp.c =================================================================== RCS file: /museum/freebsd/repo/usr/src/sys/dev/k8temp/k8temp.c,v retrieving revision 1.2 diff -u -p -r1.2 k8temp.c --- k8temp.c 21 Apr 2008 22:00:01 -0000 1.2 +++ k8temp.c 9 May 2008 03:21:55 -0000 @@ -226,13 +226,13 @@ k8temp_attach(device_t dev) SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "core0", CTLTYPE_INT | CTLFLAG_RD, - dev, SENSOR0_CORE0, k8temp_sysctl, "I", + dev, SENSOR1_CORE0, k8temp_sysctl, "I", "Sensor 1 / Core 0 temperature"); SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sysctlnode), OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD, - dev, SENSOR0_CORE0, k8temp_sysctl, "I", + dev, SENSOR1_CORE1, k8temp_sysctl, "I", "Sensor 1 / Core 1 temperature"); return (0); @@ -265,12 +265,12 @@ k8temp_sysctl(SYSCTL_HANDLER_ARGS) case CORE0: auxtemp[0] = k8temp_gettemp(dev, SENSOR0_CORE0); auxtemp[1] = k8temp_gettemp(dev, SENSOR1_CORE0); - temp = max(auxtemp[0], auxtemp[1]); + temp = imax(auxtemp[0], auxtemp[1]); break; case CORE1: auxtemp[0] = k8temp_gettemp(dev, SENSOR0_CORE1); auxtemp[1] = k8temp_gettemp(dev, SENSOR1_CORE1); - temp = max(auxtemp[0], auxtemp[1]); + temp = imax(auxtemp[0], auxtemp[1]); break; default: temp = k8temp_gettemp(dev, arg2); >Release-Note: >Audit-Trail: >Unformatted: