samples: sensor: Fix logically dead code in bmg160 sample
Converts the bmg160 sample application to check the sensor device at
build time instead of runtime. This fixes a Coverity issue for logically
dead code introduced in commit 5832e588e3.
Fixes #35118
Coverity-CID: 235919
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
53f21e170f
commit
19fd5835f7
@ -17,6 +17,10 @@
|
||||
#define MAX_TEST_TIME 15000
|
||||
#define SLEEPTIME 300
|
||||
|
||||
#if !DT_HAS_COMPAT_STATUS_OKAY(bosch_bmg160)
|
||||
#error "No bosch,bmg160 compatible node found in the device tree"
|
||||
#endif
|
||||
|
||||
static void print_gyro_data(const struct device *bmg160)
|
||||
{
|
||||
struct sensor_value val[3];
|
||||
@ -173,10 +177,6 @@ void main(void)
|
||||
struct sensor_value attr;
|
||||
#endif
|
||||
|
||||
if (!bmg160) {
|
||||
printf("Device not found.\n");
|
||||
return;
|
||||
}
|
||||
if (!device_is_ready(bmg160)) {
|
||||
printf("Device %s is not ready.\n", bmg160->name);
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user