[Nut-upsdev] [PATCH] Fix logic error in rhino driver

Thomas Jarosch thomas.jarosch at intra2net.com
Fri Oct 14 15:11:41 UTC 2011


The if() statement always evaluated to true.
Detected by "cppcheck", not tested on real hardware.

Signed-off-by: Thomas Jarosch <thomas.jarosch at intra2net.com>
---
 drivers/rhino.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/rhino.c b/drivers/rhino.c
index ca66169..e478bcb 100644
--- a/drivers/rhino.c
+++ b/drivers/rhino.c
@@ -187,7 +187,7 @@ AutonomyCalc( int ia ) /* all models */
     {
       currin = ( UtilPowerOut + ConstInt ) *1.0 / Vin;
       auton = ( ( ( AmpH *1.0 / currin ) * 60 * ( ( BattVoltage - VbatMin ) * 1.0 /( VbatNom - VbatMin ) ) * FM ) + FA );
-      if(  ( BattVoltage > 129 ) || ( BattVoltage < 144 ) )
+      if(  ( BattVoltage > 129 ) && ( BattVoltage < 144 ) )
 	result = 133;
       else
 	result = (int) auton;
-- 
1.7.4.4




More information about the Nut-upsdev mailing list