From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Thu, 18 Apr 2019 15:52:03 -0400 (EDT) Subject: [lttng-dev] [RFC PATCH lttng-tools 17/18] Add serdes functions for lttng_snapshot_output In-Reply-To: <20190418161850.1536-18-ylamarre@efficios.com> References: <20190418161850.1536-1-ylamarre@efficios.com> <20190418161850.1536-18-ylamarre@efficios.com> Message-ID: <202790084.1641.1555617123626.JavaMail.zimbra@efficios.com> ----- On Apr 18, 2019, at 12:18 PM, Yannick Lamarre ylamarre at efficios.com wrote: > Since those structs are only transfered across unix sockets, endianess > is kept in host order. transfered -> transferred (check all commit messages) endianess -> endianness (check all commit messages) > > Signed-off-by: Yannick Lamarre > --- > include/lttng/snapshot-internal.h | 3 +++ > src/common/sessiond-comm/sessiond-comm.c | 28 ++++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/include/lttng/snapshot-internal.h > b/include/lttng/snapshot-internal.h > index bf9dfbe4..b269607d 100644 > --- a/include/lttng/snapshot-internal.h > +++ b/include/lttng/snapshot-internal.h > @@ -73,4 +73,7 @@ struct lttng_snapshot_output_list { > struct lttng_snapshot_output *array; > }; > > +int lttng_snapshot_output_serialize(struct lttng_snapshot_output_serialized > *dst, const struct lttng_snapshot_output *src); > +int lttng_snapshot_output_deserialize(struct lttng_snapshot_output *dst, const > struct lttng_snapshot_output_serialized *src); > + > #endif /* LTTNG_SNAPSHOT_INTERNAL_ABI_H */ > diff --git a/src/common/sessiond-comm/sessiond-comm.c > b/src/common/sessiond-comm/sessiond-comm.c > index d71abe0c..863054d0 100644 > --- a/src/common/sessiond-comm/sessiond-comm.c > +++ b/src/common/sessiond-comm/sessiond-comm.c > @@ -77,6 +77,34 @@ static const char *lttcomm_readable_code[] = { > static unsigned long network_timeout; > > LTTNG_HIDDEN > +int lttng_snapshot_output_serialize(struct lttng_snapshot_output_serialized > *dst, > + const struct lttng_snapshot_output *src) > +{ Why not assert(src && dst) here like other helpers ? > + dst->id = src->id; > + dst->max_size = src->max_size; > + > + memcpy(dst->name, src->name, LTTNG_NAME_MAX); > + memcpy(dst->ctrl_url, src->ctrl_url, PATH_MAX); > + memcpy(dst->data_url, src->data_url, PATH_MAX); > + > + return 0; > +} > + > +LTTNG_HIDDEN > +int lttng_snapshot_output_deserialize(struct lttng_snapshot_output *dst, > + const struct lttng_snapshot_output_serialized *src) > +{ same. Thanks, Mathieu > + dst->id = src->id; > + dst->max_size = src->max_size; > + > + memcpy(dst->name, src->name, LTTNG_NAME_MAX); > + memcpy(dst->ctrl_url, src->ctrl_url, PATH_MAX); > + memcpy(dst->data_url, src->data_url, PATH_MAX); > + > + return 0; > +} > + > +LTTNG_HIDDEN > int lttng_event_common_serialize(struct lttng_event_serialized *dst, > const struct lttng_event *src) > { > -- > 2.11.0 > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com