From 642b64709549c023e8b867c2857514d9ac4316f0 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Wed, 6 May 2026 11:29:07 +0200 Subject: [PATCH 1/2] Update for changes in dds_stream_normalize --- clayer/pysertype.c | 16 ++++++++-------- .../fuzz_tools/rand_idl/c_app/xtypes_sub.c | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clayer/pysertype.c b/clayer/pysertype.c index 5a9a22f..e1a62dd 100644 --- a/clayer/pysertype.c +++ b/clayer/pysertype.c @@ -192,7 +192,7 @@ static bool ddspy_serdata_populate_key (ddspy_serdata_t *this) // well-formed inputs. So we'd better check. void * const cdr_data = (char *)this->data + 4; uint32_t act_size; - if (!dds_stream_normalize (cdr_data, (uint32_t)this->data_size - 4, needs_bswap, xcdr_version, &csertype(this)->cdrstream_desc, (this->c_data.kind == SDK_KEY), &act_size)) + if (dds_stream_normalize (cdr_data, (uint32_t)this->data_size - 4, needs_bswap, xcdr_version, &csertype(this)->cdrstream_desc, (this->c_data.kind == SDK_KEY), &act_size) != DDS_STREAM_NORMALIZE_SUCCESS) return false; // Fixup encoding header if we byte-swapped the contents if (needs_bswap) @@ -414,7 +414,7 @@ static bool serdata_typeless_to_sample (const struct ddsi_sertype *type, const s switch (pyst->cdrstream_desc.ops.ops[0]) { case DDS_OP_PLC: header.enc = DDSI_RTPS_PL_CDR_BE; break; default: header.enc = DDSI_RTPS_CDR_BE; break; - } + } } #elif DDSRT_ENDIAN == DDSRT_LITTLE_ENDIAN if (pysd->is_v2) { @@ -427,7 +427,7 @@ static bool serdata_typeless_to_sample (const struct ddsi_sertype *type, const s switch (pyst->cdrstream_desc.ops.ops[0]) { case DDS_OP_PLC: header.enc = DDSI_RTPS_PL_CDR_LE; break; default: header.enc = DDSI_RTPS_CDR_LE; break; - } + } } #else #error "endianness not set properly" @@ -752,7 +752,7 @@ static ddspy_sertype_t *ddspy_sertype_new (PyObject *pytype) const dds_data_type_properties_t data_type_props = PyLong_AsUnsignedLongLong (pydata_type_props); const bool keyless = !(data_type_props & DDS_DATA_TYPE_CONTAINS_KEY); - + new = dds_alloc (sizeof (ddspy_sertype_t)); Py_INCREF (pytype); @@ -853,7 +853,7 @@ static dds_return_t init_cdrstream_descriptor (ddspy_sertype_t *sertype) goto err; } - dds_topic_descriptor_t desc; + dds_topic_descriptor_t desc = {0}; if ((ret = ddsi_topic_descriptor_from_type (gv, &desc, ddsi_type)) != DDS_RETCODE_OK) goto err; @@ -1135,7 +1135,7 @@ static PyObject *readtake_post (int32_t sts, collector_state_t *state) for (size_t i = 0; i < state->count; ++i) { PyObject *sampleinfo = get_sampleinfo_pyobject(&state->sample_infos[i]); - PyObject *item = Py_BuildValue("(y#O)", + PyObject *item = Py_BuildValue("(y#O)", state->containers[i].usample, (Py_ssize_t)state->containers[i].usample_size, sampleinfo); @@ -1163,7 +1163,7 @@ dds_return_t collector_callback_fn( // Grow allocation, this ensures amortized linear growth while keeping allocation calls minimal. // Doubling gives exponential growth this makes adding N items only require log2(N) reallocations - efficient! size_t new_capacity = state->capacity ? state->capacity * 2 : 8; - + void *new_containers = dds_realloc(state->containers, new_capacity * sizeof(ddspy_sample_container_t)); void *new_infos = dds_realloc(state->sample_infos, new_capacity * sizeof(dds_sample_info_t)); @@ -1460,7 +1460,7 @@ static PyObject *ddspy_calc_key (PyObject *self, PyObject *args) PyBuffer_Release (&sample_data); // Extract key in correct CDR version (pyserdata->key is now always XCDR2) - const uint32_t xcdr_version = pyserdata->is_v2 ? DDSI_RTPS_CDR_ENC_VERSION_2 : DDSI_RTPS_CDR_ENC_VERSION_1; + const enum dds_cdr_enc_version xcdr_version = pyserdata->is_v2 ? DDSI_RTPS_CDR_ENC_VERSION_2 : DDSI_RTPS_CDR_ENC_VERSION_1; dds_ostream_t os; dds_ostream_init (&os, &cdrstream_allocator, 0, xcdr_version); dds_istream_t is; diff --git a/tests/support_modules/fuzz_tools/rand_idl/c_app/xtypes_sub.c b/tests/support_modules/fuzz_tools/rand_idl/c_app/xtypes_sub.c index 343979c..36ca34f 100644 --- a/tests/support_modules/fuzz_tools/rand_idl/c_app/xtypes_sub.c +++ b/tests/support_modules/fuzz_tools/rand_idl/c_app/xtypes_sub.c @@ -134,7 +134,7 @@ static bool topic_desc_eq (const dds_topic_descriptor_t * generated_desc, const return true; } -static uint16_t xcdr_version_from_enc_identifier (uint16_t enc_identifier) +static enum dds_cdr_enc_version xcdr_version_from_enc_identifier (uint16_t enc_identifier) { switch (enc_identifier) { @@ -365,8 +365,8 @@ int main(int argc, char **argv) assert(ref.iov_len == data_sz); assert(ref.iov_base); dds_istream_t sampstream = { - .m_buffer = ref.iov_base, - .m_size = data_sz, + .m_buffer = ref.iov_base, + .m_size = data_sz, .m_index = 0, .m_xcdr_version = keystream.m_xcdr_version }; From d51e4eb38487b00d25b8cb12832a6b55e43e1739 Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Mon, 10 Aug 2026 14:02:24 +0200 Subject: [PATCH 2/2] Union member ids start at 1 in XTypes 1.3 --- cyclonedds/idl/_main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cyclonedds/idl/_main.py b/cyclonedds/idl/_main.py index 8263109..f92f430 100644 --- a/cyclonedds/idl/_main.py +++ b/cyclonedds/idl/_main.py @@ -88,10 +88,14 @@ def populate_locked(self): self.xcdrv1_head = 0x00 self.xcdrv2_head = 0x06 + # Unions start numbering at 1 in XTypes + # I would've liked issubclass(..., IdlUnion), IdlUnion hasn't been defined yet + isunion = any(base.__name__ == "IdlUnion" for base in self.datatype.__mro__) + if self.member_ids is None: ids = {} is_hash_id = annotations.get("autoid", "sequential") == "hash" - idc = 0 + idc = 1 if isunion else 0 for name, _ in get_extended_type_hints(self.datatype).items(): f_annot = field_annotations.get(name, {})