core: convert load-git.c to C++

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-02-28 08:42:23 +01:00 committed by Michael Keller
parent d803e42314
commit c05be40bfd
5 changed files with 126 additions and 158 deletions

View file

@ -61,7 +61,7 @@ SOURCES += subsurface-mobile-main.cpp \
core/git-access.cpp \
core/globals.cpp \
core/liquivision.c \
core/load-git.c \
core/load-git.cpp \
core/parse-xml.c \
core/parse.c \
core/picture.c \

View file

@ -124,7 +124,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
libdivecomputer.c
libdivecomputer.h
liquivision.c
load-git.c
load-git.cpp
membuffer.cpp
membuffer.h
metadata.cpp

View file

@ -86,13 +86,13 @@ const char *cylinderuse_text[NUM_GAS_USE] = {
QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
};
int cylinderuse_from_text(const char *text)
enum cylinderuse cylinderuse_from_text(const char *text)
{
for (enum cylinderuse i = 0; i < NUM_GAS_USE; i++) {
if (same_string(text, cylinderuse_text[i]) || same_string(text, translate("gettextFromC", cylinderuse_text[i])))
return i;
}
return -1;
return (enum cylinderuse)-1;
}
/* Add a metric or an imperial tank info structure. Copies the passed-in string. */

View file

@ -70,7 +70,7 @@ struct weightsystem_table {
#define MAX_WS_INFO (100)
extern int cylinderuse_from_text(const char *text);
extern enum cylinderuse cylinderuse_from_text(const char *text);
extern void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d);
extern void copy_cylinders(const struct cylinder_table *s, struct cylinder_table *d);
extern weightsystem_t clone_weightsystem(weightsystem_t ws);

View file

