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

libc: Add uuid implemenation #1440

Merged
merged 1 commit into from Jul 22, 2020
Merged

libc: Add uuid implemenation #1440

merged 1 commit into from Jul 22, 2020

Conversation

xiaoxiang781216
Copy link
Contributor

@xiaoxiang781216 xiaoxiang781216 commented Jul 21, 2020

Summary

Adds the UUID libc functions specified by OpenGroup here:
https://pubs.opengroup.org/onlinepubs/009629399/toc.htm

Impact

Testing

Copy link
Contributor

@btashton btashton left a comment

Choose a reason for hiding this comment

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

I have some concerns about where this implementation came from. It looks to be NetBSD.


/* The UUID string representation has a fixed length. */

if (strlen(s) != UUID_STR_LEN)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we protect this with strnlen(s, UUID_STR_LEN+1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

#include <endian.h>
#include <uuid.h>

/****************************************************************************
Copy link
Contributor

Choose a reason for hiding this comment

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

Did this code come from NetBSD? It looks a lot like the code here
http://mirrors.mit.edu/NetBSD/NetBSD-release-7/src/lib/libc/uuid/uuid_stream.c

If so my understanding is that we would leave the BSD headers on this and call it out in the LICENSE file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code is rewritten from scratch now. Should we put some note in LICENSE file?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is fine now. Most of these functions are trivial especially with us using our existing endian code.


/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */

static inline uint16_t be16dec(const void *pp)
Copy link
Contributor

Choose a reason for hiding this comment

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

These endian functions dont seem to be uuid specific. Normally they are defined via <machine/endian.h> or <endian.h> OS specific location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

specified by OpenGroup here:
https://pubs.opengroup.org/onlinepubs/009629399/toc.htm

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I3bc585e7f4d41f6c2ea70e170276ab0d0399b088
@btashton btashton merged commit 6c03a4e into apache:master Jul 22, 2020
@xiaoxiang781216 xiaoxiang781216 deleted the uuid branch July 22, 2020 06:08
@btashton btashton added this to To-Add in Release Notes - 10.0.0 Oct 14, 2020
@btashton btashton moved this from To-Add to Added in Release Notes - 10.0.0 Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants