Skip to content

Commit c42a458

Browse files
committed
sensor: icm4568x: Address existing code issues by static analysis
Put in a separate commit in order to make it easier to keep track of changes. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent 8601a05 commit c42a458

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

drivers/sensor/tdk/icm4268x/icm4268x.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ static inline void icm4268x_accel_reg_to_hz(uint8_t odr, struct sensor_value *ou
200200
out->val1 = 1;
201201
out->val2 = 562500;
202202
return;
203+
default:
204+
CODE_UNREACHABLE;
205+
return;
203206
}
204207
}
205208

@@ -283,6 +286,8 @@ static inline void icm4268x_gyro_reg_to_odr(uint8_t odr, struct sensor_value *ou
283286
out->val1 = 12;
284287
out->val2 = 500000;
285288
return;
289+
default:
290+
CODE_UNREACHABLE;
286291
}
287292
}
288293

drivers/sensor/tdk/icm4268x/icm4268x_decoder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int icm4268x_convert_raw_to_q31(struct icm4268x_cfg *cfg, enum sensor_channel ch
116116
if (shift < 0) {
117117
intermediate =
118118
intermediate * ((int64_t)INT32_MAX + 1) * (1 << -shift) / INT64_C(1000000);
119-
} else if (shift > 0) {
119+
} else if (shift >= 0) {
120120
intermediate =
121121
intermediate * ((int64_t)INT32_MAX + 1) / ((1 << shift) * INT64_C(1000000));
122122
}
@@ -513,6 +513,8 @@ static int icm4268x_fifo_decode(const uint8_t *buffer, struct sensor_chan_spec c
513513
buffer = frame_end;
514514
continue;
515515
}
516+
} else {
517+
CODE_UNREACHABLE;
516518
}
517519
buffer = frame_end;
518520
*fit = (uintptr_t)frame_end;

drivers/sensor/tdk/icm4268x/icm4268x_emul.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ static void icm4268x_emul_handle_write(const struct emul *target, uint8_t regn,
5858
data->reg[REG_INT_STATUS] |= BIT_RESET_DONE_INT;
5959
}
6060
break;
61+
default:
62+
__ASSERT_UNREACHABLE;
6163
}
6264
}
6365

0 commit comments

Comments
 (0)