summarylogtreecommitdiffstats
path: root/build-fix.patch
blob: a3be41614f40d8b5d723df8f6b91c7783bb59781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
From 00e32c6ec3044c32d1a3ec7eac3343dd360e143e Mon Sep 17 00:00:00 2001
From: xulfer <xulfer at cheapbsd.net>
Date: Fri, 16 Jun 2017 13:39:28 -0500
Subject: [PATCH] Fixed some issues with newer GCC versions.

A few new warnings popped up with newer GCC versions that
prevented building due to -Werror.  These should appear to be
fixed for now, but may not be compatible with BSD versions so
more testing may be required.

diff --git a/benc/serialization/json/JsonBencSerializer.c b/benc/serialization/json/JsonBencSerializer.c
index edc1f3d2..7d1690f6 100644
--- a/benc/serialization/json/JsonBencSerializer.c
+++ b/benc/serialization/json/JsonBencSerializer.c
@@ -72,15 +72,15 @@ static int32_t serializeString(struct Writer* writer,
     Writer_write(writer, "\"", 1);
     size_t i;
     uint8_t chr;
-    char buffer[4];
+    char buffer[5];
     for (i = 0; i < string->len; i++) {
         chr = (uint8_t) string->bytes[i] & 0xFF;
         /* Nonprinting chars, \ and " are hex'd */
         if (chr < 126 && chr > 31 && chr != '\\' && chr != '"') {
-            snprintf(buffer, 4, "%c", chr);
+            snprintf(buffer, 5, "%c", chr);
             Writer_write(writer, buffer, 1);
         } else {
-            snprintf(buffer, 4, "\\x%.2X", chr);
+            snprintf(buffer, 5, "\\x%.2X", chr);
             Writer_write(writer, buffer, 4);
         }
     }
diff --git a/dht/dhtcore/NodeStore.c b/dht/dhtcore/NodeStore.c
index decab6c0..5199d865 100644
--- a/dht/dhtcore/NodeStore.c
+++ b/dht/dhtcore/NodeStore.c
@@ -1771,7 +1771,9 @@ struct NodeList* NodeStore_getPeers(uint64_t label,
         }
         switch (j) {
             default: Bits_memmove(out->nodes, &out->nodes[1], (j - 1) * sizeof(char*));
+                     __attribute__ ((fallthrough)); // C and C++03
             case 1: out->nodes[j - 1] = next->child;
+                     __attribute__ ((fallthrough)); // C and C++03
             case 0:;
         }
     }
diff --git a/subnode/GetPeersResponder.c b/subnode/GetPeersResponder.c
index 5110d0dd..a37fd38e 100644
--- a/subnode/GetPeersResponder.c
+++ b/subnode/GetPeersResponder.c
@@ -81,7 +81,9 @@ static void onGetPeers(Dict* msg,
         }
         switch (j) {
             default: Bits_memmove(ptrList, &ptrList[1], (j - 1) * sizeof(char*));
+                     __attribute__ ((fallthrough)); // C and C++03
             case 1: ptrList[j - 1] = peer;
+                     __attribute__ ((fallthrough)); // C and C++03
             case 0:;
         }
     }