X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D76D93861013 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1596451558; bh=ZoY08g4UOjN+3LmPOgvDKtygOOPabQ/UbEQWaTd9Dq8=; h=Date:From:To:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Reply-To:Cc:From; b=ngbfnDcx9BcHLzYwGJM4psLyTZN3ybZ0GC9qWrEi0drQj9/1k46AaparjHXB2Fmhh K6ABG/JmbJe+NDZZsGsVtkoZaiW0QL7r2wh/mDlqRYdhH7z34id4JyZPg074YbMS7q hvmZJzq046IaafsNdb/bCeHzcHcE8SSy501/MfMs= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0CA643858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=corinna-cygwin AT cygwin DOT com Date: Mon, 3 Aug 2020 12:45:52 +0200 From: Corinna Vinschen To: Petr Skocik Subject: Re: FD_{SET,ISSET,CLR} macros from sys/select.h triggerring gcc's -Wsign-conversion warnings Message-ID: <20200803104552.GJ460314@calimero.vinschen.de> Mail-Followup-To: Petr Skocik , cygwin AT cygwin DOT com References: <1f188b7e-6dc4-73af-e458-013760210469 AT gmail DOT com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1f188b7e-6dc4-73af-e458-013760210469@gmail.com> X-Provags-ID: V03:K1:7ER4nqbXVhu2glPNsoHGIRMVyNOO59PbFRrrptDRcS8NUeZwIvC KhvhHnFbxmD/RgmF6P3fKFMGzC2MtH8Vm9rNnkCs8ZaYTV7Bcm8f8QqWC8a+F4EXuXAdzvz n4mUfCoOEQAMrAzk2Ls3er47zNywjJo7Ms3U1PPm7FMjBbGoO1V266k8VJt2a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JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: cygwin AT cygwin DOT com Cc: cygwin AT cygwin DOT com Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 073AkOmH011488 Hi Petr, On Aug 2 20:08, Petr Skocik via Cygwin wrote: > Example: > > #include > void f(int X) > { >     fd_set set; >     FD_ZERO(&set); >     FD_SET(X,&set); >     FD_CLR(X+1,&set); >     (void)FD_ISSET(X+2,&set); > } > > causes > > fds.c:7:2: warning: conversion to ‘long unsigned int’ from ‘int’ may > change the sign of the result [-Wsign-conversion] >   FD_SET(X,&set); >   ^~~~~~ > [...] > on gcc with -Wconversion -Wsign-conversion. > > The problem is caused by the following macros: > >     #  define    NFDBITS    (sizeof (fd_mask) * 8)    /* bits per mask */ >     #  define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1L << > ((n) % NFDBITS))) >     #  define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << > ((n) % NFDBITS))) >     #  define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1L << > ((n) % NFDBITS))) > > int-casting the sizeof and using 1UL instead of 1L fixes the problem: Thanks. I pushed a patch which will show up in the next Cygwin release: https://sourceware.org/git/?p=newlib-cygwin.git;a=commitdiff;h=5717262b8ecf Funny enough, while the GLibc version of sys/select.h does not generate these warnings, the same problem still exists in the upstream FreeBSD code. For testing I uploaded a new developer snapshot to https://cygwin.com/snapshots/ You only need to fetch the new sys/select.h file. Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple