Skip to content

Commit cccbc24

Browse files
stephanosioerwango
authored andcommitted
sensor: lsm6dso: Disable -Wmaybe-uninitialized for lsm6dso_mode_set
This commit disables the potentially uninitialized variable warning (`-Wmaybe-uninitialized`) for the `lsm6dso_mode_set` function because GCC 12 and above may report a false positive warning claiming that the `ctrl2_ois` variable may be used uninitialized. Note that the `ctrl2_ois` variable is always set when `aux_ctx != NULL` and is accessed if and only if `aux_ctx != NULL`, therefore it may never be used uninitialized as the warning claims. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent 52a522c commit cccbc24

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

sensor/stmemsc/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ License:
5656

5757
License Link:
5858
https://opensource.org/licenses/BSD-3-Clause
59+
60+
Patch List:
61+
* sensor: lsm6dso: Disable -Wmaybe-uninitialized for lsm6dso_mode_set
62+
- Modified sensor/stmemsc/lsm6dso_STdC/driver/lsm6dso_reg.c

sensor/stmemsc/lsm6dso_STdC/driver/lsm6dso_reg.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11768,6 +11768,16 @@ int32_t lsm6dso_all_sources_get(stmdev_ctx_t *ctx,
1176811768
return ret;
1176911769
}
1177011770

11771+
/*
11772+
* `-Wmaybe-uninitialized` warning is disabled for the `lsm6dso_mode_set`
11773+
* function because GCC 12 and above may report a false positive warning
11774+
* claiming that the `ctrl2_ois` variable may be used uninitialized.
11775+
*/
11776+
#if defined(__GNUC__)
11777+
#pragma GCC diagnostic push
11778+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
11779+
#endif
11780+
1177111781
/**
1177211782
* @brief Sensor conversion parameters selection.[set]
1177311783
*
@@ -12226,6 +12236,10 @@ int32_t lsm6dso_mode_set(stmdev_ctx_t *ctx, stmdev_ctx_t *aux_ctx,
1222612236
return ret;
1222712237
}
1222812238

12239+
#if defined(__GNUC__)
12240+
#pragma GCC diagnostic pop
12241+
#endif
12242+
1222912243
/**
1223012244
* @brief Sensor conversion parameters selection.[get]
1223112245
*

0 commit comments

Comments
 (0)