Skip to content

Commit 1564d09

Browse files
committed
partial "-Wmaybe-uninitialized" added
1 parent 647aec8 commit 1564d09

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/trice.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,16 @@ unsigned TriceOutDepth(void) {
865865
return depth;
866866
}
867867

868+
#ifdef __GNUC__
869+
// https://stackoverflow.com/questions/5080848/disable-gcc-may-be-used-uninitialized-on-a-particular-variable
870+
#pragma GCC diagnostic push // save the actual diag context
871+
#ifndef __clang__
872+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // disable maybe warnings
873+
#endif
874+
#endif // #ifdef __GNUC__
875+
// now impacted section of code
876+
877+
868878
//! TRICE_ASSERT writes trice data as fast as possible in a buffer.
869879
//! \param tid is a 16 bit Trice id in upper 2 bytes of a 32 bit value
870880
//! This is a helper macro and should not be used in user code.
@@ -915,6 +925,10 @@ void TRiceAssertFalse(int idN, char* msg, int flag) {
915925
}
916926
}
917927

928+
#ifdef __GNUC__
929+
#pragma GCC diagnostic pop // restore previous diag context
930+
#endif // #ifdef __GNUC__
931+
918932
#ifdef TRICE_N
919933

920934
void triceN(int tid, char* fmt, void* buf, uint32_t n) {

0 commit comments

Comments
 (0)