I noticed that powernowd init script is not doing what the documentation
says it will do. I can't see it load the powernowd daemon with the
default configuration. I tried "ps -e|grep powernowd" and was puzzled
why it won't start. Skimmed all logs for errors and found none.

As written the default behavior is to not start powernowd daemon (looks
like ondemand can be set on 99% of PCs). Which is counter-intuitive and
as such it should be spelled out in the docs. It should also print some
notice to the logs if "ondemand" is used so it will be clear why
powernowd is not running. After all, one would expect powernowd daemon
to run if you install powernowd package!

Also, there is a "problem" with this code:
use_ondemand() {
        if [ "$OPTIONS" != "-q" ]; then
            return 1
        fi
...
This logic does not make sense when you first look at it. Using option to be 
quiet as a flag to enable ondemand? Bug?? Same as #3 I thought there is an 
error in the code. I tried something like #3 suggested 
(PREFER_ONDEMAND_IF_SUPPORTED='true'), though I came up with "USE_ONDEMAND" 
name.

Only 5 minutes later I realized that there is probably some reason behind it. 
After following that hidden reasoning I understand the code now and see how it 
"makes sense". It goes as follows:
- If we want the default behavior (-q), then we will try ondemand and if 
successfull, will not start the powernowd. Since if we were to start "powernowd 
-q" it will be quiet anyway, so ondemand will be a "transparent" default 
substitution. If kernel can govern cpu by itself we are better off with it in 
ondemand mode.
- If the default option is changed, then we will not try ondemand and load 
powernowd, giving the user what he wants.

Here's the brush. I found it many times even with my own "smart" code
that I can not understand the logic behind it just few months after I
wrote it. Therefore now I heavily comment all such places. The code
above is such a case and many pople will be looking at it and some will
be not able to deduce the reasoning and think the code is broken. Open
source power is in people reading the code.

It makes more sense to either a). comment on the logic to use the code
above; or b). make more readable code, use another option to
enable/disable, e.g. USE_ONDEMAND, instead of inferring it (and make it
the default):

use_ondemand() {
        if [ "x$USE_ONDEMAND" != "xyes" ]; then
            return 1
        fi
...

Also, to reiterate - ammending the docs and logging that ondemand is
used are good to have too.

-- 
powernowd doesn't start with init script
https://bugs.launchpad.net/bugs/153186
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to