]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic|boot: silence Wunterminated-string-initialization gcc15 warnings
authorCristian Rodríguez <cristian@rodriguez.im>
Sun, 4 Aug 2024 22:51:54 +0000 (18:51 -0400)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 6 Aug 2024 22:14:53 +0000 (00:14 +0200)
gcc15 has -Wunterminated-string-initialization in -Wextra and
warns about string constants that are not null terminated even though
the functions do do out of bounds access.
Silence the warnings by simply not providing an explicit size.

src/basic/hexdecoct.c
src/boot/efi/efi-string.c

index c474b60776e4547548e4f8fc6c8aa9302ae8c8b7..79e4959be79047b79167c70648668da529d7b1f8 100644 (file)
@@ -36,7 +36,7 @@ int undecchar(char c) {
 }
 
 char hexchar(int x) {
-        static const char table[16] = "0123456789abcdef";
+        static const char table[] = "0123456789abcdef";
 
         return table[x & 15];
 }
@@ -168,8 +168,8 @@ int unhexmem_full(
  * useful when representing NSEC3 hashes, as one can then verify the
  * order of hashes directly from their representation. */
 char base32hexchar(int x) {
-        static const char table[32] = "0123456789"
-                                      "ABCDEFGHIJKLMNOPQRSTUV";
+        static const char table[] = "0123456789"
+                                    "ABCDEFGHIJKLMNOPQRSTUV";
 
         return table[x & 31];
 }
@@ -519,9 +519,9 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *_l
 
 /* https://tools.ietf.org/html/rfc4648#section-4 */
 char base64char(int x) {
-        static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                      "abcdefghijklmnopqrstuvwxyz"
-                                      "0123456789+/";
+        static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                    "abcdefghijklmnopqrstuvwxyz"
+                                    "0123456789+/";
         return table[x & 63];
 }
 
@@ -529,9 +529,9 @@ char base64char(int x) {
  * since we don't want "/" appear in interface names (since interfaces appear in sysfs as filenames).
  * See section #5 of RFC 4648. */
 char urlsafe_base64char(int x) {
-        static const char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                                      "abcdefghijklmnopqrstuvwxyz"
-                                      "0123456789-_";
+        static const char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                    "abcdefghijklmnopqrstuvwxyz"
+                                    "0123456789-_";
         return table[x & 63];
 }
 
index 63481461a5acb3c45617d8ea7de271ceec18ff3b..87beb8528607ccdd1081fa9f69cb13051cc7661d 100644 (file)
@@ -481,7 +481,7 @@ char* line_get_key_value(char *s, const char *sep, size_t *pos, char **ret_key,
 }
 
 char16_t *hexdump(const void *data, size_t size) {
-        static const char hex[16] = "0123456789abcdef";
+        static const char hex[] = "0123456789abcdef";
         const uint8_t *d = data;
 
         assert(data || size == 0);