break;
default:
WARN_ON_ONCE(1);
+ ret = -1;
+ goto end;
}
ret = lttng_msgpack_end_map(writer);
}
static
-int64_t capture_sequence_element_signed(uint8_t *ptr,
- const struct lttng_kernel_type_integer *type)
+int capture_sequence_element_signed(uint8_t *ptr,
+ const struct lttng_kernel_type_integer *type,
+ int64_t *_value)
{
int64_t value = 0;
unsigned int size = type->size;
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(int8_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(int16_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(int16_t *) ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(int32_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(int32_t *) ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(int64_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(int64_t *) ptr;
}
}
default:
WARN_ON_ONCE(1);
+ return -1;
}
- return value;
+ *_value = value;
+ return 0;
}
static
-uint64_t capture_sequence_element_unsigned(uint8_t *ptr,
- const struct lttng_kernel_type_integer *type)
+int capture_sequence_element_unsigned(uint8_t *ptr,
+ const struct lttng_kernel_type_integer *type,
+ uint64_t *_value)
{
uint64_t value = 0;
unsigned int size = type->size;
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(uint8_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(uint16_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(uint16_t *) ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(uint32_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(uint32_t *) ptr;
}
if (user) {
if (lttng_copy_from_user_check_nofault(&tmp, ptr, sizeof(uint64_t)))
- tmp = 0;
+ return -1;
} else {
tmp = *(uint64_t *) ptr;
}
}
default:
WARN_ON_ONCE(1);
+ return -1;
}
- return value;
+ *_value = value;
+ return 0;
}
int capture_sequence(struct lttng_msgpack_writer *writer,
signedness = integer_type->signedness;
for (i = 0; i < output->u.sequence.nr_elem; i++) {
if (signedness) {
- ret = lttng_msgpack_write_signed_integer(writer,
- capture_sequence_element_signed(ptr, integer_type));
+ int64_t v;
+
+ ret = capture_sequence_element_signed(ptr, integer_type, &v);
+ if (ret) {
+ goto end;
+ }
+ ret = lttng_msgpack_write_signed_integer(writer, v);
if (ret) {
goto end;
}
} else {
- ret = lttng_msgpack_write_unsigned_integer(writer,
- capture_sequence_element_unsigned(ptr, integer_type));
+ uint64_t v;
+
+ ret = capture_sequence_element_unsigned(ptr, integer_type, &v);
+ if (ret) {
+ goto end;
+ }
+ ret = lttng_msgpack_write_unsigned_integer(writer, v);
if (ret) {
goto end;
}