]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Move 'virProcessLimitResourceToLabel' into same preprocessor if-block as only...
authorPeter Krempa <pkrempa@redhat.com>
Mon, 9 Mar 2026 16:38:28 +0000 (17:38 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 10 Mar 2026 13:50:10 +0000 (14:50 +0100)
'virProcessLimitResourceToLabel' is called only from
'virProcessGetLimitFromProc' but the latter has different conditions
when it's compiled. In certain cases this could lead to build failures.

Fixes: 90fe839f8a0
Closes: https://gitlab.com/libvirt/libvirt/-/work_items/848
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
src/util/virprocess.c

index e8120c1bdcd132e52d4850ac875322e8ad05d5fa..e06ed94b0d6a5314e49cabc6b0576e444d119e14 100644 (file)
@@ -743,36 +743,36 @@ virProcessPrLimit(pid_t pid G_GNUC_UNUSED,
 #endif
 
 #if WITH_GETRLIMIT
+# if defined(__linux__)
 static const char*
 virProcessLimitResourceToLabel(int resource)
 {
     switch (resource) {
-# if defined(RLIMIT_MEMLOCK)
+#  if defined(RLIMIT_MEMLOCK)
         case RLIMIT_MEMLOCK:
             return "Max locked memory";
-# endif /* defined(RLIMIT_MEMLOCK) */
+#  endif /* defined(RLIMIT_MEMLOCK) */
 
-# if defined(RLIMIT_NPROC)
+#  if defined(RLIMIT_NPROC)
         case RLIMIT_NPROC:
             return "Max processes";
-# endif /* defined(RLIMIT_NPROC) */
+#  endif /* defined(RLIMIT_NPROC) */
 
-# if defined(RLIMIT_NOFILE)
+#  if defined(RLIMIT_NOFILE)
         case RLIMIT_NOFILE:
             return "Max open files";
-# endif /* defined(RLIMIT_NOFILE) */
+#  endif /* defined(RLIMIT_NOFILE) */
 
-# if defined(RLIMIT_CORE)
+#  if defined(RLIMIT_CORE)
         case RLIMIT_CORE:
             return "Max core file size";
-# endif /* defined(RLIMIT_CORE) */
+#  endif /* defined(RLIMIT_CORE) */
 
         default:
             return NULL;
     }
 }
 
-# if defined(__linux__)
 static int
 virProcessGetLimitFromProc(pid_t pid,
                            int resource,