Bug 169779 - [patch] powerd(8) doesn't honor the -n flag
Summary: [patch] powerd(8) doesn't honor the -n flag
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Christian Brueffer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-11 03:50 UTC by Axel Gonzalez
Modified: 2014-02-25 08:00 UTC (History)
0 users

See Also:


Attachments
file.diff (335 bytes, patch)
2012-07-11 03:50 UTC, Axel Gonzalez
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Gonzalez 2012-07-11 03:50:10 UTC
powerd never initializes the variable that keeps the status of the line status. This variable defaults to 0 (with the compiler? with the arch?) and results in powerd using the AC profile.

This is a problem, since at start it says it is in unkown status, but doesn't respect the -n argument. 

Note: since the variable is not initialized, it can lead to other unexpected behaviour.

Fix: Initialize the variable
How-To-Repeat: This should use the "adaptive" profile specified by -n, but uses hiadaptive

# /usr/sbin/powerd -i 50 -r 80 -M 1800 -v -p 1000 -n adaptive
powerd: unable to determine AC line status
CPU frequency is above user-defined maximum; changing frequency to 1795 MHz
load  15%, current freq 1795 MHz ( 0), wanted freq 2094 MHz
Comment 1 John Baldwin freebsd_committer freebsd_triage 2012-07-12 12:40:09 UTC
I suspect this is correct, but cc'ing acpi@ to see if anyone there has any 
comments.

-- 
John Baldwin
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2012-07-16 04:12:31 UTC
Responsible Changed
From-To: freebsd-amd64->freebsd-bugs

reclassify.
Comment 3 dfilter service freebsd_committer freebsd_triage 2014-02-11 15:16:57 UTC
Author: brueffer
Date: Tue Feb 11 15:16:49 2014
New Revision: 261773
URL: http://svnweb.freebsd.org/changeset/base/261773

Log:
  In acline_init(), initialize ac_line to SRC_UNKNOWN.  Previously
  this could lead to the -n option effectively being ignored (in case
  ac_line happened to be 0 aka SRC_AC), or other undefined behaviour.
  
  PR:		169779
  Submitted by:	Alex Gonzalez <loox at e-shell.net>
  Reviewed by:	jhb
  MFC after:	2 weeks

Modified:
  head/usr.sbin/powerd/powerd.c

Modified: head/usr.sbin/powerd/powerd.c
==============================================================================
--- head/usr.sbin/powerd/powerd.c	Tue Feb 11 13:33:03 2014	(r261772)
+++ head/usr.sbin/powerd/powerd.c	Tue Feb 11 15:16:49 2014	(r261773)
@@ -279,6 +279,7 @@ static void
 acline_init(void)
 {
 	acline_mib_len = 4;
+	acline_status = SRC_UNKNOWN;
 
 	if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {
 		acline_mode = ac_sysctl;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 Christian Brueffer freebsd_committer freebsd_triage 2014-02-11 15:17:12 UTC
State Changed
From-To: open->patched

Committed. thanks!  Sorry for the long waiting time. 


Comment 5 Christian Brueffer freebsd_committer freebsd_triage 2014-02-11 15:17:12 UTC
Responsible Changed
From-To: freebsd-bugs->brueffer

MFC reminder.
Comment 6 dfilter service freebsd_committer freebsd_triage 2014-02-25 07:55:11 UTC
Author: brueffer
Date: Tue Feb 25 07:55:03 2014
New Revision: 262474
URL: http://svnweb.freebsd.org/changeset/base/262474

Log:
  MFC: r261773
  
  In acline_init(), initialize ac_line to SRC_UNKNOWN.  Previously
  this could lead to the -n option effectively being ignored (in case
  ac_line happened to be 0 aka SRC_AC), or other undefined behaviour.
  
  PR:		169779
  Submitted by:	Alex Gonzalez <loox at e-shell.com>
  Reviewed by:	jhb

Modified:
  stable/10/usr.sbin/powerd/powerd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/powerd/powerd.c
==============================================================================
--- stable/10/usr.sbin/powerd/powerd.c	Tue Feb 25 07:40:37 2014	(r262473)
+++ stable/10/usr.sbin/powerd/powerd.c	Tue Feb 25 07:55:03 2014	(r262474)
@@ -279,6 +279,7 @@ static void
 acline_init(void)
 {
 	acline_mib_len = 4;
+	acline_status = SRC_UNKNOWN;
 
 	if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {
 		acline_mode = ac_sysctl;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 7 dfilter service freebsd_committer freebsd_triage 2014-02-25 07:57:24 UTC
Author: brueffer
Date: Tue Feb 25 07:57:17 2014
New Revision: 262475
URL: http://svnweb.freebsd.org/changeset/base/262475

Log:
  MFC: r261773
  
  In acline_init(), initialize ac_line to SRC_UNKNOWN.  Previously
  this could lead to the -n option effectively being ignored (in case
  ac_line happened to be 0 aka SRC_AC), or other undefined behaviour.
  
  PR:		169779
  Submitted by:	Alex Gonzalez <loox at e-shell.com>
  Reviewed by:	jhb

Modified:
  stable/9/usr.sbin/powerd/powerd.c
Directory Properties:
  stable/9/usr.sbin/powerd/   (props changed)

Modified: stable/9/usr.sbin/powerd/powerd.c
==============================================================================
--- stable/9/usr.sbin/powerd/powerd.c	Tue Feb 25 07:55:03 2014	(r262474)
+++ stable/9/usr.sbin/powerd/powerd.c	Tue Feb 25 07:57:17 2014	(r262475)
@@ -278,6 +278,7 @@ static void
 acline_init(void)
 {
 	acline_mib_len = 4;
+	acline_status = SRC_UNKNOWN;
 
 	if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {
 		acline_mode = ac_sysctl;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 8 dfilter service freebsd_committer freebsd_triage 2014-02-25 07:59:40 UTC
Author: brueffer
Date: Tue Feb 25 07:59:33 2014
New Revision: 262476
URL: http://svnweb.freebsd.org/changeset/base/262476

Log:
  MFC: r261773
  
  In acline_init(), initialize ac_line to SRC_UNKNOWN.  Previously
  this could lead to the -n option effectively being ignored (in case
  ac_line happened to be 0 aka SRC_AC), or other undefined behaviour.
  
  PR:		169779
  Submitted by:	Alex Gonzalez <loox at e-shell.com>
  Reviewed by:	jhb

Modified:
  stable/8/usr.sbin/powerd/powerd.c
Directory Properties:
  stable/8/usr.sbin/powerd/   (props changed)

Modified: stable/8/usr.sbin/powerd/powerd.c
==============================================================================
--- stable/8/usr.sbin/powerd/powerd.c	Tue Feb 25 07:57:17 2014	(r262475)
+++ stable/8/usr.sbin/powerd/powerd.c	Tue Feb 25 07:59:33 2014	(r262476)
@@ -274,6 +274,7 @@ static void
 acline_init()
 {
 	acline_mib_len = 4;
+	acline_status = SRC_UNKNOWN;
 
 	if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {
 		acline_mode = ac_sysctl;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 9 Christian Brueffer freebsd_committer freebsd_triage 2014-02-25 08:00:13 UTC
State Changed
From-To: patched->closed

Merge to stable branches done.