diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-18 19:51:48 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-18 20:25:45 -0400 |
commit | d14932058f191de2a812a9b3b9ad87c5febd2b3e (patch) | |
tree | a903417419c3bb80a8dde5b6b708bda5bf567a38 /equipment.c | |
parent | f73e5b726808675ec3a02fe57f063b666e0706ac (diff) | |
download | subsurface-d14932058f191de2a812a9b3b9ad87c5febd2b3e.tar.gz |
Fix some of the problems reported by cppcheck
Thanks to Christian for running the static code analysis tool against
subsurface...
There were some false positives, a few style issues that I'll ignore for
now, and two actual potential bugs.
First: Don't check unsigned variables for < 0
This has been around for a while and we are lucky that while technically a
bug it still works as expected. Passing a negative idx simply turns it
into a very large unsigned integer which then fails the > dive_table.nr
test. So it still gets a NULL returned. A bug? Yes. Critical? No.
Mismatched allocation and free
This is an actual bug that potentially could cause issues. We allocate
memory with malloc and free it with g_free. Not good.
Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'equipment.c')
-rw-r--r-- | equipment.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/equipment.c b/equipment.c index adfb02989..fc31d9729 100644 --- a/equipment.c +++ b/equipment.c @@ -96,13 +96,13 @@ static void convert_volume_pressure(int ml, int mbar, double *v, double *p) volume *= bar_to_atm(mbar / 1000.0); } - if (output_units.pressure == PSI) { + if (output_units.pressure == PSI) pressure = mbar_to_PSI(mbar); - } else + else pressure = mbar / 1000.0; + *p = pressure; } *v = volume; - *p = pressure; } static int convert_weight(int grams, double *m) |