Skip to content

Commit

Permalink
sensor: lsm6dso: Disable -Wmaybe-uninitialized for lsm6dso_mode_set
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stephanosio authored and erwango committed Aug 25, 2022
1 parent 52a522c commit cccbc24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sensor/stmemsc/README
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ License:

License Link:
https://opensource.org/licenses/BSD-3-Clause

Patch List:
* sensor: lsm6dso: Disable -Wmaybe-uninitialized for lsm6dso_mode_set
- Modified sensor/stmemsc/lsm6dso_STdC/driver/lsm6dso_reg.c
14 changes: 14 additions & 0 deletions sensor/stmemsc/lsm6dso_STdC/driver/lsm6dso_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -11768,6 +11768,16 @@ int32_t lsm6dso_all_sources_get(stmdev_ctx_t *ctx,
return ret;
}

/*
* `-Wmaybe-uninitialized` warning is disabled 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.
*/
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

/**
* @brief Sensor conversion parameters selection.[set]
*
Expand Down Expand Up @@ -12226,6 +12236,10 @@ int32_t lsm6dso_mode_set(stmdev_ctx_t *ctx, stmdev_ctx_t *aux_ctx,
return ret;
}

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

/**
* @brief Sensor conversion parameters selection.[get]
*
Expand Down

0 comments on commit cccbc24

Please sign in to comment.