[vte/vte-0-62] lib: Fix unused variable warning when not using getrlimit



commit f8faddc3d1c30d00ea9147a35dd577c286dc6f4b
Author: Christian Persch <chpe src gnome org>
Date:   Mon Nov 16 20:38:04 2020 +0100

    lib: Fix unused variable warning when not using getrlimit
    
    Mentioned in https://gitlab.gnome.org/GNOME/vte/-/issues/296#note_963045
    
    (cherry picked from commit 770a375f023dd7bcd25a45ca01ff1fdcabf4c5bf)

 src/missing.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/missing.cc b/src/missing.cc
index e6da31e9..214419fc 100644
--- a/src/missing.cc
+++ b/src/missing.cc
@@ -90,16 +90,21 @@ static rlim_t
 getrlimit_NOFILE_max(void)
 {
 #ifdef HAVE_SYS_RESOURCE_H
+#ifdef __linux__
+{
         struct rlimit rlim;
 
-#ifdef __linux__
         if (prlimit(0 /* this PID */, RLIMIT_NOFILE, nullptr, &rlim) == 0)
                 return rlim.rlim_max;
 
         return RLIM_INFINITY;
+}
 #endif /* __linux__ */
 
 #ifdef __GLIBC__
+{
+        struct rlimit rlim;
+
         /* Use getrlimit() function provided by the system if it is known to be
          * async-signal safe.
          *
@@ -107,9 +112,10 @@ getrlimit_NOFILE_max(void)
          */
         if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
                 return rlim.rlim_max;
+}
 
         /* fallback */
-#endif
+#endif /* __GLIBC__ */
 
 #endif /* HAVE_SYS_RESOURCE_H */
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]