mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: Fix Problems Raised by Coverity Scan.
Opportunistically fix some problems newly raised by a recent Coverity scan. Not touching any of the string memory allocation issues as this is being handled by the move towards C++ strings. Signed-off-by: Michael Keller <mikeller@042.ch>
This commit is contained in:
parent
3229d1e3a1
commit
e6ff3f7537
3 changed files with 11 additions and 10 deletions
|
@ -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);
|
||||
|
|
|
@ -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--;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue