From nobody@FreeBSD.org  Wed Jul 11 02:48:52 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 19AAA106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 02:48:52 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 044288FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 02:48:52 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6B2mper078754
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Jul 2012 02:48:51 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6B2mplM078753;
	Wed, 11 Jul 2012 02:48:51 GMT
	(envelope-from nobody)
Message-Id: <201207110248.q6B2mplM078753@red.freebsd.org>
Date: Wed, 11 Jul 2012 02:48:51 GMT
From: Axel Gonzalez <loox@e-shell.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] powerd doesn't honor the -n flag
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: freebsd-acpi@FreeBSD.org

>Number:         169779
>Category:       bin
>Synopsis:       [patch] powerd(8) doesn't honor the -n flag
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    brueffer
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 11 02:50:10 UTC 2012
>Closed-Date:    Tue Feb 25 09:00:37 CET 2014
>Last-Modified:  Tue Feb 25 09:00:37 CET 2014
>Originator:     Axel Gonzalez
>Release:        9.0-RELEASE-p2
>Organization:
>Environment:
FreeBSD moonlight 9.0-RELEASE-p2 FreeBSD 9.0-RELEASE-p2 #0: Tue Jun 12 02:12:57 CDT 2012     toor@moonlight:/usr/obj/usr/src/sys/LXCORE964  amd64
>Description:
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.

>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

>Fix:
Initialize the variable

--- powerd.c.orig       2012-07-10 21:21:07.882970887 -0500
+++ powerd.c    2012-07-10 21:22:29.292974203 -0500
@@ -278,6 +278,7 @@
 acline_init(void)
 {
        acline_mib_len = 4;
+        acline_status = SRC_UNKNOWN;
 
        if (sysctlnametomib(ACPIAC, acline_mib, &acline_mib_len) == 0) {
                acline_mode = ac_sysctl;


>Release-Note:
>Audit-Trail:

From: John Baldwin <jhb@freebsd.org>
To: freebsd-amd64@freebsd.org
Cc: Axel Gonzalez <loox@e-shell.net>,
 freebsd-gnats-submit@freebsd.org,
 acpi@freebsd.org
Subject: Re: amd64/169779: [patch] powerd doesn't honor the -n flag
Date: Thu, 12 Jul 2012 07:40:09 -0400

 I suspect this is correct, but cc'ing acpi@ to see if anyone there has any 
 comments.
 
 -- 
 John Baldwin
Responsible-Changed-From-To: freebsd-amd64->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Jul 16 03:12:31 UTC 2012 
Responsible-Changed-Why:  
reclassify. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169779 
State-Changed-From-To: open->patched 
State-Changed-By: brueffer 
State-Changed-When: Tue Feb 11 16:17:12 CET 2014 
State-Changed-Why:  
Committed. thanks!  Sorry for the long waiting time. 


Responsible-Changed-From-To: freebsd-bugs->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Tue Feb 11 16:17:12 CET 2014 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169779 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/169779: commit references a PR
Date: Tue, 11 Feb 2014 15:16:57 +0000 (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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/169779: commit references a PR
Date: Tue, 25 Feb 2014 07:59:40 +0000 (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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/169779: commit references a PR
Date: Tue, 25 Feb 2014 07:57:24 +0000 (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"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/169779: commit references a PR
Date: Tue, 25 Feb 2014 07:55:11 +0000 (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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: brueffer 
State-Changed-When: Tue Feb 25 09:00:13 CET 2014 
State-Changed-Why:  
Merge to stable branches done. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=169779 
>Unformatted:
