[26/40] sim/ppc: Remove getrusage declarations if possible

Message ID 4f666ba3e017785495a6d9e1242c827b4f74424c.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  Clang generates a warning if there is a function declaration/definition
with zero arguments.  Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype").  On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

This commit removes redundant and indefinite getrusage function declarations
if the known getrusage declaration is found.
---
 sim/ppc/emul_netbsd.c | 2 ++
 sim/ppc/emul_unix.c   | 2 ++
 sim/ppc/mon.c         | 2 ++
 3 files changed, 6 insertions(+)
  

Comments

Mike Frysinger Oct. 23, 2022, 3:04 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> Clang generates a warning if there is a function declaration/definition
> with zero arguments.  Such declarations/definitions without a prototype (an
> argument list) are deprecated forms of indefinite arguments
> ("-Wdeprecated-non-prototype").  On the default configuration, it causes a
> build failure (unless "--disable-werror" is specified).
> 
> This commit removes redundant and indefinite getrusage function declarations
> if the known getrusage declaration is found.

just delete the code and be done.  don't keep it around for ancient irrelevant
systems that we never test on.
-mike
  
Tsukasa OI Oct. 27, 2022, 2 a.m. UTC | #2
On 2022/10/24 0:04, Mike Frysinger wrote:
> On 20 Oct 2022 09:32, Tsukasa OI wrote:
>> Clang generates a warning if there is a function declaration/definition
>> with zero arguments.  Such declarations/definitions without a prototype (an
>> argument list) are deprecated forms of indefinite arguments
>> ("-Wdeprecated-non-prototype").  On the default configuration, it causes a
>> build failure (unless "--disable-werror" is specified).
>>
>> This commit removes redundant and indefinite getrusage function declarations
>> if the known getrusage declaration is found.
> 
> just delete the code and be done.  don't keep it around for ancient irrelevant
> systems that we never test on.
> -mike

I'm concerned what kind of machines / environments to preserve behavior
but it seems we no longer have to worry about such pre-POSIX
environments (also, sim requires ISO C11 support).  Removing getrusage
declarations without prototype is simpler and easier for me too, so I
agree to delete them.

Thanks,
Tsukasa
  

Patch

diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c
index 322b584a3f1..072a5df5598 100644
--- a/sim/ppc/emul_netbsd.c
+++ b/sim/ppc/emul_netbsd.c
@@ -48,8 +48,10 @@ 
 
 #ifdef HAVE_GETRUSAGE
 #include <sys/resource.h>
+#ifndef HAVE_DECL_GETRUSAGE
 int getrusage();
 #endif
+#endif
 
 #if HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
diff --git a/sim/ppc/emul_unix.c b/sim/ppc/emul_unix.c
index 57691d4befc..6d4c2dad944 100644
--- a/sim/ppc/emul_unix.c
+++ b/sim/ppc/emul_unix.c
@@ -95,8 +95,10 @@ 
 
 #ifdef HAVE_GETRUSAGE
 #include <sys/resource.h>
+#ifndef HAVE_DECL_GETRUSAGE
 int getrusage();
 #endif
+#endif
 
 #if HAVE_DIRENT_H
 # include <dirent.h>
diff --git a/sim/ppc/mon.c b/sim/ppc/mon.c
index 4e29ec99879..3e88829f688 100644
--- a/sim/ppc/mon.c
+++ b/sim/ppc/mon.c
@@ -38,8 +38,10 @@ 
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
+#ifndef HAVE_DECL_GETRUSAGE
 int getrusage();
 #endif
+#endif
 
 #include "basics.h"
 #include "cpu.h"