X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fevaluation.c;h=f07c81b18cf9747250bc3284ff04cf713d4ebbb7;hb=9ef5b6be9aba525924d1eab6d3260f4c7ff165ee;hp=b2c2df81585e34d943af6605d04d8633b084a277;hpb=e8360425c2fd0f8cfef1e678af5adfde7ae0a68e;p=lttng-tools.git diff --git a/src/common/evaluation.c b/src/common/evaluation.c index b2c2df815..f07c81b18 100644 --- a/src/common/evaluation.c +++ b/src/common/evaluation.c @@ -24,29 +24,26 @@ #include LTTNG_HIDDEN -ssize_t lttng_evaluation_serialize(struct lttng_evaluation *evaluation, - char *buf) +int lttng_evaluation_serialize(struct lttng_evaluation *evaluation, + struct lttng_dynamic_buffer *buf) { - ssize_t ret, offset = 0; + int ret; struct lttng_evaluation_comm evaluation_comm = { .type = (int8_t) evaluation->type }; - if (buf) { - memcpy(buf, &evaluation_comm, sizeof(evaluation_comm)); + ret = lttng_dynamic_buffer_append(buf, &evaluation_comm, + sizeof(evaluation_comm)); + if (ret) { + goto end; } - offset += sizeof(evaluation_comm); if (evaluation->serialize) { - ret = evaluation->serialize(evaluation, - buf ? (buf + offset) : NULL); - if (ret < 0) { + ret = evaluation->serialize(evaluation, buf); + if (ret) { goto end; } - offset += ret; } - - ret = offset; end: return ret; }