Skip to content
Snippets Groups Projects
Commit a3eb75e3 authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[Libc] avoid spurious uninitialized warnings from the compiler

Clang 13 emits warnings related to uninitialized variables:

variable 'r' is used uninitialized whenever 'if'
condition is false [-Wsometimes-uninitialized]

This is due to the fact that the assert(0) macro, when using Frama-C's libc,
is expanded to __FC_assert. Since it is not known by the compiler, it cannot
consider it as "noreturn" when the condition is zero. Note that adding
'__attribute__ ((__noreturn__))' will not work: Frama-C will assume it
never returns, even when the condition is true.
Initializing the 'r' variables with a default value will not change the
actual behavior, and will avoid the warnings.
parent ea345863
No related branches found
No related tags found
No related merge requests found
...@@ -60,7 +60,7 @@ unsigned long long __fc_atomic_load_explicit(void *object, ...@@ -60,7 +60,7 @@ unsigned long long __fc_atomic_load_explicit(void *object,
unsigned long long __fc_atomic_exchange(void *obj, unsigned long long __fc_atomic_exchange(void *obj,
unsigned long long desired, unsigned long long desired,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = *((volatile atomic_uchar *)obj); r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) = desired; *((volatile atomic_uchar *)obj) = desired;
...@@ -120,7 +120,7 @@ _Bool __fc_atomic_compare_exchange_weak_explicit(void *object, void *expected, ...@@ -120,7 +120,7 @@ _Bool __fc_atomic_compare_exchange_weak_explicit(void *object, void *expected,
unsigned long long __fc_atomic_fetch_add(void *obj, unsigned long long operand, unsigned long long __fc_atomic_fetch_add(void *obj, unsigned long long operand,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = *((volatile atomic_uchar *)obj); r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) += operand; *((volatile atomic_uchar *)obj) += operand;
...@@ -149,7 +149,7 @@ unsigned long long __fc_atomic_fetch_add_explicit(void *obj, ...@@ -149,7 +149,7 @@ unsigned long long __fc_atomic_fetch_add_explicit(void *obj,
unsigned long long __fc_atomic_fetch_sub(void *obj, unsigned long long operand, unsigned long long __fc_atomic_fetch_sub(void *obj, unsigned long long operand,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { r = *((volatile atomic_uchar *)obj); if (obj_size == sizeof(char)) { r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) -= operand; } *((volatile atomic_uchar *)obj) -= operand; }
else if (obj_size == sizeof(short)) { r = *((volatile atomic_ushort *)obj); else if (obj_size == sizeof(short)) { r = *((volatile atomic_ushort *)obj);
...@@ -173,7 +173,7 @@ unsigned long long __fc_atomic_fetch_sub_explicit(void *obj, ...@@ -173,7 +173,7 @@ unsigned long long __fc_atomic_fetch_sub_explicit(void *obj,
unsigned long long __fc_atomic_fetch_or(void *obj, unsigned long long operand, unsigned long long __fc_atomic_fetch_or(void *obj, unsigned long long operand,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { r = *((volatile atomic_uchar *)obj); if (obj_size == sizeof(char)) { r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) |= operand; } *((volatile atomic_uchar *)obj) |= operand; }
else if (obj_size == sizeof(short)) { r = *((volatile atomic_ushort *)obj); else if (obj_size == sizeof(short)) { r = *((volatile atomic_ushort *)obj);
...@@ -197,7 +197,7 @@ unsigned long long __fc_atomic_fetch_or_explicit(void *obj, ...@@ -197,7 +197,7 @@ unsigned long long __fc_atomic_fetch_or_explicit(void *obj,
unsigned long long __fc_atomic_fetch_xor(void *obj, unsigned long long operand, unsigned long long __fc_atomic_fetch_xor(void *obj, unsigned long long operand,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = *((volatile atomic_uchar *)obj); r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) ^= operand; *((volatile atomic_uchar *)obj) ^= operand;
...@@ -228,7 +228,7 @@ unsigned long long __fc_atomic_fetch_xor_explicit(void *obj, ...@@ -228,7 +228,7 @@ unsigned long long __fc_atomic_fetch_xor_explicit(void *obj,
unsigned long long __fc_atomic_fetch_and(void *obj, unsigned long long __fc_atomic_fetch_and(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) { size_t obj_size) {
unsigned long long r; unsigned long long r = 0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = *((volatile atomic_uchar *)obj); r = *((volatile atomic_uchar *)obj);
*((volatile atomic_uchar *)obj) &= operand; *((volatile atomic_uchar *)obj) &= operand;
......
...@@ -213,13 +213,13 @@ ...@@ -213,13 +213,13 @@
Global metrics Global metrics
============== ==============
Sloc = 1641 Sloc = 1647
Decision point = 307 Decision point = 307
Global variables = 86 Global variables = 86
If = 292 If = 292
Loop = 55 Loop = 55
Goto = 118 Goto = 118
Assignment = 711 Assignment = 717
Exit point = 128 Exit point = 128
Function = 556 Function = 556
Function call = 165 Function call = 165
......
...@@ -5865,7 +5865,7 @@ unsigned long long __fc_atomic_exchange(void *obj, ...@@ -5865,7 +5865,7 @@ unsigned long long __fc_atomic_exchange(void *obj,
unsigned long long desired, unsigned long long desired,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)desired; *((atomic_uchar volatile *)obj) = (unsigned char)desired;
...@@ -5953,7 +5953,7 @@ unsigned long long __fc_atomic_fetch_add(void *obj, ...@@ -5953,7 +5953,7 @@ unsigned long long __fc_atomic_fetch_add(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) + operand); *((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) + operand);
...@@ -5996,7 +5996,7 @@ unsigned long long __fc_atomic_fetch_sub(void *obj, ...@@ -5996,7 +5996,7 @@ unsigned long long __fc_atomic_fetch_sub(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) - operand); *((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) - operand);
...@@ -6039,7 +6039,7 @@ unsigned long long __fc_atomic_fetch_or(void *obj, ...@@ -6039,7 +6039,7 @@ unsigned long long __fc_atomic_fetch_or(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) | operand); *((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) | operand);
...@@ -6082,7 +6082,7 @@ unsigned long long __fc_atomic_fetch_xor(void *obj, ...@@ -6082,7 +6082,7 @@ unsigned long long __fc_atomic_fetch_xor(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) ^ operand); *((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) ^ operand);
...@@ -6125,7 +6125,7 @@ unsigned long long __fc_atomic_fetch_and(void *obj, ...@@ -6125,7 +6125,7 @@ unsigned long long __fc_atomic_fetch_and(void *obj,
unsigned long long operand, unsigned long long operand,
size_t obj_size) size_t obj_size)
{ {
unsigned long long r; unsigned long long r = (unsigned long long)0;
if (obj_size == sizeof(char)) { if (obj_size == sizeof(char)) {
r = (unsigned long long)*((atomic_uchar volatile *)obj); r = (unsigned long long)*((atomic_uchar volatile *)obj);
*((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) & operand); *((atomic_uchar volatile *)obj) = (unsigned char)((unsigned long long)*((atomic_uchar volatile *)obj) & operand);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment