@@ -1210,7 +1210,10 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
1210
1210
}
1211
1211
1212
1212
unsigned int scrubberState = array_uint16_le (data + offset );
1213
- int scrubberTimeMinutes = (scrubberState & 0x0800 ) ? (-1 ^ 0x0FFF ) | (scrubberState & 0x0FFF ) : scrubberState & 0x0FFF ; // extract 12 bit signed int
1213
+ int scrubberTimeMinutes = scrubberState & 0x0FFF ; // Extract the 12-bit value
1214
+ if (scrubberState & 0x0800 ) { // Check if the sign bit is set
1215
+ scrubberTimeMinutes -= 0x1000 ; // Perform sign extension
1216
+ }
1214
1217
if (parser -> first_scrubber_time_minutes == INT_MAX ) {
1215
1218
parser -> first_scrubber_time_minutes = scrubberTimeMinutes ;
1216
1219
}
@@ -1222,17 +1225,16 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
1222
1225
.event .flags = SAMPLE_FLAGS_SEVERITY_STATE ,
1223
1226
};
1224
1227
1225
-
1226
1228
if (scrubberState & OSTC4_SCRUBBER_STATE_ERROR_FLAG ) {
1227
1229
if (!parser -> scrubber_error_reported ) {
1228
- sample .event .flags = SAMPLE_FLAGS_SEVERITY_ALARM ;
1229
- parser -> scrubber_error_reported = true;
1230
+ sample .event .flags = SAMPLE_FLAGS_SEVERITY_ALARM ;
1231
+ parser -> scrubber_error_reported = true;
1230
1232
}
1231
1233
snprintf (buf , BUFLEN , "Scrubber exhausted: %d minutes remaining" , scrubberTimeMinutes );
1232
1234
} else if (scrubberState & OSTC4_SCRUBBER_STATE_WARNING_FLAG ) {
1233
1235
if (!parser -> scrubber_warning_reported ) {
1234
- sample .event .flags = SAMPLE_FLAGS_SEVERITY_WARN ;
1235
- parser -> scrubber_warning_reported = true;
1236
+ sample .event .flags = SAMPLE_FLAGS_SEVERITY_WARN ;
1237
+ parser -> scrubber_warning_reported = true;
1236
1238
}
1237
1239
snprintf (buf , BUFLEN , "Scrubber warning: %d minutes remaining" , scrubberTimeMinutes );
1238
1240
} else {
0 commit comments