summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-06-08 08:16:50 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-06-08 08:16:50 (GMT)
commitcfb1961f6127ddc6e1b8920d4f125142bace2dac (patch)
tree7b2c29a79df6043be8b9545693eaa63f8674d1a4 /Python
parent24a72ca2391bcd3b951675d279763ac8bb78c98e (diff)
downloadcpython-cfb1961f6127ddc6e1b8920d4f125142bace2dac.zip
cpython-cfb1961f6127ddc6e1b8920d4f125142bace2dac.tar.gz
cpython-cfb1961f6127ddc6e1b8920d4f125142bace2dac.tar.bz2
py_getrandom(): use char* instead of void* for the destination
Fix a "gcc -pedantic" warning on "buffer += n" because buffer type is void*.
Diffstat (limited to 'Python')
-rw-r--r--Python/random.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/random.c b/Python/random.c
index ef3a4cd..cd8d945 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -132,11 +132,14 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
* 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 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
#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 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
* 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 @@ py_getrandom(void *buffer, Py_ssize_t size, int raise)
return -1;
}
- buffer += n;
+ dest += n;
size -= n;
}
return 1;