Fix -Wempty-body warnings in system-specific code

Message ID alpine.DEB.2.21.1902181825530.12080@digraph.polyomino.org.uk
State Committed
Headers

Commit Message

Joseph Myers Feb. 18, 2019, 6:26 p.m. UTC
  This patch fixes -Wempty-body warnings in system-specific code (Hurd
and m68k) that show up building glibc with -Wextra.

Note: there also such warnings on many platforms arising from the
default definition of HP_TIMING_NOW in sysdeps/generic/hp-timing.h,
but no change there is proposed in this patch because of other changes
under discussion in that area that would result in a nonempty
definition.

Tested with build-many-glibcs.py.

2019-02-18  Joseph Myers  <joseph@codesourcery.com>

	* hurd/hurdinit.c (_hurd_init): Use braces around empty body of an
	if statement.
	* sysdeps/m68k/wcpcpy.c (__wcpcpy): Use braces for empty body of a
	do-while statement.
  

Comments

Andreas Schwab Feb. 18, 2019, 7:55 p.m. UTC | #1
On Feb 18 2019, Joseph Myers <joseph@codesourcery.com> wrote:

> diff --git a/sysdeps/m68k/wcpcpy.c b/sysdeps/m68k/wcpcpy.c
> index a4bac08308..daeffc8f9b 100644
> --- a/sysdeps/m68k/wcpcpy.c
> +++ b/sysdeps/m68k/wcpcpy.c
> @@ -27,7 +27,8 @@ wchar_t *
>  __wcpcpy (wchar_t *dest, const wchar_t *src)
>  {
>    do
> -    ;
> +    {
> +    }
>    while ((*dest++ = *src++));

There is no point in using do..while here.

Andreas.
  
Adhemerval Zanella Feb. 18, 2019, 8:50 p.m. UTC | #2
On 18/02/2019 16:55, Andreas Schwab wrote:
> On Feb 18 2019, Joseph Myers <joseph@codesourcery.com> wrote:
> 
>> diff --git a/sysdeps/m68k/wcpcpy.c b/sysdeps/m68k/wcpcpy.c
>> index a4bac08308..daeffc8f9b 100644
>> --- a/sysdeps/m68k/wcpcpy.c
>> +++ b/sysdeps/m68k/wcpcpy.c
>> @@ -27,7 +27,8 @@ wchar_t *
>>  __wcpcpy (wchar_t *dest, const wchar_t *src)
>>  {
>>    do
>> -    ;
>> +    {
>> +    }
>>    while ((*dest++ = *src++));
> 
> There is no point in using do..while here.
> 
> Andreas.
> 

Can't we just use my 'wcsmbs: optimize wcpcpy' [1] instead?

[1] https://sourceware.org/ml/libc-alpha/2019-02/msg00155.html
  
Joseph Myers Feb. 18, 2019, 10:35 p.m. UTC | #3
On Mon, 18 Feb 2019, Adhemerval Zanella wrote:

> Can't we just use my 'wcsmbs: optimize wcpcpy' [1] instead?
> 
> [1] https://sourceware.org/ml/libc-alpha/2019-02/msg00155.html

That looks like it would also deal with the issue for that file, yes 
(while the hurdinit.c change would still be needed).
  
Joseph Myers Feb. 25, 2019, 1:24 p.m. UTC | #4
Ping.  This patch 
<https://sourceware.org/ml/libc-alpha/2019-02/msg00452.html> is pending 
review.  (Disregarding the m68k-specific change if people prefer to cover 
that with another patch.)
  
Florian Weimer Feb. 27, 2019, 1:39 p.m. UTC | #5
* Joseph Myers:

> diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
> index 773bb1c37f..2a224638ca 100644
> --- a/hurd/hurdinit.c
> +++ b/hurd/hurdinit.c
> @@ -100,10 +100,12 @@ _hurd_init (int flags, char **argv,
>  		   portarraysize * sizeof (mach_port_t));
>  
>    if (flags & EXEC_SECURE)
> -    /* XXX if secure exec, elide environment variables
> -       which the library uses and could be security holes.
> -       CORESERVER, COREFILE
> -       */ ;
> +    {
> +      /* XXX if secure exec, elide environment variables
> +	 which the library uses and could be security holes.
> +	 CORESERVER, COREFILE
> +      */
> +    }
>  
>    /* Call other things which want to do some initialization.  These are not
>       on the __libc_subinit hook because things there like to be able to

The change looks okay to me, although this to-do does look a bit scary.

> diff --git a/sysdeps/m68k/wcpcpy.c b/sysdeps/m68k/wcpcpy.c
> index a4bac08308..daeffc8f9b 100644
> --- a/sysdeps/m68k/wcpcpy.c
> +++ b/sysdeps/m68k/wcpcpy.c
> @@ -27,7 +27,8 @@ wchar_t *
>  __wcpcpy (wchar_t *dest, const wchar_t *src)
>  {
>    do
> -    ;
> +    {
> +    }
>    while ((*dest++ = *src++));
>  
>    return dest - 1;

Adhemerval deleted this file, so this is no longer needed.

Thanks,
Florian
  

Patch

diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index 773bb1c37f..2a224638ca 100644
--- a/hurd/hurdinit.c
+++ b/hurd/hurdinit.c
@@ -100,10 +100,12 @@  _hurd_init (int flags, char **argv,
 		   portarraysize * sizeof (mach_port_t));
 
   if (flags & EXEC_SECURE)
-    /* XXX if secure exec, elide environment variables
-       which the library uses and could be security holes.
-       CORESERVER, COREFILE
-       */ ;
+    {
+      /* XXX if secure exec, elide environment variables
+	 which the library uses and could be security holes.
+	 CORESERVER, COREFILE
+      */
+    }
 
   /* Call other things which want to do some initialization.  These are not
      on the __libc_subinit hook because things there like to be able to
diff --git a/sysdeps/m68k/wcpcpy.c b/sysdeps/m68k/wcpcpy.c
index a4bac08308..daeffc8f9b 100644
--- a/sysdeps/m68k/wcpcpy.c
+++ b/sysdeps/m68k/wcpcpy.c
@@ -27,7 +27,8 @@  wchar_t *
 __wcpcpy (wchar_t *dest, const wchar_t *src)
 {
   do
-    ;
+    {
+    }
   while ((*dest++ = *src++));
 
   return dest - 1;