[Python-checkins] cpython: py_getrandom(): use char* instead of void* for the destination

victor.stinner python-checkins at python.org
Wed Jun 8 04:27:40 EDT 2016


https://hg.python.org/cpython/rev/7e3860ea539e
changeset: 101782:7e3860ea539e
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Jun 08 10:16:50 2016 +0200
summary:
 py_getrandom(): use char* instead of void* for the destination
Fix a "gcc -pedantic" warning on "buffer += n" because buffer type is void*.
files:
 Python/random.c | 13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Python/random.c b/Python/random.c
--- a/Python/random.c
+++ b/Python/random.c
@@ -132,11 +132,14 @@
 * see https://bugs.python.org/issue26839. To avoid this, use the
 * GRND_NONBLOCK flag. */
 const int flags = GRND_NONBLOCK;
+
+ char *dest;
 int n;
 
 if (!getrandom_works)
 return 0;
 
+ dest = buffer;
 while (0 < size) {
 #ifdef sun
 /* Issue #26735: On Solaris, getrandom() is limited to returning up
@@ -150,11 +153,11 @@
 #ifdef HAVE_GETRANDOM
 if (raise) {
 Py_BEGIN_ALLOW_THREADS
- n = getrandom(buffer, n, flags);
+ n = getrandom(dest, n, flags);
 Py_END_ALLOW_THREADS
 }
 else {
- n = getrandom(buffer, n, flags);
+ n = getrandom(dest, n, flags);
 }
 #else
 /* On Linux, use the syscall() function because the GNU libc doesn't
@@ -162,11 +165,11 @@
 * https://sourceware.org/bugzilla/show_bug.cgi?id=17252 */
 if (raise) {
 Py_BEGIN_ALLOW_THREADS
- n = syscall(SYS_getrandom, buffer, n, flags);
+ n = syscall(SYS_getrandom, dest, n, flags);
 Py_END_ALLOW_THREADS
 }
 else {
- n = syscall(SYS_getrandom, buffer, n, flags);
+ n = syscall(SYS_getrandom, dest, n, flags);
 }
 #endif
 
@@ -204,7 +207,7 @@
 return -1;
 }
 
- buffer += n;
+ dest += n;
 size -= n;
 }
 return 1;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /