diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-30 08:10:46 +1100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-30 08:31:53 +1100 |
commit | e3a8ed5183ed5a24e391395c9faeae03dc9e4a6a (patch) | |
tree | 6490fa5d2d135dd74b748f0fe31179411144f63f | |
parent | 468d3f28f9f1f2795960b8e8b79b9d02024e34ed (diff) | |
download | subsurface-e3a8ed5183ed5a24e391395c9faeae03dc9e4a6a.tar.gz |
Massive cleanup
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.
This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | deco.c | 10 | ||||
-rw-r--r-- | display-gtk.h | 7 | ||||
-rw-r--r-- | dive.c | 2 | ||||
-rw-r--r-- | dive.h | 3 | ||||
-rw-r--r-- | divelist.c | 42 | ||||
-rw-r--r-- | equipment.c | 20 | ||||
-rw-r--r-- | gps.c | 2 | ||||
-rw-r--r-- | gtk-gui.c | 58 | ||||
-rw-r--r-- | info.c | 8 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | planner.c | 8 | ||||
-rw-r--r-- | print.c | 10 | ||||
-rw-r--r-- | profile.c | 30 | ||||
-rw-r--r-- | statistics.c | 38 | ||||
-rw-r--r-- | uemis-downloader.c | 3 | ||||
-rw-r--r-- | uemis.c | 20 | ||||
-rw-r--r-- | windows.c | 4 |
17 files changed, 103 insertions, 164 deletions
@@ -104,9 +104,9 @@ static double tissue_tolerance_calc(const struct dive *dive) #if !GF_LOW_AT_MAXDEPTH lowest_ceiling = (buehlmann_inertgas_b * tissue_inertgas_saturation - gf_low * buehlmann_inertgas_a * buehlmann_inertgas_b) / - ((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b); - if(lowest_ceiling > gf_low_pressure_this_dive) - gf_low_pressure_this_dive = lowest_ceiling; + ((1.0 - buehlmann_inertgas_b) * gf_low + buehlmann_inertgas_b); + if (lowest_ceiling > gf_low_pressure_this_dive) + gf_low_pressure_this_dive = lowest_ceiling; #endif tissue_tolerated_ambient_pressure[ci] = (-buehlmann_inertgas_a * buehlmann_inertgas_b * (gf_high * gf_low_pressure_this_dive - gf_low * surface) - @@ -258,10 +258,10 @@ unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressur depth = rel_mbar_to_depth(pressure_delta * 1000, dive); - if(!smooth) + if (!smooth) depth = ceil(depth / DECO_STOPS_MULTIPLIER_MM) * DECO_STOPS_MULTIPLIER_MM; - if(depth > 0 && depth < buehlmann_config.last_deco_stop_in_mtr * 1000) + if (depth > 0 && depth < buehlmann_config.last_deco_stop_in_mtr * 1000) depth = buehlmann_config.last_deco_stop_in_mtr * 1000; return depth; diff --git a/display-gtk.h b/display-gtk.h index dcab97aa0..287a3e210 100644 --- a/display-gtk.h +++ b/display-gtk.h @@ -29,19 +29,15 @@ extern int subsurface_fill_device_list(GtkListStore *store); extern const char *subsurface_icon_name(void); extern void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, GtkWidget *vbox, GtkUIManager *ui_manager); -extern void quit(GtkWidget *w, gpointer data); extern gboolean on_delete(GtkWidget* w, gpointer data); extern void set_divelist_font(const char *); -extern void import_files(GtkWidget *, gpointer); extern void update_screen(void); extern void download_dialog(GtkWidget *, gpointer); extern int is_default_dive_computer_device(const char *); extern int is_default_dive_computer(const char *, const char *); extern void add_dive_cb(GtkWidget *, gpointer); -extern void report_error(GError* error); -extern int process_ui_events(void); extern void update_progressbar(progressbar_t *progress, double value); extern void update_progressbar_text(progressbar_t *progress, const char *text); @@ -60,14 +56,11 @@ extern GtkWidget *create_date_time_widget(struct tm *time, GtkWidget **cal, GtkW extern void add_string_list_entry(const char *string, GtkListStore *list); extern int match_list(GtkListStore *list, const char *string); -extern GtkWidget *dive_profile_widget(void); extern GtkWidget *dive_info_frame(void); extern GtkWidget *extended_dive_info_widget(void); extern GtkWidget *equipment_widget(int w_idx); extern GtkWidget *single_stats_widget(void); extern GtkWidget *total_stats_widget(void); -extern GtkWidget *cylinder_list_widget(int w_idx); -extern GtkWidget *weightsystem_list_widget(int w_idx); extern GtkWidget *dive_list_create(void); extern void dive_list_destroy(void); @@ -406,7 +406,7 @@ static struct event *find_previous_event(struct divecomputer *dc, struct event * if (!event->name) return NULL; while (ev && ev != event) { - if(ev->name && !strcmp(ev->name, event->name)) + if (ev->name && !strcmp(ev->name, event->name)) previous = ev; ev = ev->next; } @@ -113,9 +113,7 @@ typedef struct { } weightsystem_t; extern gboolean cylinder_nodata(cylinder_t *cyl); -extern gboolean cylinder_nosamples(cylinder_t *cyl); extern gboolean cylinder_none(void *_data); -extern gboolean no_cylinders(cylinder_t *cyl); extern gboolean no_weightsystems(weightsystem_t *ws); extern gboolean weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2); @@ -374,7 +372,6 @@ extern gboolean autogroup; #define DIVE_NEEDS_TRIP(_dive) ((_dive)->tripflag == TF_NONE) extern void add_dive_to_trip(struct dive *, dive_trip_t *); -extern void remove_dive_from_trip(struct dive *); extern void delete_single_dive(int idx); extern void add_single_dive(int idx, struct dive *dive); diff --git a/divelist.c b/divelist.c index f286eb660..5ccc4face 100644 --- a/divelist.c +++ b/divelist.c @@ -140,7 +140,7 @@ static void first_leaf(GtkTreeModel *model, GtkTreeIter *iter, int *diveidx) gtk_tree_path_free(tpath); return; } - if(!gtk_tree_view_row_expanded(GTK_TREE_VIEW(dive_list.tree_view), tpath)) + if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(dive_list.tree_view), tpath)) gtk_tree_view_expand_row(GTK_TREE_VIEW(dive_list.tree_view), tpath, FALSE); gtk_tree_path_free(tpath); gtk_tree_model_get(model, iter, DIVE_INDEX, diveidx, -1); @@ -163,7 +163,7 @@ static struct dive *dive_from_path(GtkTreePath *path) /* make sure that if we expand a summary row that is selected, the children show up as selected, too */ -void row_expanded_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data) +static void row_expanded_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data) { GtkTreeIter child; GtkTreeModel *model = MODEL(dive_list); @@ -208,7 +208,7 @@ static int selected_children(GtkTreeModel *model, GtkTreeIter *iter) /* Make sure that if we collapse a summary row with any selected children, the row shows up as selected too */ -void row_collapsed_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data) +static void row_collapsed_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data) { GtkTreeModel *model = MODEL(dive_list); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dive_list.tree_view)); @@ -873,7 +873,7 @@ GdkPixbuf *get_gps_icon(void) return gdk_pixbuf_from_pixdata(&my_pixbuf, TRUE, NULL); } -GdkPixbuf *get_gps_icon_for_dive(struct dive *dive) +static GdkPixbuf *get_gps_icon_for_dive(struct dive *dive) { if (dive_has_location(dive)) return get_gps_icon(); @@ -1143,7 +1143,7 @@ static void find_new_trip_start_time(dive_trip_t *trip) trip->when = when; } -void remove_dive_from_trip(struct dive *dive) +static void remove_dive_from_trip(struct dive *dive) { struct dive *next, **pprev; dive_trip_t *trip = dive->divetrip; @@ -1509,7 +1509,7 @@ void add_dive_cb(GtkWidget *menuitem, gpointer data) free(dive); } -void edit_trip_cb(GtkWidget *menuitem, GtkTreePath *path) +static void edit_trip_cb(GtkWidget *menuitem, GtkTreePath *path) { GtkTreeIter iter; timestamp_t when; @@ -1522,19 +1522,19 @@ void edit_trip_cb(GtkWidget *menuitem, GtkTreePath *path) gtk_tree_store_set(STORE(dive_list), &iter, DIVE_LOCATION, dive_trip->location, -1); } -void edit_selected_dives_cb(GtkWidget *menuitem, gpointer data) +static void edit_selected_dives_cb(GtkWidget *menuitem, gpointer data) { edit_multi_dive_info(NULL); } -void edit_dive_from_path_cb(GtkWidget *menuitem, GtkTreePath *path) +static void edit_dive_from_path_cb(GtkWidget *menuitem, GtkTreePath *path) { struct dive *dive = dive_from_path(path); edit_multi_dive_info(dive); } -void edit_dive_when_cb(GtkWidget *menuitem, struct dive *dive) +static void edit_dive_when_cb(GtkWidget *menuitem, struct dive *dive) { GtkWidget *dialog, *cal, *h, *m; timestamp_t when; @@ -1957,7 +1957,7 @@ static gboolean add_rowref_if_selected(GtkTreeModel *model, GtkTreePath *path, struct dive *dive; gtk_tree_model_get(MODEL(dive_list), iter, DIVE_INDEX, &idx, -1); - if (idx >=0 ) { + if (idx >=0) { dive = get_dive(idx); if (dive->selected) { /* we need to store the Row References as those @@ -1980,7 +1980,7 @@ static void remove_from_trip_cb(GtkWidget *menuitem, GtkTreePath *path) if (!gtk_tree_model_iter_parent(MODEL(dive_list), &parent, &iter)) return; gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1); - if (idx < 0 ) + if (idx < 0) return; dive = get_dive(idx); if (dive->selected) { @@ -2002,7 +2002,7 @@ static void remove_from_trip_cb(GtkWidget *menuitem, GtkTreePath *path) mark_divelist_changed(TRUE); } -void remove_trip(GtkTreePath *trippath, gboolean force_no_trip) +static void remove_trip(GtkTreePath *trippath, gboolean force_no_trip) { GtkTreeIter newiter, parent, child, *lastiter = &parent; struct dive *dive; @@ -2016,7 +2016,7 @@ void remove_trip(GtkTreePath *trippath, gboolean force_no_trip) childpath = gtk_tree_path_copy(trippath); gtk_tree_path_down(childpath); for (;;) { - if( ! gtk_tree_model_get_iter(MODEL(dive_list), &child, childpath)) + if ( ! gtk_tree_model_get_iter(MODEL(dive_list), &child, childpath)) break; gtk_tree_store_insert_after(STORE(dive_list), &newiter, NULL, lastiter); copy_tree_node(&child, &newiter); @@ -2041,7 +2041,7 @@ void remove_trip(GtkTreePath *trippath, gboolean force_no_trip) #endif } -void remove_trip_cb(GtkWidget *menuitem, GtkTreePath *trippath) +static void remove_trip_cb(GtkWidget *menuitem, GtkTreePath *trippath) { int success; GtkWidget *dialog; @@ -2063,7 +2063,7 @@ void remove_trip_cb(GtkWidget *menuitem, GtkTreePath *trippath) mark_divelist_changed(TRUE); } -void merge_trips_cb(GtkWidget *menuitem, GtkTreePath *trippath) +static void merge_trips_cb(GtkWidget *menuitem, GtkTreePath *trippath) { GtkTreePath *prevpath; GtkTreeIter thistripiter, prevtripiter; @@ -2571,14 +2571,14 @@ static void sort_column_change_cb(GtkTreeSortable *treeview, gpointer data) return; gtk_tree_sortable_get_sort_column_id(treeview, &colid, &order); - if(colid == lastcol) { + if (colid == lastcol) { /* we just changed sort order */ sortorder[colid] = order; return; } else { lastcol = colid; } - if(colid == DIVE_NR) + if (colid == DIVE_NR) dive_list.model = dive_list.treemodel; else dive_list.model = dive_list.listmodel; @@ -2613,13 +2613,13 @@ static void deselect_dive(int idx) amount_selected--; if (selected_dive == idx && amount_selected > 0) { /* pick a different dive as selected */ - while(--selected_dive >= 0) { + while (--selected_dive >= 0) { dive = get_dive(selected_dive); if (dive && dive->selected) return; } selected_dive = idx; - while(++selected_dive < dive_table.nr) { + while (++selected_dive < dive_table.nr) { dive = get_dive(selected_dive); if (dive && dive->selected) return; @@ -2630,7 +2630,7 @@ static void deselect_dive(int idx) } } -gboolean modify_selection_cb(GtkTreeSelection *selection, GtkTreeModel *model, +static gboolean modify_selection_cb(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean was_selected, gpointer userdata) { int idx; @@ -2845,7 +2845,7 @@ static GtkTreeIter *get_iter_from_idx(int idx) return iteridx.iter; } -void scroll_to_selected(GtkTreeIter *iter) +static void scroll_to_selected(GtkTreeIter *iter) { GtkTreePath *treepath; treepath = gtk_tree_model_get_path(MODEL(dive_list), iter); diff --git a/equipment.c b/equipment.c index 98162c9b9..f28050949 100644 --- a/equipment.c +++ b/equipment.c @@ -462,7 +462,7 @@ gboolean cylinder_nodata(cylinder_t *cyl) !cyl->end.mbar; } -gboolean cylinder_nosamples(cylinder_t *cyl) +static gboolean cylinder_nosamples(cylinder_t *cyl) { return !cyl->sample_start.mbar && !cyl->sample_end.mbar; @@ -474,19 +474,9 @@ gboolean cylinder_none(void *_data) return cylinder_nodata(cyl) && cylinder_nosamples(cyl); } -gboolean no_cylinders(cylinder_t *cyl) -{ - int i; - - for (i = 0; i < MAX_CYLINDERS; i++) - if (!cylinder_none(cyl + i)) - return FALSE; - return TRUE; -} - /* descriptions are equal if they are both NULL or both non-NULL and the same text */ -gboolean description_equal(const char *desc1, const char *desc2) +static gboolean description_equal(const char *desc1, const char *desc2) { return ((! desc1 && ! desc2) || (desc1 && desc2 && strcmp(desc1, desc2) == 0)); @@ -1010,7 +1000,7 @@ static void ws_widget(GtkWidget *vbox, struct ws_widget *ws_widget, GtkListStore gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0); - if ( prefs.units.weight == KG) + if (prefs.units.weight == KG) widget = create_spinbutton(hbox, _("kg"), 0, 50, 0.5); else widget = create_spinbutton(hbox, _("lbs"), 0, 110, 1); @@ -1440,7 +1430,7 @@ static void ws_row_activated_cb(GtkTreeView *tree_view, ws_edit_cb(GTK_WIDGET(tree_view), w_idx); } -GtkWidget *cylinder_list_widget(int w_idx) +static GtkWidget *cylinder_list_widget(int w_idx) { GtkListStore *model = cylinder_list[w_idx].model; GtkWidget *tree_view; @@ -1469,7 +1459,7 @@ GtkWidget *cylinder_list_widget(int w_idx) return tree_view; } -GtkWidget *weightsystem_list_widget(int w_idx) +static GtkWidget *weightsystem_list_widget(int w_idx) { GtkListStore *model = weightsystem_list[w_idx].model; GtkWidget *tree_view; @@ -111,7 +111,7 @@ static gboolean scroll_cb(GtkWidget *widget, GdkEventScroll *event, gpointer dat osm_gps_map_zoom_in(map); osm_gps_map_set_center(map, target_lat, target_lon); } else if (event->direction == GDK_SCROLL_DOWN) { - if(zoom == min_zoom) + if (zoom == min_zoom) return TRUE; target_x = event->x + ((ltx + rbx) / 2.0 - (gint)(event->x)) * 2; @@ -35,8 +35,9 @@ GtkWidget *notebook; int error_count; const char *existing_filename; -static struct device_info *nicknamelist; static struct device_info *holdnicknames = NULL; +static GtkWidget *dive_profile_widget(void); +static void import_files(GtkWidget *, gpointer); static void remember_dc(const char *model, uint32_t deviceid, const char *nickname) { @@ -57,18 +58,6 @@ static void remove_dc(const char *model, uint32_t deviceid) free(remove_device_info(model, deviceid)); } -void dump_nickname_list_entry(struct device_info *nnl){ - - printf("\n"); - printf("Address of entry is %p root is at %p\n", nnl, nicknamelist); - printf("Model = %s\n",nnl->model); - printf("Device = %x\n", nnl->deviceid); - printf("Nickname = %s\n", nnl->nickname); - printf("Address of next entry is %p\n",nnl->next); - printf("\n"); - -} - static GtkWidget *dive_profile; GtkActionGroup *action_group; @@ -338,7 +327,7 @@ static void on_destroy(GtkWidget* w, gpointer data) gtk_main_quit(); } -void quit(GtkWidget *w, gpointer data) +static void quit(GtkWidget *w, gpointer data) { /* Make sure to flush any modified dive data */ update_dive(NULL); @@ -1207,9 +1196,9 @@ static void cell_edited_cb(GtkCellRendererText *cell, gchar *path, /* remember pending commit * Need to extend list rather than wipe and store only one result */ - if(matched == 1){ + if (matched == 1){ if (holdnicknames == NULL){ - holdnicknames = (struct device_info *) malloc(sizeof( struct device_info )); + holdnicknames = (struct device_info *) malloc(sizeof(struct device_info)); holdnicknames->model = strdup(model); holdnicknames->deviceid = deviceid; holdnicknames->serial_nr = NULL; @@ -1219,7 +1208,7 @@ static void cell_edited_cb(GtkCellRendererText *cell, gchar *path, } else { struct device_info * top; struct device_info * last = holdnicknames; - top = (struct device_info *) malloc(sizeof( struct device_info )); + top = (struct device_info *) malloc(sizeof(struct device_info)); top->model = strdup(model); top->deviceid = deviceid; top->serial_nr = NULL; @@ -1248,7 +1237,7 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data) char id_string[11] = {0}; struct device_info * nnl; - dialog = gtk_dialog_new_with_buttons( _("Edit Dive Computer Nicknames"), + dialog = gtk_dialog_new_with_buttons(_("Edit Dive Computer Nicknames"), GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_DELETE, @@ -1291,7 +1280,7 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data) /* populate list store from device_info_list */ nnl = head_of_device_info_list(); - while( nnl ) { + while (nnl) { sprintf(&id_string[0], "%#08x", nnl->deviceid); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, @@ -1336,11 +1325,11 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data) mark_divelist_changed(TRUE); gtk_widget_destroy(confirm); } - if (res == GTK_RESPONSE_APPLY && holdnicknames && holdnicknames->model != NULL ) { + if (res == GTK_RESPONSE_APPLY && holdnicknames && holdnicknames->model != NULL) { struct device_info * walk = holdnicknames; struct device_info * release = holdnicknames; struct device_info * track = holdnicknames->next; - while(walk) { + while (walk) { remember_dc(walk->model, walk->deviceid, walk->nickname); walk = walk->next; } @@ -1348,7 +1337,7 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data) while (release){ free(release); release = track; - if(track) + if (track) track = track->next; } holdnicknames = NULL; @@ -1787,7 +1776,7 @@ static void zoom_event(int x, int y, double inc) zoom_factor = inc; } -gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) +static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { switch (event->direction) { case GDK_SCROLL_UP: @@ -1803,7 +1792,7 @@ gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer user_da return TRUE; } -gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data) +static gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { switch (event->button) { case 1: @@ -1818,7 +1807,7 @@ gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data) return TRUE; } -gboolean released(GtkWidget *widget, GdkEventButton *event, gpointer user_data) +static gboolean released(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { switch (event->button) { case 1: @@ -1832,7 +1821,7 @@ gboolean released(GtkWidget *widget, GdkEventButton *event, gpointer user_data) return TRUE; } -gboolean motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) +static gboolean motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { if (zoom_x < 0) return TRUE; @@ -1843,7 +1832,7 @@ gboolean motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) return TRUE; } -GtkWidget *dive_profile_widget(void) +static GtkWidget *dive_profile_widget(void) { GtkWidget *da; @@ -1863,19 +1852,6 @@ GtkWidget *dive_profile_widget(void) return da; } -int process_ui_events(void) -{ - int ret=0; - - while (gtk_events_pending()) { - if (gtk_main_iteration_do(0)) { - ret = 1; - break; - } - } - return ret; -} - static void do_import_file(gpointer data, gpointer user_data) { GError *error = NULL; @@ -1889,7 +1865,7 @@ static void do_import_file(gpointer data, gpointer user_data) } } -void import_files(GtkWidget *w, gpointer data) +static void import_files(GtkWidget *w, gpointer data) { GtkWidget *fs_dialog; const char *current_default; @@ -563,7 +563,7 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc free(rating_string); new_text = (char *)gtk_entry_get_text(info->airtemp); - if(sscanf(new_text, "%lf", &newtemp) == 1) { + if (sscanf(new_text, "%lf", &newtemp) == 1) { unsigned long mkelvin; switch (prefs.units.temperature) { case CELSIUS: @@ -619,7 +619,7 @@ struct location_update { void (*callback)(float, float); } location_update; -void print_gps_coordinates(char *buffer, int len, float lat, float lon) +static void print_gps_coordinates(char *buffer, int len, float lat, float lon) { unsigned int latdeg, londeg; float latmin, lonmin; @@ -638,7 +638,7 @@ void print_gps_coordinates(char *buffer, int len, float lat, float lon) lonh, londeg, UTF8_DEGREE, lonmin); } -void update_gps_entry(float lat, float lon) +static void update_gps_entry(float lat, float lon) { char gps_text[45]; @@ -831,7 +831,7 @@ static void update_cylinder(cylinder_t *dst, cylinder_t *src, cylinder_t *orig) data if it has changed in the master dive and the other dive either has no entries for the equipment or the same entries as the master dive had before it was edited */ -void update_equipment_data(struct dive *dive, struct dive *master) +static void update_equipment_data(struct dive *dive, struct dive *master) { int i; @@ -305,7 +305,7 @@ int main(int argc, char **argv) * so that it uses the correct system directory when * subsurface isn't run from the local directory */ path = subsurface_gettext_domainpath(argv[0]); - setlocale( LC_ALL, "" ); + setlocale(LC_ALL, ""); bindtextdomain("subsurface", path); bind_textdomain_codeset("subsurface", "utf-8"); textdomain("subsurface"); @@ -332,7 +332,7 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp) struct divedatapoint **lastdp = &diveplan->dp; struct divedatapoint *ldp = *lastdp; int lasttime = 0; - while(*lastdp) { + while (*lastdp) { ldp = *lastdp; if (ldp->time > lasttime) lasttime = ldp->time; @@ -524,7 +524,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive) he = newhe; lasttime = dp->time; lastdepth = dp->depth; - } while((dp = dp->next) != NULL); + } while ((dp = dp->next) != NULL); len = strlen(buffer); snprintf(buffer + len, sizeof(buffer) - len, _("Gas consumption:\n")); for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) { @@ -938,7 +938,7 @@ void show_planned_dive(void) memcpy(&tempplan, &diveplan, sizeof(struct diveplan)); dpp = &tempplan.dp; dp = diveplan.dp; - while(dp && *dpp) { + while (dp && *dpp) { *dpp = malloc(sizeof(struct divedatapoint)); memcpy(*dpp, dp, sizeof(struct divedatapoint)); dp = dp->next; @@ -1163,7 +1163,7 @@ static void add_waypoint_cb(GtkButton *button, gpointer _data) } static void add_entry_with_callback(GtkWidget *box, int length, char *label, char *initialtext, - gboolean (*callback)(GtkWidget *, GdkEvent *, gpointer ), gpointer data) + gboolean (*callback)(GtkWidget *, GdkEvent *, gpointer), gpointer data) { GtkWidget *entry = add_entry_to_box(box, label); gtk_entry_set_max_length(GTK_ENTRY(entry), length); @@ -227,7 +227,7 @@ static void print_tanks (struct dive *dive, cairo_t *cr, int maxwidth, int maxhe /* Then the cylinder stuff */ n = first_tank; counter = 0; - while ( n < tank_count && n < first_tank + 4) { + while (n < tank_count && n < first_tank + 4) { int decimals; const char *unit, *desc; double gas_usage; @@ -436,7 +436,7 @@ static void show_dive_tanks(struct dive *dive, cairo_t *cr, double w, maxheight = h * PANGO_SCALE * 0.9; /* We need to know how many cylinders we used*/ - for ( tank_count = 0; tank_count < MAX_CYLINDERS; tank_count++ ){ + for (tank_count = 0; tank_count < MAX_CYLINDERS; tank_count++){ if (cylinder_nodata(dive->cylinder+tank_count)) { break; } @@ -446,7 +446,7 @@ static void show_dive_tanks(struct dive *dive, cairo_t *cr, double w, if (tank_count == 0) { height = maxheight; } else { - if ( tank_count<=4 ) { + if (tank_count<=4) { height = maxheight / (tank_count + 1); } else { height = maxheight / 5; @@ -521,7 +521,7 @@ static void show_table_header(cairo_t *cr, double w, double h, curwidth = 0; for (i = 0; i < 7; i++) { cairo_move_to(cr, curwidth / PANGO_SCALE, 0); - if (i == 0 || i == 2 || i == 3 ){ + if (i == 0 || i == 2 || i == 3){ // Column 0, 2 and 3 (Dive #, Depth and Time) get 1/2 width pango_layout_set_width(layout, colwidth/ (double) 2); curwidth = curwidth + (colwidth / 2); @@ -727,7 +727,7 @@ static void print_table(int divenr, cairo_t *cr, double x, double y, cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER); cairo_stroke(cr); for (i = 0; i < 6; i++) { - if (i == 0 || i == 2 || i == 3 ){ + if (i == 0 || i == 2 || i == 3){ // Column 0, 2 and 3 (Dive #, Depth and Time) get 1/2 width curwidth = curwidth + (maxwidth/7/2); } else { @@ -3,11 +3,6 @@ * uses cairo to draw it */ #include <glib/gi18n.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <time.h> #include "dive.h" #include "display.h" @@ -173,7 +168,7 @@ void init_profile_background(struct graphics_context *gc) set_source_rgba(gc, BACKGROUND); } -void pattern_add_color_stop_rgba(struct graphics_context *gc, cairo_pattern_t *pat, double o, color_indice_t c) +static void pattern_add_color_stop_rgba(struct graphics_context *gc, cairo_pattern_t *pat, double o, color_indice_t c) { const color_t *col = &profile_color[c]; struct rgba rgb = col->media[gc->printer]; @@ -223,7 +218,7 @@ static int get_maxtime(struct plot_info *pi) * calculate the space dynamically. * This is seamless since 600/4 = 150. */ - if ( seconds < 600 ) + if (seconds < 600) return ROUND_UP(seconds+seconds/4, 60); else return ROUND_UP(seconds+150, 60); @@ -1234,8 +1229,9 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi) entry->velocity = velocity((entry[0].depth - entry[past].depth) / (entry[0].sec - entry[past].sec)); } - } else + } else { entry->velocity = STABLE; + } } /* One-, two- and three-minute minmax data */ @@ -1699,7 +1695,7 @@ static void populate_cylinder_pressure_data(int idx, int start, int end, struct } /* .. and the last entry with the ending cylinder pressure */ - for (i = pi->nr; --i >= 0; ) { + for (i = pi->nr; --i >= 0; /* nothing */) { struct plot_data *entry = pi->entry+i; if (entry->cylinderindex != idx) continue; @@ -1849,14 +1845,14 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d (entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure * N2_DENSITY + entry->phe / amb_pressure * HE_DENSITY) / (O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 -10000; - if(entry->mod <0) - entry->mod=0; - if(entry->ead <0) - entry->ead=0; - if(entry->end <0) - entry->end=0; - if(entry->eadd <0) - entry->eadd=0; + if (entry->mod < 0) + entry->mod = 0; + if (entry->ead < 0) + entry->ead = 0; + if (entry->end < 0) + entry->end = 0; + if (entry->eadd < 0) + entry->eadd = 0; if (entry->po2 > pi->maxpp && prefs.pp_graphs.po2) pi->maxpp = entry->po2; diff --git a/statistics.c b/statistics.c index c421b4051..14d83b686 100644 --- a/statistics.c +++ b/statistics.c @@ -3,19 +3,12 @@ * controlled through the following interfaces: * * void show_dive_stats(struct dive *dive) - * void flush_dive_stats_changes(struct dive *dive) * * called from gtk-ui: * GtkWidget *stats_widget(void) */ #include <glib/gi18n.h> #include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <stdarg.h> -#include <time.h> -#include <gdk/gdkkeysyms.h> #include "dive.h" #include "display.h" @@ -106,7 +99,7 @@ enum { N_COLUMNS }; -static char * get_time_string(int seconds, int maxdays); +static char *get_time_string(int seconds, int maxdays); static void process_temperatures(struct dive *dp, stats_t *stats) { @@ -251,7 +244,7 @@ static void add_cell_to_tree(GtkTreeStore *store, char *value, int index, GtkTre { gtk_tree_store_set(store, parent, index, value, -1); } -static char * get_minutes(int seconds) +static char *get_minutes(int seconds) { static char buf[80]; snprintf(buf, sizeof(buf), "%d:%.2d", FRACTION(seconds, 60)); @@ -335,7 +328,7 @@ static void process_interval_stats(stats_t stats_interval, GtkTreeIter *parent, } } -void clear_statistics() +static void clear_statistics() { GtkTreeStore *store; @@ -360,7 +353,7 @@ static void key_press_event(GtkWidget *window, GdkEventKey *event, gpointer data } } -void update_yearly_stats() +static void update_yearly_stats() { int i, j, combined_months, month = 0; GtkTreeIter year_iter, month_iter; @@ -468,9 +461,9 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) if (current_year != tm.tm_year + 1900) { current_year = tm.tm_year + 1900; process_dive(dp, &(stats_yearly[++year_iter])); - } else + } else { process_dive(dp, &(stats_yearly[year_iter])); - + } stats_yearly[year_iter].selection_size++; stats_yearly[year_iter].period = current_year; @@ -483,7 +476,6 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) if (prev_month != current_month || prev_year != current_year) month_iter++; } - process_dive(dp, &(stats_monthly[month_iter])); stats_monthly[month_iter].selection_size++; stats_monthly[month_iter].period = current_month; @@ -523,12 +515,12 @@ static void set_label(GtkWidget *w, const char *fmt, ...) gtk_label_set_text(GTK_LABEL(w), buf); } -static char * get_time_string(int seconds, int maxdays) +static char *get_time_string(int seconds, int maxdays) { static char buf[80]; - if (maxdays && seconds > 3600 * 24 * maxdays) + if (maxdays && seconds > 3600 * 24 * maxdays) { snprintf(buf, sizeof(buf), _("more than %d days"), maxdays); - else { + } else { int days = seconds / 3600 / 24; int hours = (seconds - days * 3600 * 24) / 3600; int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60; @@ -591,9 +583,9 @@ static void show_single_dive_stats(struct dive *dive) set_label(single_w.air_press, _("unknown")); } value = get_volume_units(dive->sac, &decimals, &unit); - if (value > 0) { + if (value > 0) set_label(single_w.sac, _("%.*f %s/min"), decimals, value, unit); - } else + else set_label(single_w.sac, ""); set_label(single_w.otu, "%d", dive->otu); offset = 0; @@ -626,8 +618,9 @@ static void show_single_dive_stats(struct dive *dive) if (gas_used) { value = get_volume_units(gas_used, &decimals, &unit); set_label(single_w.gas_used, "%.*f %s", decimals, value, unit); - } else + } else { set_label(single_w.gas_used, ""); + } } /* this gets called when at least two but not all dives are selected */ @@ -753,11 +746,6 @@ void show_dive_stats(struct dive *dive) show_total_dive_stats(dive); } -void flush_dive_stats_changes(struct dive *dive) -{ - /* We do nothing: we require the "Ok" button press */ -} - static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label) { GtkWidget *label_widget; diff --git a/uemis-downloader.c b/uemis-downloader.c index 8274884e6..065237971 100644 --- a/uemis-downloader.c +++ b/uemis-downloader.c @@ -202,8 +202,7 @@ static gboolean uemis_init(const char *path) #endif if (sscanf(tmp + 1, "%d", &filenr) != 1) return FALSE; - } - else { + } else { filenr = 0; #if UEMIS_DEBUG & 2 fprintf(debugfile, "::r req.txt skipped as there were fewer than 5 bytes\n"); @@ -37,21 +37,21 @@ static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$ /* * decodeblock -- decode 4 '6-bit' characters into 3 8-bit binary bytes */ -static void decodeblock( unsigned char in[4], unsigned char out[3] ) { - out[ 0 ] = (unsigned char ) (in[0] << 2 | in[1] >> 4); - out[ 1 ] = (unsigned char ) (in[1] << 4 | in[2] >> 2); - out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | in[3]); +static void decodeblock (unsigned char in[4], unsigned char out[3]) { + out[0] = (unsigned char) (in[0] << 2 | in[1] >> 4); + out[1] = (unsigned char) (in[1] << 4 | in[2] >> 2); + out[2] = (unsigned char) (((in[2] << 6) & 0xc0) | in[3]); } /* * decode a base64 encoded stream discarding padding, line breaks and noise */ -static void decode( uint8_t *inbuf, uint8_t *outbuf, int inbuf_len ) { +static void decode(uint8_t *inbuf, uint8_t *outbuf, int inbuf_len) { uint8_t in[4], out[3], v; int i,len,indx_in=0,indx_out=0; while (indx_in < inbuf_len) { - for (len = 0, i = 0; i < 4 && (indx_in < inbuf_len); i++ ) { + for (len = 0, i = 0; i < 4 && (indx_in < inbuf_len); i++) { v = 0; while ((indx_in < inbuf_len) && v == 0) { v = inbuf[indx_in++]; @@ -67,9 +67,9 @@ static void decode( uint8_t *inbuf, uint8_t *outbuf, int inbuf_len ) { else in[i] = 0; } - if( len ) { - decodeblock( in, out ); - for( i = 0; i < len - 1; i++ ) + if (len) { + decodeblock(in, out); + for(i = 0; i < len - 1; i++) outbuf[indx_out++] = out[i]; } } @@ -119,7 +119,7 @@ static struct uemis_helper *uemis_get_helper(int diveid) struct uemis_helper **php = &uemis_helper; struct uemis_helper *hp = *php; - while(hp) { + while (hp) { if (hp->diveid == diveid) return hp; if (hp->next) { @@ -17,7 +17,7 @@ static int get_from_registry(HKEY hkey, const char *key) LONG success; success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL, - (LPBYTE) &value, (LPDWORD)&len ); + (LPBYTE) &value, (LPDWORD)&len); if (success != ERROR_SUCCESS) return -1; return value != 0; @@ -97,7 +97,7 @@ const void *subsurface_get_conf(char *name) return NULL; blen = 0; /* lest try to load the string in chunks of 'csize' bytes until it fits */ - while(ret == ERROR_MORE_DATA) { + while (ret == ERROR_MORE_DATA) { blen += csize; wstring = (wchar_t *)realloc(wstring, blen * sizeof(wchar_t)); ret = RegQueryValueExW(hkey, (LPCWSTR)wname, NULL, NULL, |