Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random.h: add doxygen comments #1683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mvandenhoek
Copy link
Contributor

Aside from the comments, I added missing DDS_EXPORT, as I can't think of any good reason to expose 'ddsrt_random' but not the variant that uses a seed.

Signed-off-by: Michel van den Hoek <[email protected]>
@mvandenhoek
Copy link
Contributor Author

@eboasson Could you please re-run the checks, since this predates the Misra check fix?

Copy link
Contributor

@eboasson eboasson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't figured out how to restart the MISRA check taking into account the changes on master since it ran. Updating this PR might fix that, and fortunately I have found something to nitpick in the comments, to give you a good excuse to push an update 😀 Thanks!

*
* Pseudo random number generator known as the Mersenne Twister.
* It generates uint32_t from a uniform distribution in the range 0 to 0xffffffff (the maximum value of uint32_t).
* A useful property is that the use of a fixed seed allows you to reproduce
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true, but it is also the very definition of a PRNG and, I would hope, common knowledge amongst all software developers. So in my view, it should not be in the documentation.

Given that there are a few other changes that I would like to see, perhaps you can remove this, too.

@@ -22,23 +31,102 @@ extern "C" {

#define DDSRT_MT19937_N 624

/** @brief A composite seed consisting of multiple smaller seeds */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be seen as a "composite" seed: it is simply a 256-bit seed.

uint32_t ddsrt_prng_random (ddsrt_prng_t *prng);
size_t ddsrt_prng_random_name(ddsrt_prng_t *prng, char* output, size_t output_size);
/**
* @brief Initialize the pseudo random number generator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not initialising "the PRNG" but rather initialising "the global PRNG", the one that ddsrt_random uses. You can safely init/use your own PRNGs.

I think it would be wise to make this a bit more obvious in the @brief description.

Signed-off-by: Michel van den Hoek <[email protected]>
@eboasson
Copy link
Contributor

Hi @mvandenhoek I did overlook the update until now, but I can't merge it yet because of the one failing CI build. The logs have been disappeared by Azure, here is a fresh one: https://dev.azure.com/eclipse-cyclonedds/cyclonedds/_build/results?buildId=4629&view=logs&j=f8a8db55-af06-546d-2cb0-cb4efb6f4971&t=a6dfd95d-d3ae-597e-db63-5274130d1879 I'm fine with exporting the handful of additional functions, but the CI checks the actually exported symbols against the list of allowed symbols and that has not been updated yet ...

@mvandenhoek
Copy link
Contributor Author

Hi @mvandenhoek I did overlook the update until now, but I can't merge it yet because of the one failing CI build. The logs have been disappeared by Azure, here is a fresh one: https://dev.azure.com/eclipse-cyclonedds/cyclonedds/_build/results?buildId=4629&view=logs&j=f8a8db55-af06-546d-2cb0-cb4efb6f4971&t=a6dfd95d-d3ae-597e-db63-5274130d1879 I'm fine with exporting the handful of additional functions, but the CI checks the actually exported symbols against the list of allowed symbols and that has not been updated yet ...

Has the CI been updated yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants