resolve: work around clang limitation
authorLennart Poettering <lennart@poettering.net>
Mon, 1 Feb 2016 20:32:54 +0000 (21:32 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 1 Feb 2016 21:18:16 +0000 (22:18 +0100)
clang is apparently not smart enough to detect when a switch statement contains case statements for all possible values
of the used type. Work around that.

(And while we are at it, normalize indentation a bit)

Fixes: #2504

src/resolve/dns-type.c

index fc2f182..49210b2 100644 (file)
@@ -240,31 +240,69 @@ int dns_class_from_string(const char *s) {
 }
 
 const char* tlsa_cert_usage_to_string(uint8_t cert_usage) {
-        switch(cert_usage) {
-        case 0:         return "CA constraint";
-        case 1:         return "Service certificate constraint";
-        case 2:         return "Trust anchor assertion";
-        case 3:         return "Domain-issued certificate";
-        case 4 ... 254: return "Unassigned";
-        case 255:       return "Private use";
+
+        switch (cert_usage) {
+
+        case 0:
+                return "CA constraint";
+
+        case 1:
+                return "Service certificate constraint";
+
+        case 2:
+                return "Trust anchor assertion";
+
+        case 3:
+                return "Domain-issued certificate";
+
+        case 4 ... 254:
+                return "Unassigned";
+
+        case 255:
+                return "Private use";
         }
+
+        return NULL;  /* clang cannot count that we covered everything */
 }
 
 const char* tlsa_selector_to_string(uint8_t selector) {
-        switch(selector) {
-        case 0:         return "Full Certificate";
-        case 1:         return "SubjectPublicKeyInfo";
-        case 2 ... 254: return "Unassigned";
-        case 255:       return "Private use";
+        switch (selector) {
+
+        case 0:
+                return "Full Certificate";
+
+        case 1:
+                return "SubjectPublicKeyInfo";
+
+        case 2 ... 254:
+                return "Unassigned";
+
+        case 255:
+                return "Private use";
         }
+
+        return NULL;
 }
 
 const char* tlsa_matching_type_to_string(uint8_t selector) {
-        switch(selector) {
-        case 0:         return "No hash used";
-        case 1:         return "SHA-256";
-        case 2:         return "SHA-512";
-        case 3 ... 254: return "Unassigned";
-        case 255:       return "Private use";
+
+        switch (selector) {
+
+        case 0:
+                return "No hash used";
+
+        case 1:
+                return "SHA-256";
+
+        case 2:
+                return "SHA-512";
+
+        case 3 ... 254:
+                return "Unassigned";
+
+        case 255:
+                return "Private use";
         }
+
+        return NULL;
 }