Return the actual default partition in dds_qget_partition() whenever possible #1824
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have run into an issue related to dds_qget_partition() a number of times. Just recently it reached my annoyance threshold level, so I decided to make a pull request for it.
The issue has to do with dds_qget_partition() related to the default partition. Currently, the behaviour of dds_qget_partition() is to return zero as the number of partition and a NULL-ish list of partitions in case the partition is the default partition (i.e., ""). According to the DDS specification is perfectly legitimate, so from a functional point of view I have no problem with this whatsoever.
However, from a useability point of view I do have problem with it. Typically, in application code that needs to access the code you do something like this:
For the default partition this doesn't work, because the default partition is treated differently: it returns n=0 in that case, so it suggests that there are no partition at all! As a consequence, an application developer needs to treat the default partition case as a special case, in order to deal with the default partition. This is a pity, because it complicates code writing for an application deveoper. And it is easy to forget that the default partition should be treated differently.
To makes life for application developers a little bit easier I suggest to treat the default partition case similar as normal partitions whenever possible. That means that when
dds_qget_partition(qos, &n, &partitions)
is called and the default partition must be returned, then it returns n=1 and partitions[0]="" for the default partition (provided &n and &partitions are non-NULL). In this way an application developer can handle the default partition that is returned from dds_qget_partition() similar as partitions.This pull request contains the fix that changes the behaviour of dds_qget_partition() for the default partition. In case you share my viewpoints regarding this issue, I would appreciate if you can have a look at this pull request.