Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/hw_ostc_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t

if (callback) {
unsigned int value = array_uint16_le(data + offset);
dc_sample_type_t eventType = DC_SAMPLE_EVENT;
dc_sample_value_t sample = {
.event.type = SAMPLE_EVENT_STRING,
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
Expand All @@ -1194,21 +1193,20 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
if (value & OSTC4_COMPASS_HEADING_CLEARED_FLAG) {
snprintf(buf, BUFLEN, "Cleared compass heading");
} else {
sample.event.value = heading;

if (value & OSTC4_COMPASS_HEADING_SET_FLAG) {
eventType = DC_SAMPLE_BEARING;
sample.bearing = heading;
sample.event.type = SAMPLE_EVENT_HEADING;
snprintf(buf, BUFLEN, "Set compass heading [degrees]%s", sample.event.value ? "" : ": 0");
} else {
sample.event.value = heading;
snprintf(buf, BUFLEN, "Logged compass heading [degrees]%s", sample.event.value ? "" : ": 0");
}

}

sample.event.name = buf;

callback(eventType, &sample, userdata);
callback(DC_SAMPLE_EVENT, &sample, userdata);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing: this callback invocation is missing a space before the opening parenthesis, unlike most other callback invocations in this function (e.g., lines 984, 991, 997, 1003, 1009, 1068, 1102, etc.).

Suggested change
callback(DC_SAMPLE_EVENT, &sample, userdata);
callback (DC_SAMPLE_EVENT, &sample, userdata);

Copilot uses AI. Check for mistakes.
}

offset += 2;
Expand Down
9 changes: 7 additions & 2 deletions src/uwatec_smart_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,13 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
}

if (have_bearing) {
sample.bearing = bearing;
if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
dc_sample_value_t sample = {
.event.type = SAMPLE_EVENT_HEADING,
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
.event.value = bearing,
};
Comment on lines +1195 to +1199
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable shadowing issue: declaring a new local variable 'sample' here shadows the outer 'sample' variable declared at line 928. This causes the 'event.time' and 'event.name' fields to not be initialized (defaulting to 0 and NULL respectively). Consider using the outer 'sample' variable instead, similar to how the bookmark event is handled at lines 1167-1172. The event.time field should be set to 0 to match the bookmark handling pattern.

Suggested change
dc_sample_value_t sample = {
.event.type = SAMPLE_EVENT_HEADING,
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
.event.value = bearing,
};
sample.event.type = SAMPLE_EVENT_HEADING;
sample.event.time = 0;
sample.event.flags = SAMPLE_FLAGS_SEVERITY_INFO;
sample.event.value = bearing;
sample.event.name = NULL;

Copilot uses AI. Check for mistakes.

if (callback) callback(DC_SAMPLE_EVENT, &sample, userdata);
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing: this callback invocation is missing a space before the opening parenthesis, unlike other callback invocations in this function (e.g., lines 1149, 1158, 1164, 1172, 1177, 1185, 1191, 1207).

Suggested change
if (callback) callback(DC_SAMPLE_EVENT, &sample, userdata);
if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata);

Copilot uses AI. Check for mistakes.
have_bearing = 0;
}

Expand Down
Loading