From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 2A7881F8C6 for ; Thu, 8 Jul 2021 14:18:12 +0000 (UTC) Received: from localhost ([::1]:35832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Uqw-0003kJ-V5 for normalperson@yhbt.net; Thu, 08 Jul 2021 10:18:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1Uqt-0003h8-Eo for bug-gnulib@gnu.org; Thu, 08 Jul 2021 10:18:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38938) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Uqs-0004QJ-3v for bug-gnulib@gnu.org; Thu, 08 Jul 2021 10:18:07 -0400 Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4096 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1Uqr-0007aG-OH for bug-gnulib@gnu.org; Thu, 08 Jul 2021 10:18:06 -0400 Date: Thu, 08 Jul 2021 17:17:55 +0300 Message-Id: <831r88evos.fsf@gnu.org> From: Eli Zaretskii To: bug-gnulib@gnu.org Subject: Missing type cast in select.c X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Compiling Gnulib's select.c with mingw.org's MinGW produces the following warnings: In file included from select.c:24: select.c: In function 'rpl_select': select.c:534:25: warning: passing argument 1 of 'rpl_fd_isset' makes integer from pointer without a cast [-Wint-conversion] 534 | if (FD_ISSET (h, &handle_rfds)) | ^ | | | HANDLE {aka void *} ./sys/select.h:640:22: note: expected 'SOCKET' {aka 'unsigned int'} but argument is of type 'HANDLE' {aka 'void *'} 640 | rpl_fd_isset (SOCKET fd, fd_set * set) | ~~~~~~~^~ select.c:536:25: warning: passing argument 1 of 'rpl_fd_isset' makes integer from pointer without a cast [-Wint-conversion] 536 | if (FD_ISSET (h, &handle_wfds)) | ^ | | | HANDLE {aka void *} ./sys/select.h:640:22: note: expected 'SOCKET' {aka 'unsigned int'} but argument is of type 'HANDLE' {aka 'void *'} 640 | rpl_fd_isset (SOCKET fd, fd_set * set) | ~~~~~~~^~ select.c:538:25: warning: passing argument 1 of 'rpl_fd_isset' makes integer from pointer without a cast [-Wint-conversion] 538 | if (FD_ISSET (h, &handle_xfds)) | ^ | | | HANDLE {aka void *} ./sys/select.h:640:22: note: expected 'SOCKET' {aka 'unsigned int'} but argument is of type 'HANDLE' {aka 'void *'} 640 | rpl_fd_isset (SOCKET fd, fd_set * set) | ~~~~~~~^~ This happens because select.c does: HANDLE h, handle_array[FD_SETSIZE + 2]; ... h = (HANDLE) _get_osfhandle (i); if (h != handle_array[nhandles]) { /* Perform handle->descriptor mapping. */ WSAEventSelect ((SOCKET) h, NULL, 0); if (FD_ISSET (h, &handle_rfds)) FD_SET (i, rfds); if (FD_ISSET (h, &handle_wfds)) FD_SET (i, wfds); if (FD_ISSET (h, &handle_xfds)) FD_SET (i, xfds); } However, FD_ISSET macro on native MS-Windows, and therefore Gnulib's rpl_fd_isset as well, expect a SOCKET argument: static int rpl_fd_isset (SOCKET fd, fd_set * set) { Suggested fix: --- gnulib/import/select.c~ 2021-07-03 20:41:11.000000000 +0300 +++ gnulib/import/select.c 2021-07-08 17:05:05.471160600 +0300 @@ -531,11 +531,11 @@ restart: { /* Perform handle->descriptor mapping. */ WSAEventSelect ((SOCKET) h, NULL, 0); - if (FD_ISSET (h, &handle_rfds)) + if (FD_ISSET ((SOCKET) h, &handle_rfds)) FD_SET (i, rfds); - if (FD_ISSET (h, &handle_wfds)) + if (FD_ISSET ((SOCKET) h, &handle_wfds)) FD_SET (i, wfds); - if (FD_ISSET (h, &handle_xfds)) + if (FD_ISSET ((SOCKET) h, &handle_xfds)) FD_SET (i, xfds); } else