]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Just suppress the warnings... Stupid stupid GCC
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 30 Oct 2021 21:42:16 +0000 (17:42 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 30 Oct 2021 21:42:16 +0000 (17:42 -0400)
src/lib/server/log.c
src/lib/util/base_16_32_64_tests.c
src/lib/util/cursor.h
src/lib/util/dbuff.h
src/lib/util/log.c
src/lib/util/pair_print.c
src/lib/util/sbuff.h

index 271373cfa10fb75d5ec42ca5d4a9adf02fd19dc4..49b73b847f168dc53791c5f6ca6201717620b824 100644 (file)
@@ -956,8 +956,6 @@ void log_request_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags,
                return;
        }
 
-       buffer[0] = '\0';       /* Fix GCC11 bug where it flags the buffer as uninitialised for no reason */
-
        fr_sbuff_init_out(&sbuff, buffer, sizeof(buffer));
        fr_sbuff_marker(&m_start, &sbuff);
        fr_sbuff_marker(&m_end, &sbuff);
index 182471a5e2a7a580074123593109712e374c6b63..cd68b5a770fbdd49ba232f7c547262a3a38c4505 100644 (file)
@@ -60,7 +60,7 @@ static const test_vector base64_vectors[] = {
 
 static void test_base16_encode(void)
 {
-       char            buffer[17] = { '\0' };
+       char            buffer[17];
        fr_sbuff_t      out;
        size_t          i;
 
@@ -104,7 +104,7 @@ static void test_base16_decode(void)
 
 static void test_base32_encode(void)
 {
-       char            buffer[17] = { '\0' };
+       char            buffer[17];
        fr_sbuff_t      out;
        size_t          i;
 
@@ -151,7 +151,7 @@ static void test_base32_decode(void)
 
 static void test_base32_hex_encode(void)
 {
-       char            buffer[17] = { '\0' };
+       char            buffer[17];
        fr_sbuff_t      out;
        size_t          i;
 
@@ -198,7 +198,7 @@ static void test_base32_hex_decode(void)
 
 static void test_base64_encode(void)
 {
-       char            buffer[17] = { '\0' };
+       char            buffer[17];
        fr_sbuff_t      out;
        size_t          i;
 
index b8cdea16b74381d8e4479064785eee1b8a5909a4..97328ad280e24679c41eedb73e9e1b80fc70d402 100644 (file)
@@ -135,6 +135,13 @@ void *fr_cursor_replace(fr_cursor_t *cursor, void *r) CC_HINT(nonnull);
 /** @hidecallergraph */
 void fr_cursor_free_list(fr_cursor_t *cursor) CC_HINT(nonnull);
 
+/*
+ *     GCC is stupid and will warn about output variables
+ *     being unnitialised, even if they're not dereferenced.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_OFF(maybe-uninitialized)
+#endif
 /** Initialise a cursor with runtime talloc type safety checks and a custom iterator
  *
  * @param[in] _cursor  to initialise.
@@ -189,6 +196,9 @@ void fr_cursor_free_list(fr_cursor_t *cursor) CC_HINT(nonnull);
 
 void *_fr_cursor_init(fr_cursor_t *cursor, void * const *head, size_t offset,
                      fr_cursor_iter_t iter, void const *ctx, char const *type);
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_ON(maybe-uninitialized)
+#endif
 
 /** talloc_free the current item
  *
index cdb8bc2f89e5f82803c88e0f9e4c19915962df64..bd2950d52b8f07a104469e9a195b93f6e4f03465 100644 (file)
@@ -317,6 +317,13 @@ do { \
  */
 #define FR_DBUFF_MAX_BIND_CURRENT(_dbuff_or_marker,  _max) _FR_DBUFF_MAX(_dbuff_or_marker, _max, FR_DBUFF_ADV_PARENT_CURRENT)
 
+/*
+ *     GCC is stupid and will warn about output variables
+ *     being unnitialised, even if they're not dereferenced.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_OFF(maybe-uninitialized)
+#endif
 /** Does the actual work of initialising a dbuff
  * @private
  */
@@ -359,6 +366,9 @@ _fr_dbuff_init(_out, \
                        char *          : false, \
                        char const *    : true \
               ))
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_ON(maybe-uninitialized)
+#endif
 
 size_t _fr_dbuff_extend_talloc(fr_dbuff_t *dbuff, size_t extension);
 
index 12f62dbf3ab85acce148cfdcecc73ade60c374c6..f91f352e6f2ca6ad229ca01aa8ec9bbf9807ce93 100644 (file)
@@ -189,8 +189,6 @@ void fr_log_fd_event(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void
                return;
        }
 
-       buffer[0] = '\0';       /* Fix GCC11 bug where it flags the buffer as uninitialised for no reason */
-
        fr_sbuff_init_out(&sbuff, buffer, sizeof(buffer));
        fr_sbuff_marker(&m_start, &sbuff);
        fr_sbuff_marker(&m_end, &sbuff);
index fb86ef2414496e7c645a84ab1c7cb4ee08c7c5bd..1b7bb5cb3f4f6c643936de2f6f029a6a489bdeaf 100644 (file)
@@ -201,8 +201,6 @@ void _fr_pair_list_log(fr_log_t const *log, int lvl, fr_pair_t *parent, fr_pair_
        fr_sbuff_t sbuff;
        char buffer[1024];
 
-       buffer[0] = '\0';       /* Fix GCC11 bug where it flags the buffer as uninitialised for no reason */
-
        fr_sbuff_init_out(&sbuff, buffer, sizeof(buffer));
 
        fr_pair_list_log_sbuff(log, lvl, parent, list, file, line, &sbuff);
@@ -225,8 +223,6 @@ void fr_pair_debug(fr_pair_t const *pair)
        fr_sbuff_t sbuff;
        char buffer[1024];
 
-       buffer[0] = '\0';       /* Fix GCC11 bug where it flags the buffer as uninitialised for no reason */
-
        fr_sbuff_init_out(&sbuff, buffer, sizeof(buffer));
 
        fr_pair_print(&sbuff, NULL, pair);
index 5be27d947837d75deab95a9f06916ecdb577a856..fae4119f4d417eb7f337150fd4c32af38baf6d21 100644 (file)
@@ -594,6 +594,14 @@ static inline void _fr_sbuff_init(fr_sbuff_t *out, char const *start, char const
        if (nul_term) *out->start = '\0';
 }
 
+/*
+ *     GCC is stupid and will warn about output variables
+ *     being unnitialised, even if they're not dereferenced.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_OFF(maybe-uninitialized)
+#endif
+
 /** Initialise an sbuff around a stack allocated buffer for printing
  *
  * Will \0 terminate the output buffer.
@@ -614,6 +622,11 @@ _Generic((_len_or_end), \
 ), \
 IS_CONST(char *, _start), true)
 
+#if defined(__GNUC__) && __GNUC__ >= 11
+DIAG_ON(maybe-uninitialized)
+#endif
+
+
 /** Initialise an sbuff around a stack allocated buffer for parsing
  *
  * @param[out] _out            Pointer to buffer.