summaryrefslogtreecommitdiff
path: root/usr/src/cmd/picl
diff options
context:
space:
mode:
authorJustin Frank <Justin.Frank@Sun.COM>2009-02-09 17:50:34 -0800
committerJustin Frank <Justin.Frank@Sun.COM>2009-02-09 17:50:34 -0800
commit47b4653e9ff2a8aebb64f9e357713fd04108674b (patch)
tree0b6ba3eb6e9ec9917391414f5be871b8076216a5 /usr/src/cmd/picl
parentec0c94e7b9f27d94fcea0d1b4087ff9df614d037 (diff)
downloadillumos-joyent-47b4653e9ff2a8aebb64f9e357713fd04108674b.tar.gz
6790907 piclenvd's get_fan_speed divides by zero
Diffstat (limited to 'usr/src/cmd/picl')
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/chicago/envd/envd.h11
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/chicago/envd/piclenvd.c46
2 files changed, 28 insertions, 29 deletions
diff --git a/usr/src/cmd/picl/plugins/sun4u/chicago/envd/envd.h b/usr/src/cmd/picl/plugins/sun4u/chicago/envd/envd.h
index 1f5a6a5f86..d194ccd3c9 100644
--- a/usr/src/cmd/picl/plugins/sun4u/chicago/envd/envd.h
+++ b/usr/src/cmd/picl/plugins/sun4u/chicago/envd/envd.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,15 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ENVD_H
#define _ENVD_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <libintl.h>
@@ -126,7 +123,7 @@ extern "C" {
#define MAX_FAN_RETRIES 14
#define MAX_SENSOR_RETRIES 14
-#define TACH_TO_RPM(tach) (90000 * 60)/tach
+#define TACH_TO_RPM(tach) (((tach) == 0) ? 0 : (90000 * 60)/(tach))
/*
* constants used for retrieving SMART data
diff --git a/usr/src/cmd/picl/plugins/sun4u/chicago/envd/piclenvd.c b/usr/src/cmd/picl/plugins/sun4u/chicago/envd/piclenvd.c
index ce36071900..ff05c167ba 100644
--- a/usr/src/cmd/picl/plugins/sun4u/chicago/envd/piclenvd.c
+++ b/usr/src/cmd/picl/plugins/sun4u/chicago/envd/piclenvd.c
@@ -19,12 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains the environmental PICL plug-in module.
*/
@@ -592,14 +590,14 @@ get_fan_speed(env_fan_t *fanp, fanspeed_t *fanspeedp)
}
/* try to read the fan information */
- for (retries = 0; retries <= MAX_FAN_RETRIES; retries++) {
+ for (retries = 0; retries < MAX_FAN_RETRIES; retries++) {
if (ioctl(fanp->fd, PIC_GET_FAN_SPEED, &tach) == 0)
break;
(void) sleep(1);
}
total_fan_retries += retries;
- if (retries == MAX_FAN_RETRIES)
+ if (retries >= MAX_FAN_RETRIES)
return (-1);
if (total_fan_retries && env_debug) {
@@ -984,7 +982,7 @@ envd_es_setup(void)
uint32_t ess_id;
(void) memcpy(&ess_id,
- sensorp->ess_id, sizeof (sensorp->ess_id));
+ sensorp->ess_id, sizeof (sensorp->ess_id));
if (env_debug) {
envd_log(LOG_INFO, "\n Sensor Id %x offset %x",
@@ -1282,9 +1280,11 @@ system_temp_thr(void *args)
(wtstamp == 0 || (ct - wtstamp) >=
sensor_warning_interval)) {
envd_log(LOG_CRIT, ENV_WARNING_MSG,
- sensorp->name, sensorp->cur_temp,
- (int8_t)sensorp->es->esb_low_warning,
- (int8_t)sensorp->es->esb_high_warning);
+ sensorp->name, sensorp->cur_temp,
+ (int8_t)
+ sensorp->es->esb_low_warning,
+ (int8_t)
+ sensorp->es->esb_high_warning);
sensorp->warning_tstamp = ct;
}
@@ -1311,10 +1311,12 @@ system_temp_thr(void *args)
sensorp->shutdown_initiated = B_TRUE;
(void) snprintf(msgbuf, sizeof (msgbuf),
- ENV_SHUTDOWN_MSG, sensorp->name,
- sensorp->cur_temp,
- (int8_t)sensorp->es->esb_low_shutdown,
- (int8_t)sensorp->es->esb_high_shutdown);
+ ENV_SHUTDOWN_MSG, sensorp->name,
+ sensorp->cur_temp,
+ (int8_t)
+ sensorp->es->esb_low_shutdown,
+ (int8_t)
+ sensorp->es->esb_high_shutdown);
envd_log(LOG_ALERT, msgbuf);
@@ -1490,12 +1492,12 @@ get_disk_temp(env_disk_t *diskp)
if (env_debug) {
envd_log(LOG_ERR, "flags = 0x%x%x,curr = 0x%x,"
- "data = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
- temp_attrib->flags[0], temp_attrib->flags[1],
- temp_attrib->raw_data[0], temp_attrib->raw_data[1],
- temp_attrib->raw_data[2], temp_attrib->raw_data[3],
- temp_attrib->raw_data[4], temp_attrib->raw_data[5],
- temp_attrib->raw_data[6], temp_attrib->raw_data[7]);
+ "data = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ temp_attrib->flags[0], temp_attrib->flags[1],
+ temp_attrib->raw_data[0], temp_attrib->raw_data[1],
+ temp_attrib->raw_data[2], temp_attrib->raw_data[3],
+ temp_attrib->raw_data[4], temp_attrib->raw_data[5],
+ temp_attrib->raw_data[6], temp_attrib->raw_data[7]);
}
if (temp_attrib->raw_data[1] != 0xFF) {
diskp->current_temp = temp_attrib->raw_data[2];
@@ -1770,15 +1772,15 @@ fan_thr(void *args)
continue;
psufan_last_status = FAN_FAILED;
(void) snprintf(msgbuf, sizeof (msgbuf),
- ENV_FAN_FAILURE_WARNING_MSG, SENSOR_PSU,
- fan_rpm_string, fan_status_string);
+ ENV_FAN_FAILURE_WARNING_MSG, SENSOR_PSU,
+ fan_rpm_string, fan_status_string);
envd_log(LOG_ALERT, msgbuf);
} else {
if (psufan_last_status == FAN_OK)
continue;
psufan_last_status = FAN_OK;
(void) snprintf(msgbuf, sizeof (msgbuf),
- ENV_FAN_OK_MSG, SENSOR_PSU);
+ ENV_FAN_OK_MSG, SENSOR_PSU);
envd_log(LOG_ALERT, msgbuf);
}
}