Module Name:    src
Committed By:   pgoyette
Date:           Wed Dec  8 00:09:14 UTC 2010

Modified Files:
        src/sys/dev/sysmon: sysmon_envsys.c sysmon_envsys_events.c

Log Message:
When removing properties (as in envstat -S), clear the flags that track
whether the properties actually exist.

When setting new limit values, don't complain/ignore about duplicate
values if the associated flag bits (indicating that the limit is valid)
are not set.

These two fixes together should fix a problem reported in private Email
by njoly@ a couple months ago.  Issue replicated and solution tested
using my recent swsensor pseudo-device running inside qemu world!


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/sysmon/sysmon_envsys.c
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/sysmon/sysmon_envsys_events.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.107 src/sys/dev/sysmon/sysmon_envsys.c:1.108
--- src/sys/dev/sysmon/sysmon_envsys.c:1.107	Sun Apr 11 01:12:28 2010
+++ src/sys/dev/sysmon/sysmon_envsys.c	Wed Dec  8 00:09:14 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.107 2010/04/11 01:12:28 pgoyette Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.108 2010/12/08 00:09:14 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.107 2010/04/11 01:12:28 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.108 2010/12/08 00:09:14 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -1143,8 +1143,10 @@
 				lims = edata->limits;
 				(*sme->sme_get_limits)(sme, edata, &lims,
 						       &edata->upropset);
-			}
-			if (edata->upropset) {
+			} else
+				edata->upropset &= ~PROP_LIMITS;
+
+			if (edata->upropset & PROP_LIMITS) {
 				DPRINTF(("%s: install limits for %s %s\n",
 					__func__, sme->sme_name, edata->desc));
 				sme_update_limits(sme, edata);

Index: src/sys/dev/sysmon/sysmon_envsys_events.c
diff -u src/sys/dev/sysmon/sysmon_envsys_events.c:1.94 src/sys/dev/sysmon/sysmon_envsys_events.c:1.95
--- src/sys/dev/sysmon/sysmon_envsys_events.c:1.94	Mon Dec  6 23:26:44 2010
+++ src/sys/dev/sysmon/sysmon_envsys_events.c	Wed Dec  8 00:09:14 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.94 2010/12/06 23:26:44 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.95 2010/12/08 00:09:14 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.94 2010/12/06 23:26:44 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.95 2010/12/08 00:09:14 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -151,29 +151,28 @@
 		    __func__, sme->sme_name, edata->desc, crittype));
 
 		see = osee;
-		if (props & (PROP_CRITMAX | PROP_BATTMAX)) {
+		if (props & edata->upropset & (PROP_CRITMAX | PROP_BATTMAX)) {
 			if (lims->sel_critmax == edata->limits.sel_critmax) {
-				DPRINTF(("%s: type=%d (critmax exists)\n",
-				    __func__, crittype));
+				DPRINTF(("%s: critmax exists\n", __func__));
 				error = EEXIST;
 				props &= ~(PROP_CRITMAX | PROP_BATTMAX);
 			}
 		}
-		if (props & (PROP_WARNMAX | PROP_BATTHIGH)) {
+		if (props & edata->upropset & (PROP_WARNMAX | PROP_BATTHIGH)) {
 			if (lims->sel_warnmax == edata->limits.sel_warnmax) {
 				DPRINTF(("%s: warnmax exists\n", __func__));
 				error = EEXIST;
 				props &= ~(PROP_WARNMAX | PROP_BATTHIGH);
 			}
 		}
-		if (props & (PROP_WARNMIN | PROP_BATTWARN)) {
+		if (props & edata->upropset & (PROP_WARNMIN | PROP_BATTWARN)) {
 			if (lims->sel_warnmin == edata->limits.sel_warnmin) {
 				DPRINTF(("%s: warnmin exists\n", __func__));
 				error = EEXIST;
 				props &= ~(PROP_WARNMIN | PROP_BATTWARN);
 			}
 		}
-		if (props & (PROP_CRITMIN | PROP_BATTCAP)) {
+		if (props & edata->upropset & (PROP_CRITMIN | PROP_BATTCAP)) {
 			if (lims->sel_critmin == edata->limits.sel_critmin) {
 				DPRINTF(("%s: critmin exists\n", __func__));
 				error = EEXIST;

Reply via email to