*
*/
-#include <common/macros.h>
+#include <common/buffer-view.hpp>
+#include <common/dynamic-array.hpp>
+#include <common/dynamic-buffer.hpp>
+#include <common/error.hpp>
+#include <common/macros.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <lttng/channel-internal.hpp>
#include <lttng/channel.h>
#include <lttng/constant.h>
-#include <lttng/channel-internal.h>
-#include <lttng/userspace-probe-internal.h>
-#include <common/dynamic-buffer.h>
-#include <common/error.h>
-#include <assert.h>
-#include <string.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/dynamic-array.h>
-#include <common/buffer-view.h>
+#include <lttng/userspace-probe-internal.hpp>
static enum lttng_error_code flatten_lttng_channels(
struct lttng_dynamic_pointer_array *channels,
struct lttng_channel_extended *extended = nullptr;
struct lttng_channel *channel = nullptr, *ret = nullptr;
- channel = (struct lttng_channel *) zmalloc(sizeof(*channel));
+ channel = zmalloc<lttng_channel>();
if (!channel) {
goto end;
}
*channel = *src;
if (src->attr.extended.ptr) {
- extended = (struct lttng_channel_extended *) zmalloc(
- sizeof(*extended));
+ extended = zmalloc<lttng_channel_extended>();
if (!extended) {
goto end;
}
struct lttng_channel *local_channel = nullptr, *ret = nullptr;
struct lttng_channel_extended *extended = nullptr;
- local_channel = (struct lttng_channel *) zmalloc(
- sizeof(struct lttng_channel));
+ local_channel = zmalloc<lttng_channel>();
if (!local_channel) {
goto end;
}
/* Extended struct */
- extended = (struct lttng_channel_extended *) zmalloc(
- sizeof(*extended));
+ extended = zmalloc<lttng_channel_extended>();
if (!extended) {
goto end;
}
lttng_buffer_view_from_view(view, offset,
channel_comm->name_len);
- if (channel_comm->name_len > LTTNG_SYMBOL_NAME_LEN - 1) {
- ret = -1;
- goto end;
- }
-
name = name_view.data;
if (!lttng_buffer_view_contains_string(
&name_view, name, channel_comm->name_len)) {
goto end;
}
- strcpy(local_channel->name, name);
+ ret = lttng_strncpy(local_channel->name, name,
+ sizeof(local_channel->name));
+ if (ret) {
+ goto end;
+ }
+
offset += channel_comm->name_len;
}
{
int ret;
size_t name_len;
- struct lttng_channel_comm channel_comm = { 0 };
+ struct lttng_channel_comm channel_comm = {};
struct lttng_channel_extended *extended;
assert(channel);