diff --git a/core/cochran.cpp b/core/cochran.cpp index 1269ae919..ea8be2dc9 100644 --- a/core/cochran.cpp +++ b/core/cochran.cpp @@ -711,9 +711,9 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod, dc->duration.seconds = (log[CMD_BT] + log[CMD_BT + 1] * 256) * 60; dc->surfacetime.seconds = (log[CMD_SIT] + log[CMD_SIT + 1] * 256) * 60; dc->maxdepth.mm = lrint((log[CMD_MAX_DEPTH] + - log[CMD_MAX_DEPTH + 1] * 256) / 4 * FEET * 1000); + log[CMD_MAX_DEPTH + 1] * 256) / 4.0 * FEET * 1000); dc->meandepth.mm = lrint((log[CMD_AVG_DEPTH] + - log[CMD_AVG_DEPTH + 1] * 256) / 4 * FEET * 1000); + log[CMD_AVG_DEPTH + 1] * 256) / 4.0 * FEET * 1000); dc->watertemp.mkelvin = F_to_mkelvin(log[CMD_MIN_TEMP]); dc->surface_pressure.mbar = lrint(ATM / BAR * pow(1 - 0.0000225577 * (double) log[CMD_ALTITUDE] * 250 * FEET, 5.25588) * 1000); @@ -757,9 +757,9 @@ static void cochran_parse_dive(const unsigned char *decode, unsigned mod, dc->duration.seconds = (log[EMC_BT] + log[EMC_BT + 1] * 256) * 60; dc->surfacetime.seconds = (log[EMC_SIT] + log[EMC_SIT + 1] * 256) * 60; dc->maxdepth.mm = lrint((log[EMC_MAX_DEPTH] + - log[EMC_MAX_DEPTH + 1] * 256) / 4 * FEET * 1000); + log[EMC_MAX_DEPTH + 1] * 256) / 4.0 * FEET * 1000); dc->meandepth.mm = lrint((log[EMC_AVG_DEPTH] + - log[EMC_AVG_DEPTH + 1] * 256) / 4 * FEET * 1000); + log[EMC_AVG_DEPTH + 1] * 256) / 4.0 * FEET * 1000); dc->watertemp.mkelvin = F_to_mkelvin(log[EMC_MIN_TEMP]); dc->surface_pressure.mbar = lrint(ATM / BAR * pow(1 - 0.0000225577 * (double) log[EMC_ALTITUDE] * 250 * FEET, 5.25588) * 1000); diff --git a/core/dive.cpp b/core/dive.cpp index f3040131b..8cc888ae5 100644 --- a/core/dive.cpp +++ b/core/dive.cpp @@ -470,7 +470,7 @@ static bool has_unknown_used_cylinders(const struct dive *dive, const struct div /* We know about the explicit first cylinder (or first) */ idx = explicit_first_cylinder(dive, dc); - if (used_and_unknown[idx]) { + if (idx >= 0 && used_and_unknown[idx]) { used_and_unknown[idx] = false; num--; } diff --git a/core/import-csv.cpp b/core/import-csv.cpp index 079999020..e16e9174b 100644 --- a/core/import-csv.cpp +++ b/core/import-csv.cpp @@ -452,11 +452,12 @@ static std::string parse_mkvi_value(const char *haystack, const char *needle) if ((lineptr = strstr(haystack, needle)) != NULL) { if ((valueptr = strstr(lineptr, ": ")) != NULL) { valueptr += 2; - } - if ((endptr = strstr(lineptr, "\n")) != NULL) { - if (*(endptr - 1) == '\r') - --endptr; - return std::string(valueptr, endptr - valueptr); + + if ((endptr = strstr(lineptr, "\n")) != NULL) { + if (*(endptr - 1) == '\r') + --endptr; + return std::string(valueptr, endptr - valueptr); + } } } return std::string();