Documentation: document undefined behavior for NULL pointers
[lttng-ust.git] / liblttng-ust-comm / lttng-ust-comm.c
index 00b1d43af0a4ec1610e4d1a83d204a2c064236b3..087424fe66626a6dd393315ccb3fa896c54322ff 100644 (file)
@@ -123,7 +123,7 @@ int ustcomm_connect_unix_sock(const char *pathname)
                 * file exists but no sessiond is listening.
                 */
                if (errno != ECONNREFUSED && errno != ECONNRESET
-                               && errno != ENOENT)
+                               && errno != ENOENT && errno != EACCES)
                        PERROR("connect");
                ret = -errno;
                if (ret == -ECONNREFUSED || ret == -ECONNRESET)
@@ -656,6 +656,26 @@ int ustcomm_send_reg_msg(int sock,
        return 0;
 }
 
+static
+int serialize_string_encoding(enum ustctl_string_encodings *ue,
+               enum lttng_string_encodings le)
+{
+       switch (le) {
+       case lttng_encode_none:
+               *ue = ustctl_encode_none;
+               break;
+       case lttng_encode_UTF8:
+               *ue = ustctl_encode_UTF8;
+               break;
+       case lttng_encode_ASCII:
+               *ue = ustctl_encode_ASCII;
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
+
 static
 int serialize_basic_type(enum ustctl_abstract_types *uatype,
                enum lttng_abstract_types atype,
@@ -674,14 +694,17 @@ int serialize_basic_type(enum ustctl_abstract_types *uatype,
                uit->signedness = lit->signedness;
                uit->reverse_byte_order = lit->reverse_byte_order;
                uit->base = lit->base;
-               uit->encoding = lit->encoding;
+               if (serialize_string_encoding(&uit->encoding, lit->encoding))
+                       return -EINVAL;
                uit->alignment = lit->alignment;
                *uatype = ustctl_atype_integer;
                break;
        }
        case atype_string:
        {
-               ubt->string.encoding = lbt->string.encoding;
+               if (serialize_string_encoding(&ubt->string.encoding,
+                               lbt->string.encoding))
+                       return -EINVAL;
                *uatype = ustctl_atype_string;
                break;
        }
@@ -831,7 +854,7 @@ int ustcomm_register_event(int sock,
                struct ustcomm_notify_event_reply r;
        } reply;
        size_t signature_len, fields_len, model_emf_uri_len;
-       struct ustctl_field *fields;
+       struct ustctl_field *fields = NULL;
        size_t nr_write_fields = 0;
        int ret;
 
This page took 0.02415 seconds and 4 git commands to generate.