[asterisk-dev] [Code Review] Add UUID support to Asterisk
wdoekes
reviewboard at asterisk.org
Wed Nov 28 02:24:03 CST 2012
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2217/#review7456
-----------------------------------------------------------
I like the idea. And the inline explanations.
But, I always start my day with a cup of pedantic. Sorry about that ;)
/trunk/main/uuid.c
<https://reviewboard.asterisk.org/r/2217/#comment14240>
+
/* UUID_STR_LEN holds length of textual representation of UUID, including trailing \0 */
That saves the next guy from having to look that up.
/trunk/main/uuid.c
<https://reviewboard.asterisk.org/r/2217/#comment14241>
Perhaps an ast_assert(ret == 0) here? uuid->uu is in an undefined state when uuid_parse returns -1.
And see my preference of malloc over calloc. If the calloc is to make ast_uuid_is_nil() true in the failure case, then that's based on the unspoken assumtion that uu=={0,} equals uuid_is_null(uu).
/trunk/main/uuid.c
<https://reviewboard.asterisk.org/r/2217/#comment14242>
I prefer calloc over malloc. You're going to be overwriting all bits soon anyway.
Someone is going to bring op defensive programming now, but you've read the manpage: "The copied UUID is returned in the location pointed to by dst." No mention of "it's nicer to overwrite NULs".
If the code changes -- e.g. more items are added to the ast_uuid -- then one can revisit the allocations.
/trunk/main/uuid.c
<https://reviewboard.asterisk.org/r/2217/#comment14243>
Good choice of nil over null.
- wdoekes
On Nov. 27, 2012, 6:05 p.m., Mark Michelson wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2217/
> -----------------------------------------------------------
>
> (Updated Nov. 27, 2012, 6:05 p.m.)
>
>
> Review request for Asterisk Developers, Matt Jordan and David Lee.
>
>
> Summary
> -------
>
> This is the first of many parts of the overall goal of improving Asterisk APIs. This adds a UUID API to Asterisk, eventually to be used as a method of uniquely identifying channels and potentially other objects.
>
> The implementation here uses libuuid, which is packaged by all major Linux distributions. The API is basically a wrapper around libuuid's API, but it hides all implementation details in case we want to switch out libraries at some point.
>
> Licensing for libuuid is a bit confusing. On one hand, this online man page (http://linux.die.net/man/3/libuuid) claims that the library is distributed under the LGPL version 2. However, when I downloaded the source for the library on my machine, the code had the 3-clause BSD license printed in the source. In either case, I believe use of external library is license-compatible with Asterisk.
>
> Regarding specific implementation decisions, I think comments in the code should explain why I chose to do things certain ways. Please let me know if anything should be done differently or if you have ideas for tests beyond what I have already included.
>
> I have no idea what is up with the changes listed in autoconfig.h.in. Those changes showed up when I ran the bootstrap.sh script after changing configure.ac.
>
>
> This addresses bug ASTERISK-20725.
> https://issues.asterisk.org/jira/browse/ASTERISK-20725
>
>
> Diffs
> -----
>
> /trunk/configure UNKNOWN
> /trunk/configure.ac 376687
> /trunk/include/asterisk/autoconfig.h.in 376687
> /trunk/include/asterisk/uuid.h PRE-CREATION
> /trunk/main/Makefile 376687
> /trunk/main/asterisk.c 376687
> /trunk/main/uuid.c PRE-CREATION
> /trunk/tests/test_uuid.c PRE-CREATION
>
> Diff: https://reviewboard.asterisk.org/r/2217/diff
>
>
> Testing
> -------
>
> I have included a set of unit tests that exercise all the APIs. They pass when run locally.
>
>
> Thanks,
>
> Mark
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20121128/0f772166/attachment.htm>
More information about the asterisk-dev
mailing list