chiark / gitweb /
bus: fix potentially uninitialized memory access
[elogind.git] / src / libsystemd-bus / bus-internal.c
index 32713546007d37588d5a192f386c5aab0731a38e..cac948e875df4f97a7732b742e6098f20bb54b98 100644 (file)
@@ -63,7 +63,7 @@ bool object_path_is_valid(const char *p) {
 
 bool interface_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot;
+        bool dot, found_dot = false;
 
         if (isempty(p))
                 return false;
@@ -103,7 +103,7 @@ bool interface_name_is_valid(const char *p) {
 
 bool service_name_is_valid(const char *p) {
         const char *q;
-        bool dot, found_dot, unique;
+        bool dot, found_dot = false, unique;
 
         if (isempty(p))
                 return false;
@@ -241,3 +241,16 @@ int bus_message_type_from_string(const char *s, uint8_t *u) {
 
         return 0;
 }
+
+const char *bus_message_type_to_string(uint8_t u) {
+        if (u == SD_BUS_MESSAGE_TYPE_SIGNAL)
+                return "signal";
+        else if (u == SD_BUS_MESSAGE_TYPE_METHOD_CALL)
+                return "method_call";
+        else if (u == SD_BUS_MESSAGE_TYPE_METHOD_ERROR)
+                return "error";
+        else if (u == SD_BUS_MESSAGE_TYPE_METHOD_RETURN)
+                 return "method_return";
+        else
+                return NULL;
+}