Fix type of getlogin_r's 2nd argument
https://rubyci.org/logs/rubyci.s3.amazonaws.com/freebsd12/ruby-master/log/20200821T223002Z.fail.html.gz ``` process.c:5593:37: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32] while ((gle = getlogin_r(login, loginsize)) != 0) { ~~~~~~~~~~ ^~~~~~~~~ ``` type of getlogin_r's 2nd argument is - int on FreeBSD - https://www.freebsd.org/cgi/man.cgi?query=getlogin_r&apropos=0&sektion=0&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html - size_t on Linux, NetBSD - https://man7.org/linux/man-pages/man3/getlogin_r.3.html - https://www.freebsd.org/cgi/man.cgi?query=getlogin_r&apropos=0&sektion=0&manpath=NetBSD+9.0&arch=default&format=html
This commit is contained in:
parent
a0273d67d0
commit
1ab6034529
@ -5577,6 +5577,12 @@ rb_getlogin(void)
|
||||
|
||||
# ifdef USE_GETLOGIN_R
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
typedef int getlogin_r_size_t;
|
||||
#else
|
||||
typedef size_t getlogin_r_size_t;
|
||||
#endif
|
||||
|
||||
long loginsize = GETLOGIN_R_SIZE_INIT; /* maybe -1 */
|
||||
|
||||
if (loginsize < 0)
|
||||
@ -5590,7 +5596,7 @@ rb_getlogin(void)
|
||||
|
||||
int gle;
|
||||
errno = 0;
|
||||
while ((gle = getlogin_r(login, loginsize)) != 0) {
|
||||
while ((gle = getlogin_r(login, (getlogin_r_size_t)loginsize)) != 0) {
|
||||
|
||||
if (gle == ENOTTY || gle == ENXIO || gle == ENOENT) {
|
||||
rb_str_resize(maybe_result, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user