[issue27278] py_getrandom() uses an int for syscall() result

2016-06-16 Thread STINNER Victor
STINNER Victor added the comment: > Adding a cast would solve this compiler warning: I changed the code to use the long type. It should fix the warning, even if it was no more a real bug: the original bug was already fixed. I close the issue, it's now solved. -- resolution: -> fixed

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-16 Thread Roundup Robot
Roundup Robot added the comment: New changeset 193f50babfa4 by Victor Stinner in branch '3.5': py_getrandom(): use long type for the syscall() result https://hg.python.org/cpython/rev/193f50babfa4 -- ___ Python tracker

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-14 Thread Martin Panter
Martin Panter added the comment: Yeah I think your change is enough. Adding a cast would solve this compiler warning: Python/random.c:168:17: warning: conversion to ‘int’ from ‘long int’ may alter its value [-Wconversion] n = syscall(SYS_getrandom, dest, n, flags);

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-14 Thread STINNER Victor
STINNER Victor added the comment: Martin: What do you think of my change? Is it enough? Or would you prefer an explicit cast on syscall() result? I hesitated to use a wider type since the manual page shows an "int" type, not long. -- ___ Python

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-14 Thread Roundup Robot
Roundup Robot added the comment: New changeset e028e86a5b73 by Victor Stinner in branch '3.5': Fix os.urandom() using getrandom() on Linux https://hg.python.org/cpython/rev/e028e86a5b73 New changeset 0d39bd9028e8 by Victor Stinner in branch 'default': Merge 3.5 (os.urandom, issue #27278)

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-09 Thread Martin Panter
Martin Panter added the comment: Make that INT_MAX. Or change n from an int to a Py_ssize_t. Both Linux and Solaris versions or getrandom() are documented as accepting size_t buflen. -- ___ Python tracker

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-09 Thread Martin Panter
Martin Panter added the comment: According to , getrandom() returns no more than 32 MiB as an int on Linux. Doesn’t that mean you can rely on syscall()’s long return value fitting in an int? Maybe just cast n = (int)sycall(...) to be

[issue27278] py_getrandom() uses an int for syscall() result

2016-06-09 Thread STINNER Victor
New submission from STINNER Victor: syscall() result type is long. Moreover, long type might can smaller than the size type, so we may need to add: n = Py_MIN(size, LONG_MAX); -- messages: 267969 nosy: haypo priority: normal severity: normal status: open title: py_getrandom() uses an