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
Conversation
b3fa764
to
076f2a0
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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> | ||
|
||
/**************************************************************************** |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
libs/libc/uuid/lib_uuid_stream.c
Outdated
|
||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */ | ||
|
||
static inline uint16_t be16dec(const void *pp) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Summary
Adds the UUID libc functions specified by OpenGroup here:
https://pubs.opengroup.org/onlinepubs/009629399/toc.htm
Impact
Testing