From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Bruno Haible Newsgroups: gmane.emacs.devel,gmane.comp.lib.gnulib.bugs Subject: Re: New warnings on emacs-26 branch with gcc 8.2.0 Date: Sat, 18 Aug 2018 23:25:56 +0200 Message-ID: <2510628.alnMaqBdeU@omega> References: <86a7q0ai2z.fsf@gmail.com> <4195986.6xTypejAr3@omega> <83d0uffrft.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: blaine.gmane.org 1534627458 8003 195.159.176.226 (18 Aug 2018 21:24:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Aug 2018 21:24:18 +0000 (UTC) User-Agent: KMail/5.1.3 (Linux/4.4.0-130-generic; KDE/5.18.0; x86_64; ; ) Cc: andrewjmoreton@gmail.com, eggert@cs.ucla.edu, bug-gnulib@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 18 23:24:14 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fr8hh-0001xa-MS for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 23:24:14 +0200 Original-Received: from localhost ([::1]:40564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr8jn-0002Y8-Kl for ged-emacs-devel@m.gmane.org; Sat, 18 Aug 2018 17:26:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fr8jc-0002X1-Ox for emacs-devel@gnu.org; Sat, 18 Aug 2018 17:26:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fr8jb-0005qq-T5 for emacs-devel@gnu.org; Sat, 18 Aug 2018 17:26:12 -0400 Original-Received: from mo6-p01-ob.smtp.rzone.de ([2a01:238:20a:202:5301::4]:31794) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fr8jY-0005om-80; Sat, 18 Aug 2018 17:26:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1534627566; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=APvj82eKro0N8sir7CJGP3i/y0vc/sNjwzPIkgvpiZY=; b=bxajVNcSWM9V//pye9KxlpovqrwRxZCCBMVX19Mam8DaCkT1RBmf07sYx1cR1x/029 mzOofva3rndMZF/XNzyV20EhCc4YANwtDcQWR/WARVD2x1lsL7uhQHOOiySwgvZ8Chvk 5X4Kbp8rZqMPg2nW9s3Ni3WTy97md0jG0lUVDn649mT/+njVxDPCvllm/9q2brNYBNn9 rh/dpAcwA9oHMPIcdO8wxWWrju4lzRRIIUfFXqQuBGuleY1CQ/nnTlpzOWk3eU8dqy93 GOyp2Z7xbQKMcD9oXFKxBmNKqbqQX5kfEKFkt+XOgbe2LkhwNAIuamSKDKwXezWK4eOh lw0w== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqf9yfs=" X-RZG-CLASS-ID: mo00 Original-Received: from bruno.haible.de by smtp.strato.de (RZmta 43.18 DYNA|AUTH) with ESMTPSA id n0457au7ILPvLQA (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sat, 18 Aug 2018 23:25:57 +0200 (CEST) In-Reply-To: <83d0uffrft.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5301::4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228670 gmane.comp.lib.gnulib.bugs:39223 Archived-At: Eli Zaretskii wrote: > There's also this additional option: > > 5) Cast through (void *). Like this: > > GetSystemTimePreciseAsFileTimeFunc = > (GetSystemTimePreciseAsFileTimeFuncType) (void (*) (void)) GetProcAddress (kernel32, "GetSystemTimePreciseAsFileTime"); Indeed, casting through (void *) or (void (*) (void)) avoids the warning. I'm going to test this patch: 2018-08-18 Bruno Haible Avoid -Wcast-function-type warnings from casts after GetProcAddress. Reported by Andy Moreton in . Solution proposed by Eli Zaretskii. * lib/getaddrinfo.c (GetProcAddress): Cast result to 'void *' first. * lib/gettimeofday.c (GetProcAddress): Likewise. * lib/link.c (GetProcAddress): Likewise. * lib/physmem.c (GetProcAddress): Likewise. * lib/poll.c (GetProcAddress): Likewise. * lib/select.c (GetProcAddress): Likewise. * lib/stat-w32.c (GetProcAddress): Likewise. diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 756c31b..7bf38e8 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -62,6 +62,11 @@ #include "sockets.h" #ifdef WINDOWS_NATIVE + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, const struct addrinfo*, struct addrinfo**); diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index bff40d7..36b5074 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -33,6 +33,10 @@ #ifdef WINDOWS_NATIVE +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */ typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime); static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL; diff --git a/lib/link.c b/lib/link.c index bf0b344..cff54a2 100644 --- a/lib/link.c +++ b/lib/link.c @@ -30,6 +30,10 @@ # define WIN32_LEAN_AND_MEAN # include +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + /* CreateHardLink was introduced only in Windows 2000. */ typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName, LPCTSTR lpExistingFileName, diff --git a/lib/physmem.c b/lib/physmem.c index cbb33ac..c89c0f0 100644 --- a/lib/physmem.c +++ b/lib/physmem.c @@ -59,8 +59,14 @@ #endif #ifdef _WIN32 + # define WIN32_LEAN_AND_MEAN # include + +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + /* MEMORYSTATUSEX is missing from older windows headers, so define a local replacement. */ typedef struct @@ -76,6 +82,7 @@ typedef struct DWORDLONG ullAvailExtendedVirtual; } lMEMORYSTATUSEX; typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*); + #endif #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) diff --git a/lib/poll.c b/lib/poll.c index 26f7f12..576ec9f 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -84,6 +84,10 @@ of SOCKETs, not bit masks of FDs. */ # undef select +/* Avoid warnings from gcc -Wcast-function-type. */ +# define GetProcAddress \ + (void *) GetProcAddress + static BOOL IsConsoleHandle (HANDLE h) { DWORD mode; diff --git a/lib/select.c b/lib/select.c index 3659cb5..ffb58ee 100644 --- a/lib/select.c +++ b/lib/select.c @@ -47,6 +47,10 @@ #undef select +/* Avoid warnings from gcc -Wcast-function-type. */ +#define GetProcAddress \ + (void *) GetProcAddress + struct bitset { unsigned char in[FD_SETSIZE / CHAR_BIT]; unsigned char out[FD_SETSIZE / CHAR_BIT]; diff --git a/lib/stat-w32.c b/lib/stat-w32.c index 802b38a..c7a53f9 100644 --- a/lib/stat-w32.c +++ b/lib/stat-w32.c @@ -38,6 +38,10 @@ #include "pathmax.h" #include "verify.h" +/* Avoid warnings from gcc -Wcast-function-type. */ +#define GetProcAddress \ + (void *) GetProcAddress + #if _GL_WINDOWS_STAT_INODES == 2 /* GetFileInformationByHandleEx was introduced only in Windows Vista. */ typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,