From: Keith Marshall Date: Thu, 6 Sep 2018 18:50:09 +0000 (+0100) Subject: Avoid unwanted GCC warning diagnostic messages. X-Git-Tag: wsl-5.2-release~21 X-Git-Url: http://git.osdn.net/view?p=mingw%2Fmingw-org-wsl.git;a=commitdiff_plain;h=ff040e9e04c6131ea2690c5945ada1ff79ceeb57 Avoid unwanted GCC warning diagnostic messages. --- diff --git a/mingwrt/ChangeLog b/mingwrt/ChangeLog index ae5a57b..4f0509c 100644 --- a/mingwrt/ChangeLog +++ b/mingwrt/ChangeLog @@ -1,3 +1,46 @@ +2018-09-06 Keith Marshall + + Avoid unwanted GCC warning diagnostic messages. + + * Makefile.in (libm_dummy.c): Remove "static" qualifier from... + (__mingw_libm_dummy): ...this variable; it caused "-Wunused-variable" + warning diagnostics, when compiled with "-Wall". + + * main.c (WinMain): Remove unnecessary argument names from prototype. + (main): Make its argument list conform to convention, otherwise it + causes a "-Wmain" warning diagnostic when compiled with "-Wall". + + * mingwex/clocktime.c (clock_gettime) [clock_id-type] + * mingwex/clockapi.c (clock_api_getres_interval) [clock_api->type]: + Ensure that switches include default cases; this avoids a "-Wswitch" + warning diagnostic message, in each case, when compiled with "-Wall". + + * mingwex/cryptnam.c (crypto_random_filename_char): Remove "unsigned" + qualifier from both argument and return type; this avoids an argument + type mismatch, raising a "-Wpointer-sign" warning when called from... + (__mingw_crypto_tmpname): ...here, and compiled with "-Wall". + + * mingwex/imaxdiv.c: Tidy layout; assert copyright. + (lldiv): Correct return type; explicitly disable "-Wattribute-alias" + diagnostic messages, under GCC pragma control. + + * mingwex/ofmt.c [__crtofmt__] (__mingw_set_output_format_fallback) + [__crtnfmt__] (__mingw_get_printf_count_output_fallback): Likewise, + disable "-Wattribute-alias" diagnostics. + + * mingwrt/mingwex/stdio/pformat.c (__pformat_ignore_flags): Adjust + layout, to avoid a "-Wmisleading-indentation" warning diagnostic. + (__pformat_argmap) [length]: Add a no-op default case, to avoid a + "-Wswitch" warning diagnostic message. + + * mingwrt/profile/mcount.c: Explicitly disable "-Wframe-address" + diagnostics, under GCC pragma control, to avoid warnings relating... + (__builtin_return_address): ...this, when called from... + (mcount): ...here. + + * mingwrt/setargv.c (__mingw_setargv): Insert parentheses, as advised, + to eliminate "-Wparentheses" diagnostic messages. + 2018-09-03 Keith Marshall Prepare and publish MinGW.org WSL-5.1.1 release. diff --git a/mingwrt/Makefile.in b/mingwrt/Makefile.in index 0a12baf..514f395 100644 --- a/mingwrt/Makefile.in +++ b/mingwrt/Makefile.in @@ -7,7 +7,7 @@ PACKAGE_TARNAME := @PACKAGE_TARNAME@ PACKAGE_VERSION := @PACKAGE_VERSION@ # Written by Keith Marshall -# Copyright (C) 2014-2017, MinGW.org Project +# Copyright (C) 2014-2018, MinGW.org Project # # # Permission is hereby granted, free of charge, to any person obtaining a @@ -508,7 +508,7 @@ x87%.$(OBJEXT): %_generic.sx all-mingwrt-libs install-mingwrt-libs: libm.a libm.a: libm_dummy.$(OBJEXT) libm_dummy.c: Makefile - echo "static int __mingw_libm_dummy;" > $@ + echo "int __mingw_libm_dummy;" > $@ # The mingwrt headers define a number of functions which are normally # expected to be compiled as inline code. Each such function must also diff --git a/mingwrt/main.c b/mingwrt/main.c index ea0d3cd..1dd033c 100644 --- a/mingwrt/main.c +++ b/mingwrt/main.c @@ -1,5 +1,6 @@ /* * main.c + * * This file has no copyright assigned and is placed in the Public Domain. * This file is a part of the mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER within the package. @@ -9,22 +10,19 @@ * applications, but they don't *have* to be. * */ - #include #include #include #define ISSPACE(a) (a == ' ' || a == '\t') -extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, - LPSTR szCmdLine, int nShow); +extern int PASCAL WinMain (HINSTANCE, HINSTANCE, LPSTR, int); int -main (int argc, char *argv[], char *environ[]) +main (int argc, char *argv[], char **envp) { char *szCmd; STARTUPINFO startinfo; - int nRet; /* Get the command line passed to the process. */ szCmd = GetCommandLineA (); @@ -70,10 +68,10 @@ main (int argc, char *argv[], char *environ[]) } } - nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, - (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? - startinfo.wShowWindow : SW_SHOWDEFAULT); - - return nRet; + return WinMain( GetModuleHandle (NULL), NULL, szCmd, + (startinfo.dwFlags & STARTF_USESHOWWINDOW) + ? startinfo.wShowWindow + : SW_SHOWDEFAULT + ); } diff --git a/mingwrt/mingwex/clockapi.c b/mingwrt/mingwex/clockapi.c index 3167616..20b8da0 100644 --- a/mingwrt/mingwex/clockapi.c +++ b/mingwrt/mingwex/clockapi.c @@ -6,7 +6,7 @@ * $Id$ * * Written by Keith Marshall - * Copyright (C) 2017, MinGW.org Project + * Copyright (C) 2017, 2018, MinGW.org Project * * * Permission is hereby granted, free of charge, to any person obtaining a @@ -107,6 +107,13 @@ int64_t clock_api_getres_interval( clockid_t clock_api ) if( QueryPerformanceFrequency( &freq.qpc_value ) && (freq.value > 0LL) ) return clock_api->resolution = NANOSECONDS_PER_SECOND / (clock_api->frequency = freq.value); + + /* In any other case, (implicitly including CLOCK_TYPE_UNIMPLEMENTED), + * we may simply fall through to the default error return, (but note + * that we specify a "do-nothing" default case handler, to suppress + * possible GCC -Wswitch warnings). + */ + default: break; } /* If we get to here, initialization of the specified clock failed; set diff --git a/mingwrt/mingwex/clocktime.c b/mingwrt/mingwex/clocktime.c index 91c6c91..b078e96 100644 --- a/mingwrt/mingwex/clocktime.c +++ b/mingwrt/mingwex/clocktime.c @@ -6,7 +6,7 @@ * $Id$ * * Written by Keith Marshall - * Copyright (C) 2017, MinGW.org Project + * Copyright (C) 2017, 2018, MinGW.org Project * * * Permission is hereby granted, free of charge, to any person obtaining a @@ -68,11 +68,16 @@ int clock_gettime( clockid_t clock_id, struct timespec *current ) /* Conversely, the counter for CLOCK_MONOTIME and derivatives * is obtained from the Windows QPC API, if supported... */ - if( QueryPerformanceCounter( &ct.qpc_value ) == 0 ) - /* - * ...or forces an "invalid status" return, otherwise. - */ - return clock_api_invalid_error(); + if( QueryPerformanceCounter( &ct.qpc_value ) > 0 ) + break; + + /* ...or otherwise, fall through, to force an "invalid status" + * return, as we do for any other clock type designation, (which + * implicitly includes CLOCK_TYPE_UNIMPLEMENTED; note that this + * is incorporated into a default case handler, to suppress any + * GCC -Wswitch warnings which might otherwise be diagnosed). + */ + default: return clock_api_invalid_error(); } /* In either case, once we have a valid count of clock ticks, we * must adjust it, relative to the timebase for the clock, (which diff --git a/mingwrt/mingwex/cryptnam.c b/mingwrt/mingwex/cryptnam.c index f7f6a0a..4b6eac4 100644 --- a/mingwrt/mingwex/cryptnam.c +++ b/mingwrt/mingwex/cryptnam.c @@ -10,7 +10,7 @@ * $Id$ * * Written by Keith Marshall - * Copyright (C) 2013, 2014, MinGW.org Project. + * Copyright (C) 2013, 2014, 2018, MinGW.org Project. * * * Permission is hereby granted, free of charge, to any person obtaining a @@ -94,7 +94,7 @@ CRYPTO_INLINE void *crypto_randomize( void *buf, size_t buflen ) return NULL; } -CRYPTO_INLINE unsigned char *crypto_random_filename_char( unsigned char *caret ) +CRYPTO_INLINE char *crypto_random_filename_char( char *caret ) { /* Helper to generate a random sequence of characters, suitable for * use in file names; although there are other valid possibilities, we diff --git a/mingwrt/mingwex/imaxdiv.c b/mingwrt/mingwex/imaxdiv.c index 10ff1a7..26124ce 100644 --- a/mingwrt/mingwex/imaxdiv.c +++ b/mingwrt/mingwex/imaxdiv.c @@ -1,25 +1,61 @@ /* - This source code was extracted from the Q8 package created and - placed in the PUBLIC DOMAIN by Doug Gwyn - last edit: 1999/11/05 gwyn@arl.mil + * imaxdiv.c + * + * Implements the imaxdiv() function, as specified in ISO/IEC 9899:1999 + * clause 7.8.2.2, and its functionally equivalent lldiv() function, as + * specified in ISO/IEC 9899:1999 clause 7.20.6.2. + * + * $Id$ + * + * Written by Doug Gwyn + * Copyright (C) 1999, 2018, MinGW.org Project. + * + * + * Abstracted from the Q8 package, which was originally placed, by the + * above named author, in the PUBLIC DOMAIN. In any jurisdiction where + * PUBLIC DOMAIN is not acceptable as a licensing waiver, the following + * licence shall apply: + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice, this permission notice, and the following + * disclaimer shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ +#include - - last edit: 1999/11/05 gwyn@arl.mil - - Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). - -*/ - -#include - -imaxdiv_t -imaxdiv(intmax_t numer, intmax_t denom) +imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom) { - imaxdiv_t result; + imaxdiv_t result; result.quot = numer / denom; result.rem = numer % denom; return result; } -long long __attribute__ ((alias ("imaxdiv"))) -lldiv (long long, long long); +/* lldiv() is effectively equivalent to imaxdiv(), so we may implement + * it as an alias. However, the two function prototypes differ in the + * formal data types of their arguments, and return values. Although + * these differing data types are effectively interchangeable, GCC may + * not recognize this, so disable associated warnings. + */ +#pragma GCC diagnostic ignored "-Wattribute-alias" + +#include + +lldiv_t __attribute__ ((alias ("imaxdiv"))) lldiv (long long, long long); + +/* $RCSfile$: end of file */ diff --git a/mingwrt/mingwex/ofmt.c b/mingwrt/mingwex/ofmt.c index 01b8096..497b7fe 100644 --- a/mingwrt/mingwex/ofmt.c +++ b/mingwrt/mingwex/ofmt.c @@ -8,7 +8,7 @@ * $Id$ * * Written by Keith Marshall - * Copyright (C) 2014, 2015, 2017, MinGW.org Project + * Copyright (C) 2014, 2015, 2017, 2018, MinGW.org Project * * * Permission is hereby granted, free of charge, to any person obtaining a @@ -113,15 +113,22 @@ unsigned int __mingw_get_output_format_fallback( void ) return __mingw_output_format_flags & _EXPONENT_DIGIT_MASK; } /* ...and, in the case of _set_output_format(), we simply map the - * requisite name to the common function implementation. + * requisite name to the common function implementation; (note that + * this effectively makes the "set" function a "no-op", ignoring the + * passed argument, but since this argument is inconsistent with the + * "get" function prototype, we suppress related GCC diagnostics). */ +#pragma GCC diagnostic ignored "-Wattribute-alias" extern unsigned int __mingw_set_output_format_fallback( unsigned int ) __attribute__((__alias__("__mingw_get_output_format_fallback"))); #elif defined __crtnfmt__ /* Here, we implement a generic fallback hook, suitable for use as the - * fallback for _get_printf_count_output()/_set_printf_count_output(). + * fallback for _get_printf_count_output()/_set_printf_count_output(); + * (again, we effectively make the "set" function a "no-op", and again + * we need to supress GCC related to inconsistent prototypes). */ +#pragma GCC diagnostic ignored "-Wattribute-alias" int __mingw_get_printf_count_output_fallback( void ) __attribute__((__alias__("__mingw_set_printf_count_output_fallback"))); diff --git a/mingwrt/mingwex/stdio/pformat.c b/mingwrt/mingwex/stdio/pformat.c index 11d0153..0731754 100644 --- a/mingwrt/mingwex/stdio/pformat.c +++ b/mingwrt/mingwex/stdio/pformat.c @@ -8,7 +8,7 @@ * to support Microsoft's non-standard format specifications. * * Written by Keith Marshall - * Copyright (C) 2008, 2009, 2011, 2014-2017, MinGW.org Project + * Copyright (C) 2008, 2009, 2011, 2014-2018, MinGW.org Project * * * Permission is hereby granted, free of charge, to any person obtaining a @@ -2030,7 +2030,8 @@ const char *__pformat_ignore_flags( const char *fmt ) /* Advance the format string scan pointer, stepping over, and * otherwise ignoring any specified flag characters. */ - while( strchr( "+-' 0#", *fmt ) ) ++fmt; return fmt; + while( strchr( "+-' 0#", *fmt ) ) ++fmt; + return fmt; } static @@ -2549,6 +2550,12 @@ int __pformat_argmap( int argc, const char *fmt, __pformat_argmap_t *map ) case PFORMAT_LENGTH_CHAR: case PFORMAT_LENGTH_SHORT: length = PFORMAT_LENGTH_DEFAULT; + + /* All other length modifier codes are left unchanged; we + * provide a "do-nothing" default case handler here, to + * avoid GCC -Wswitch compile-time warnings. + */ + default: break; } /* All of the indicies associated with the current conversion diff --git a/mingwrt/profile/mcount.c b/mingwrt/profile/mcount.c index 296b4fb..42857ed 100644 --- a/mingwrt/profile/mcount.c +++ b/mingwrt/profile/mcount.c @@ -36,8 +36,13 @@ static char rcsid[] = "$OpenBSD: mcount.c,v 1.6 1997/07/23 21:11:27 kstailey Exp $"; #endif -/* - * This file is taken from Cygwin distribution. Please keep it in sync. +/* This translation unit will attempt to invoke __builtin_return_address() + * with a non-zero argument, which GCC considers to be unsafe; nonetheless, + * we need to do this, so suppress any warning GCC may try to emit. + */ +#pragma GCC diagnostic ignored "-Wframe-address" + +/* This file is taken from the Cygwin distribution. Please keep it in sync. * The differences should be within __MINGW32__ guard. */ diff --git a/mingwrt/setargv.c b/mingwrt/setargv.c index 3ac119d..712ad83 100644 --- a/mingwrt/setargv.c +++ b/mingwrt/setargv.c @@ -93,7 +93,7 @@ void __mingw32_setargv( const char *cmdline ) { /* Implementation of the MinGW replacement command line interpreter. */ - char cmdbuf[1 + strlen( cmdline ) << 1]; + char cmdbuf[(1 + strlen( cmdline )) << 1]; int c, gotarg = 0, quoted = 0, bracket = 0, bslash = 0; char *argptr = cmdbuf; const char *cmdptr = cmdline; glob_t gl_argv; @@ -111,7 +111,7 @@ void __mingw32_setargv( const char *cmdline ) /* Scan the command line, and prepare it for globbing. */ - while( c = *cmdptr++ ) + while( (c = *cmdptr++) != '\0' ) { /* Got a character to process... */