[libc-commits] [PATCH] D147981: [LIBC] Fix `getrandom` success return value
Noah Goldstein via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Apr 12 17:05:16 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee361a3fabb1: [LIBC] Fix `getrandom` success return value (authored by goldstein.w.n).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147981/new/
https://reviews.llvm.org/D147981
Files:
libc/src/sys/random/linux/getrandom.cpp
libc/test/src/sys/random/linux/getrandom_test.cpp
Index: libc/test/src/sys/random/linux/getrandom_test.cpp
===================================================================
--- libc/test/src/sys/random/linux/getrandom_test.cpp
+++ libc/test/src/sys/random/linux/getrandom_test.cpp
@@ -29,6 +29,15 @@
libc_errno = 0;
}
+TEST(LlvmLibcGetRandomTest, ReturnsSize) {
+ static constexpr size_t SIZE = 8192;
+ uint8_t buf[SIZE];
+ for (size_t i = 0; i < SIZE; ++i) {
+ // Without GRND_RANDOM set this should never fail.
+ ASSERT_EQ(__llvm_libc::getrandom(buf, i, 0), static_cast<ssize_t>(i));
+ }
+}
+
TEST(LlvmLibcGetRandomTest, PiEstimation) {
static constexpr size_t LIMIT = 10000000;
static constexpr double PI = 3.14159265358979;
Index: libc/src/sys/random/linux/getrandom.cpp
===================================================================
--- libc/src/sys/random/linux/getrandom.cpp
+++ libc/src/sys/random/linux/getrandom.cpp
@@ -23,7 +23,7 @@
libc_errno = -ret;
return -1;
}
- return 0;
+ return ret;
}
} // namespace __llvm_libc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147981.513019.patch
Type: text/x-patch
Size: 1030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230413/2f5fb089/attachment.bin>
More information about the libc-commits
mailing list