@ -153,11 +153,11 @@ static duration_t get_duration(const char *line)
static enum divemode_t get_dctype(const char *line)
{
for (enum divemode_t i = 0; i < NUM_DIVEMODE; i++) {
for (int i = 0; i < NUM_DIVEMODE; i++) {
if (strcmp(line, divemode_text[i]) == 0)
return i;
return (divemode_t)i;
}
return 0;
return (divemode_t)0;
}
static int get_index(const char *line)
@ -166,9 +166,8 @@ static int get_index(const char *line)
static int get_hex(const char *line)
{ return strtoul(line, NULL, 16); }
static void parse_dive_gps(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dive_gps(char *line, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
location_t location;
struct dive_site *ds = get_dive_site_for_dive(state->active_dive);
@ -190,9 +189,8 @@ static void parse_dive_gps(char *line, struct membuffer *str, struct git_parser_
}
static void parse_dive_location(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dive_location(char *, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
char *name = detach_cstring(str);
struct dive_site *ds = get_dive_site_for_dive(state->active_dive);
if (!ds) {
@ -213,28 +211,27 @@ static void parse_dive_location(char *line, struct membuffer *str, struct git_pa
free(name);
}
static void parse_dive_diveguide(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->diveguide = detach_cstring(str); }
static void parse_dive_diveguide(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_dive->diveguide = detach_cstring(str); }
static void parse_dive_buddy(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->buddy = detach_cstring(str); }
static void parse_dive_buddy(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_dive->buddy = detach_cstring(str); }
static void parse_dive_suit(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->suit = detach_cstring(str); }
static void parse_dive_suit(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_dive->suit = detach_cstring(str); }
static void parse_dive_notes(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dive->notes = detach_cstring(str); }
static void parse_dive_notes(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_dive->notes = detach_cstring(str); }
static void parse_dive_divesiteid(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); add_dive_to_dive_site(state->active_dive, get_dive_site_by_uuid(get_hex(line), state->log->sites)); }
static void parse_dive_divesiteid(char *line, struct membuffer *, struct git_parser_state *state)
{ add_dive_to_dive_site(state->active_dive, get_dive_site_by_uuid(get_hex(line), state->log->sites)); }
/*
* We can have multiple tags in the membuffer. They are separated by
* NUL bytes.
*/
static void parse_dive_tags(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dive_tags(char *, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
const char *tag;
int len = str->len;
@ -255,65 +252,60 @@ static void parse_dive_tags(char *line, struct membuffer *str, struct git_parser
}
}
static void parse_dive_airtemp(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->airtemp = get_temperature(line); }
static void parse_dive_airtemp(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->airtemp = get_temperature(line); }
static void parse_dive_watertemp(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->watertemp = get_temperature(line); }
static void parse_dive_watertemp(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->watertemp = get_temperature(line); }
static void parse_dive_airpressure(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->surface_pressure = get_airpressure(line); }
static void parse_dive_airpressure(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->surface_pressure = get_airpressure(line); }
static void parse_dive_duration(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->duration = get_duration(line); }
static void parse_dive_duration(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->duration = get_duration(line); }
static void parse_dive_rating(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->rating = get_index(line); }
static void parse_dive_rating(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->rating = get_index(line); }
static void parse_dive_visibility(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->visibility = get_index(line); }
static void parse_dive_visibility(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->visibility = get_index(line); }
static void parse_dive_wavesize(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->wavesize = get_index(line); }
static void parse_dive_wavesize(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->wavesize = get_index(line); }
static void parse_dive_current(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->current = get_index(line); }
static void parse_dive_current(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->current = get_index(line); }
static void parse_dive_surge(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->surge = get_index(line); }
static void parse_dive_surge(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->surge = get_index(line); }
static void parse_dive_chill(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->chill = get_index(line); }
static void parse_dive_chill(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->chill = get_index(line); }
static void parse_dive_watersalinity(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dive->user_salinity = get_salinity(line); }
static void parse_dive_watersalinity(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dive->user_salinity = get_salinity(line); }
static void parse_dive_notrip(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dive_notrip(char *, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
UNUSED(line);
state->active_dive->notrip = true;
}
static void parse_dive_invalid(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dive_invalid(char *, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
UNUSED(line);
state->active_dive->invalid = true;
}
static void parse_site_description(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_site->description = detach_cstring(str); }
static void parse_site_description(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_site->description = detach_cstring(str); }
static void parse_site_name(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_site->name = detach_cstring(str); }
static void parse_site_name(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_site->name = detach_cstring(str); }
static void parse_site_notes(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_site->notes = detach_cstring(str); }
static void parse_site_notes(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_site->notes = detach_cstring(str); }
static void parse_site_gps(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_site_gps(char *line, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
parse_location(line, &state->active_site->location);
}
@ -322,18 +314,19 @@ static void parse_site_geo(char *line, struct membuffer *str, struct git_parser_
int origin;
int category;
sscanf(line, "cat %d origin %d \"", &category, &origin);
taxonomy_set_category(&state->active_site->taxonomy , category, mb_cstring(str), origin);
taxonomy_set_category(&state->active_site->taxonomy, (taxonomy_category)category,
mb_cstring(str), (taxonomy_origin)origin);
}
static char *remove_from_front(struct membuffer *str, int len)
{
char *prefix;
if (len >= str->len)
if ((unsigned int)len >= str->len)
return detach_cstring(str);
/* memdup() - oh well */
prefix = malloc(len);
prefix = (char *)malloc(len);
if (!prefix) {
report_error("git-load: out of memory");
return NULL;
@ -390,7 +383,7 @@ static char *parse_keyvalue_entry(void (*fn)(void *, const char *, const char *)
static void parse_cylinder_keyvalue(void *_cylinder, const char *key, const char *value)
{
cylinder_t *cylinder = _cylinder;
cylinder_t *cylinder = (cylinder *)_cylinder;
if (!strcmp(key, "vol")) {
cylinder->type.size = get_volume(value);
return;
@ -462,7 +455,7 @@ static void parse_dive_cylinder(char *line, struct membuffer *str, struct git_pa
static void parse_weightsystem_keyvalue(void *_ws, const char *key, const char *value)
{
weightsystem_t *ws = _ws;
weightsystem_t *ws = (wightsystem *)_ws;
if (!strcmp(key, "weight")) {
ws->weight = get_weight(value);
return;
@ -518,9 +511,9 @@ static int match_action(char *line, struct membuffer *str, void *data,
struct keyword_action *a = action + mid;
int cmp = strcmp(line, a->keyword);
if (!cmp) { // attribute found:
a->fn(p, str, data); // Execute appropriate function,
return 0; // .. passing 2n word from above
} // (p) as a function argument.
a->fn(p, str, (git_parser_state *)data); // Execute appropriate function,
return 0; // .. passing 2n word from above
} // (p) as a function argument.
if (cmp < 0)
high = mid;
else
@ -533,7 +526,7 @@ report_error("Unmatched action '%s'", line);
/* FIXME! We should do the array thing here too. */
static void parse_sample_keyvalue(void *_sample, const char *key, const char *value)
{
struct sample *sample = _sample;
struct sample *sample = (sample *)_sample;
if (!strcmp(key, "sensor")) {
sample->sensor[0] = atoi(value);
@ -729,57 +722,55 @@ static void sample_parser(char *line, struct git_parser_state *state)
finish_sample(state->active_dc);
}
static void parse_dc_airtemp(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->airtemp = get_temperature(line); }
static void parse_dc_airtemp(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->airtemp = get_temperature(line); }
static void parse_dc_date(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); update_date(&state->active_dc->when, line); }
static void parse_dc_date(char *line, struct membuffer *, struct git_parser_state *state)
{ update_date(&state->active_dc->when, line); }
static void parse_dc_deviceid(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_dc_deviceid(char *line, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
int id = get_hex(line);
UNUSED(id); // legacy
get_hex(line); // legacy
}
static void parse_dc_diveid(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->diveid = get_hex(line); }
static void parse_dc_diveid(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->diveid = get_hex(line); }
static void parse_dc_duration(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->duration = get_duration(line); }
static void parse_dc_duration(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->duration = get_duration(line); }
static void parse_dc_dctype(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->divemode = get_dctype(line); }
static void parse_dc_dctype(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->divemode = get_dctype(line); }
static void parse_dc_lastmanualtime(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->last_manual_time = get_duration(line); }
static void parse_dc_lastmanualtime(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->last_manual_time = get_duration(line); }
static void parse_dc_maxdepth(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->maxdepth = get_depth(line); }
static void parse_dc_maxdepth(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->maxdepth = get_depth(line); }
static void parse_dc_meandepth(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->meandepth = get_depth(line); }
static void parse_dc_meandepth(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->meandepth = get_depth(line); }
static void parse_dc_model(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_dc->model = detach_cstring(str); }
static void parse_dc_model(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_dc->model = detach_cstring(str); }
static void parse_dc_numberofoxygensensors(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->no_o2sensors = get_index(line); }
static void parse_dc_numberofoxygensensors(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->no_o2sensors = get_index(line); }
static void parse_dc_surfacepressure(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->surface_pressure = get_pressure(line); }
static void parse_dc_surfacepressure(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->surface_pressure = get_pressure(line); }
static void parse_dc_salinity(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->salinity = get_salinity(line); }
static void parse_dc_salinity(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->salinity = get_salinity(line); }
static void parse_dc_surfacetime(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->surfacetime = get_duration(line); }
static void parse_dc_surfacetime(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->surfacetime = get_duration(line); }
static void parse_dc_time(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); update_time(&state->active_dc->when, line); }
static void parse_dc_time(char *line, struct membuffer *, struct git_parser_state *state)
{ update_time(&state->active_dc->when, line); }
static void parse_dc_watertemp(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(str); state->active_dc->watertemp = get_temperature(line); }
static void parse_dc_watertemp(char *line, struct membuffer *, struct git_parser_state *state)
{ state->active_dc->watertemp = get_temperature(line); }
static int get_divemode(const char *divemodestring) {
@ -806,7 +797,7 @@ struct parse_event {
static void parse_event_keyvalue(void *_parse, const char *key, const char *value)
{
struct parse_event *parse = _parse;
struct parse_event *parse = (parse_event *)_parse;
int val = atoi(value);
if (!strcmp(key, "type")) {
@ -903,48 +894,39 @@ static void parse_dc_event(char *line, struct membuffer *str, struct git_parser_
}
/* Not needed anymore - trip date calculated implicitly from first dive */
static void parse_trip_date(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); UNUSED(str); UNUSED(state); }
static void parse_trip_date(char *, struct membuffer *, struct git_parser_state *)
{ }
/* Not needed anymore - trip date calculated implicitly from first dive */
static void parse_trip_time(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); UNUSED(str); UNUSED(state); }
static void parse_trip_time(char *, struct membuffer *, struct git_parser_state *)
{ }
static void parse_trip_location(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_trip->location = detach_cstring(str); }
static void parse_trip_location(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_trip->location = detach_cstring(str); }
static void parse_trip_notes(char *line, struct membuffer *str, struct git_parser_state *state)
{ UNUSED(line); state->active_trip->notes = detach_cstring(str); }
static void parse_trip_notes(char *, struct membuffer *str, struct git_parser_state *state)
{ state->active_trip->notes = detach_cstring(str); }
static void parse_settings_autogroup(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_settings_autogroup(char *, struct membuffer *, struct git_parser_state *state)
{
UNUSED(line);
UNUSED(str);
state->log->autogroup = true;
}
static void parse_settings_units(char *line, struct membuffer *str, struct git_parser_state *unused)
static void parse_settings_units(char *line, struct membuffer *, struct git_parser_state *)
{
UNUSED(str);
UNUSED(unused);
if (line)
set_informational_units(line);
}
static void parse_settings_userid(char *line, struct membuffer *str, struct git_parser_state *_unused)
static void parse_settings_userid(char *, struct membuffer *, struct git_parser_state *)
/* Keep this despite removal of the webservice as there are legacy logbook around
* that still have this defined.
*/
{
UNUSED(str);
UNUSED(_unused);
UNUSED(line);
}
static void parse_settings_prefs(char *line, struct membuffer *str, struct git_parser_state *unused)
static void parse_settings_prefs(char *line, struct membuffer *, struct git_parser_state *)
{
UNUSED(str);
UNUSED(unused);
if (line)
set_git_prefs(line);
}
@ -956,10 +938,8 @@ static void parse_settings_prefs(char *line, struct membuffer *str, struct git_p
* We MUST keep this in sync with the XML version (so we can report a consistent
* minimum datafile version)
*/
static void parse_settings_version(char *line, struct membuffer *str, struct git_parser_state *_unused)
static void parse_settings_version(char *line, struct membuffer *, struct git_parser_state *)
{
UNUSED(str);
UNUSED(_unused);
int version = atoi(line);
report_datafile_version(version);
if (version > DATAFORMAT_VERSION)
@ -967,11 +947,8 @@ static void parse_settings_version(char *line, struct membuffer *str, struct git
}
/* The string in the membuffer is the version string of subsurface that saved things, just FYI */
static void parse_settings_subsurface(char *line, struct membuffer *str, struct git_parser_state *_unused)
static void parse_settings_subsurface(char *, struct membuffer *, struct git_parser_state *)
{
UNUSED(line);
UNUSED(str);
UNUSED(_unused);
}
struct divecomputerid {
@ -984,7 +961,7 @@ struct divecomputerid {
static void parse_divecomputerid_keyvalue(void *_cid, const char *key, const char *value)
{
struct divecomputerid *cid = _cid;
struct divecomputerid *cid = (divecomputerid *)_cid;
// Ignored legacy fields
if (!strcmp(key, "firmware"))
@ -1039,7 +1016,7 @@ struct fingerprint_helper {
static void parse_fingerprint_keyvalue(void *_fph, const char *key, const char *value)
{
struct fingerprint_helper *fph = _fph;
struct fingerprint_helper *fph = (fingerprint_helper *)_fph;
if (!strcmp(key, "model")) {
fph->model = get_hex(value);
@ -1082,26 +1059,21 @@ static void parse_settings_fingerprint(char *line, struct membuffer *str, struct
fph.hex_data, fph.fdeviceid, fph.fdiveid);
}
static void parse_picture_filename(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_picture_filename(char *, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
state->active_pic.filename = detach_cstring(str);
}
static void parse_picture_gps(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_picture_gps(char *line, struct membuffer *, struct git_parser_state *state)
{
UNUSED(str);
parse_location(line, &state->active_pic.location);
}
static void parse_picture_hash(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_picture_hash(char *, struct membuffer *, struct git_parser_state *)
{
// we no longer use hashes to identify pictures, but we shouldn't
// remove this parser lest users get an ugly red warning when
// opening old git repos
UNUSED(line);
UNUSED(state);
UNUSED(str);
}
/* These need to be sorted! */
@ -1187,7 +1159,7 @@ static void picture_parser(char *line, struct membuffer *str, struct git_parser_
static void parse_filter_preset_constraint_keyvalue(void *_state, const char *key, const char *value)
{
struct git_parser_state *state = _state;
struct git_parser_state *state = (git_parser_state *)_state;
if (!strcmp(key, "type")) {
free(state->filter_constraint_type);
state->filter_constraint_type = strdup(value);
@ -1242,7 +1214,7 @@ static void parse_filter_preset_constraint(char *line, struct membuffer *str, st
static void parse_filter_preset_fulltext_keyvalue(void *_state, const char *key, const char *value)
{
struct git_parser_state *state = _state;
struct git_parser_state *state = (git_parser_state *)_state;
if (!strcmp(key, "mode")) {
free(state->fulltext_mode);
state->fulltext_mode = strdup(value);
@ -1275,9 +1247,8 @@ static void parse_filter_preset_fulltext(char *line, struct membuffer *str, stru
state->fulltext_query = NULL;
}
static void parse_filter_preset_name(char *line, struct membuffer *str, struct git_parser_state *state)
static void parse_filter_preset_name(char *, struct membuffer *str, struct git_parser_state *state)
{
UNUSED(line);
filter_preset_set_name(state->active_filter, detach_cstring(str));
}
@ -1417,7 +1388,7 @@ static unsigned parse_one_line(const char *buf, unsigned size, line_fn_t *fn, st
*/
static void for_each_line(git_blob *blob, line_fn_t *fn, struct git_parser_state *state)
{
const char *content = git_blob_rawcontent(blob);
const char *content = (const char *)git_blob_rawcontent(blob);
unsigned int size = git_blob_rawsize(blob);
struct membuffer str = { 0 };
@ -1587,10 +1558,8 @@ static int dive_directory(const char *root, const git_tree_entry *entry, const c
return GIT_WALK_OK;
}
static int picture_directory(const char *root, const char *name, struct git_parser_state *state)
static int picture_directory(const char *, const char *, struct git_parser_state *state)
{
UNUSED(root);
UNUSED(name);
if (!state->active_dive)
return GIT_WALK_SKIP;
return GIT_WALK_OK;
@ -1711,7 +1680,7 @@ static struct divecomputer *create_new_dc(struct dive *dive)
dc = dc->next;
/* Did we already fill that in? */
if (dc->samples || dc->model || dc->when) {
struct divecomputer *newdc = calloc(1, sizeof(*newdc));
struct divecomputer *newdc = (divecomputer *)calloc(1, sizeof(*newdc));
if (!newdc)
return NULL;
dc->next = newdc;
@ -1728,9 +1697,8 @@ static struct divecomputer *create_new_dc(struct dive *dive)
* cheap, but the loading of the git blob into memory can be pretty
* costly.
*/
static int parse_divecomputer_entry(struct git_parser_state *state, const git_tree_entry *entry, const char *suffix)
static int parse_divecomputer_entry(struct git_parser_state *state, const git_tree_entry *entry, const char *)
{
UNUSED(suffix);
git_blob *blob = git_tree_entry_blob(state->repo, entry);
if (!blob)
@ -1891,7 +1859,7 @@ static int walk_tree_file(const char *root, const git_tree_entry *entry, struct
static int walk_tree_cb(const char *root, const git_tree_entry *entry, void *payload)
{
struct git_parser_state *state = payload;
struct git_parser_state *state = (git_parser_state *)payload;
git_filemode_t mode = git_tree_entry_filemode(entry);
if (mode == GIT_FILEMODE_TREE)
@ -1908,13 +1876,13 @@ static int load_dives_from_tree(git_repository *repo, git_tree *tree, struct git
return 0;
}
void clear_git_id(void)
extern "C" void clear_git_id(void)
{
free((void *)saved_git_id);
saved_git_id = NULL;
}
void set_git_id(const struct git_oid *id)
extern "C" void set_git_id(const struct git_oid *id)
{
char git_id_buffer[GIT_OID_HEXSZ + 1];
@ -1956,7 +1924,7 @@ static int do_git_load(git_repository *repo, const char *branch, struct git_pars
return ret;
}
const char *get_sha(git_repository *repo, const char *branch)
extern "C" const char *get_sha(git_repository *repo, const char *branch)
{
static char git_id_buffer[GIT_OID_HEXSZ + 1];
git_commit *commit;
@ -1974,7 +1942,7 @@ const char *get_sha(git_repository *repo, const char *branch)
* If it is a git repository, we return zero for success,
* or report an error and return 1 if the load failed.
*/
int git_load_dives(struct git_info *info, struct divelog *log)
extern "C" int git_load_dives(struct git_info *info, struct divelog *log)
{
int ret;
struct git_parser_state state = { 0 };