Subject: [PATCH] Code cleanup: gaspressures.c

This patch does some cleaning up of code after the previous CCR
patch that extracted the contents of gaspressures.c form profile.c
1) Inapplicable #defines were removed
2) static function types were reinstated where practically possible.
3) comments at the start of the file were expanded a bit.

Signed-off-by: Willem Ferguson <[email protected]>

>From d343c0d418eb2542be24434df8c39827253ac759 Mon Sep 17 00:00:00 2001
From: Willem Ferguson <[email protected]>
Date: Mon, 25 Aug 2014 10:03:46 +0200
Subject: [PATCH] Code cleanup: gaspressures.c

This patch does some cleaning up of code after the previous CCR
patch that extracted the contents of gaspressures.c form profile.c
1) Inapplicable #defines were removed
2) static function types were reinstated where practically possible.
3) comments at the start of the file were expanded a bit.

Signed-off-by: Willem Ferguson <[email protected]>
---
 gaspressures.c | 25 ++++++++++---------------
 gaspressures.h |  2 ++
 profile.h      |  2 --
 3 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/gaspressures.c b/gaspressures.c
index 72ce7c8..7b299c1 100644
--- a/gaspressures.c
+++ b/gaspressures.c
@@ -9,23 +9,18 @@
  *  populate_pressure_information() -> calc_pressure_time()
  *                                  -> fill_missing_tank_pressures() -> fill_missing_segment_pressures()
  *                                                                   -> get_pr_interpolate_data()
+ *
+ *  The pr_track_t related functions below implement a linked list that is used by
+ *  the majority of the functions below. The linked list covers a part of the dive profile
+ *  for which there are no cylinder pressure data. Each element in the linked list
+ *  represents a segment between two consecutive points on the dive profile.
+ *  pr_track_t is defined in gaspressures.h
  */
 
-#include "gettext.h"
-#include <limits.h>
-#include <string.h>
-
 #include "dive.h"
 #include "display.h"
-#include "divelist.h"
-
 #include "profile.h"
 #include "gaspressures.h"
-#include "deco.h"
-#include "libdivecomputer/parser.h"
-#include "libdivecomputer/version.h"
-#include "membuffer.h"
-
 
 static pr_track_t *pr_track_alloc(int start, int t_start)
 {
@@ -102,7 +97,7 @@ static void dump_pr_track(pr_track_t **track_pr)
  * segments according to how big of a time_pressure area
  * they have.
  */
-void fill_missing_segment_pressures(pr_track_t *list)
+static void fill_missing_segment_pressures(pr_track_t *list)
 {
 	while (list) {
 		int start = list->start, end;
@@ -160,7 +155,7 @@ void dump_pr_interpolate(int i, pr_interpolate_t interpolate_pr)
 #endif
 
 
-struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur)
+static struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct plot_info *pi, int cur)
 {
 	struct pr_interpolate_struct interpolate;
 	int i;
@@ -211,7 +206,7 @@ struct pr_interpolate_struct get_pr_interpolate_data(pr_track_t *segment, struct
 	return interpolate;
 }
 
-void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_track_t **track_pr)
+static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_track_t **track_pr)
 {
 	int cyl, i;
 	struct plot_data *entry;
@@ -284,7 +279,7 @@ void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi, pr_tra
  * scale pressures, so it ends up being a unitless scaling
  * factor.
  */
-inline int calc_pressure_time(struct dive *dive, struct divecomputer *dc, struct plot_data *a, struct plot_data *b)
+static inline int calc_pressure_time(struct dive *dive, struct divecomputer *dc, struct plot_data *a, struct plot_data *b)
 {
 	int time = b->sec - a->sec;
 	int depth = (a->depth + b->depth) / 2;
diff --git a/gaspressures.h b/gaspressures.h
index e48a324..33a7c1f 100644
--- a/gaspressures.h
+++ b/gaspressures.h
@@ -27,7 +27,9 @@ struct pr_interpolate_struct {
 	int acc_pressure_time;
 };
 
+
 #ifdef __cplusplus
 }
 #endif
 #endif // GASPRESSURES_H
+
diff --git a/profile.h b/profile.h
index 67e6152..55bb396 100644
--- a/profile.h
+++ b/profile.h
@@ -81,13 +81,11 @@ int get_maxtime(struct plot_info *pi);
  * partial pressure graphs */
 int get_maxdepth(struct plot_info *pi);
 
-
 #define SENSOR_PR 0
 #define INTERPOLATED_PR 1
 #define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR]
 #define INTERPOLATED_PRESSURE(_entry) (_entry)->pressure[INTERPOLATED_PR]
 #define GET_PRESSURE(_entry) (SENSOR_PRESSURE(_entry) ? SENSOR_PRESSURE(_entry) : INTERPOLATED_PRESSURE(_entry))
-
 #define SAC_WINDOW 45 /* sliding window in seconds for current SAC calculation */
 
 #ifdef __cplusplus
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to