[PATCH] ntdll: Ensure that performance information is initialized (scan-build)

Alex Henrie alexhenrie24 at gmail.com
Wed Sep 11 22:05:31 CDT 2019


And comment this code out on non-Linux systems which don't have /proc.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/ntdll/nt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 06f8f39b16..efc4c8adcf 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -2415,13 +2415,16 @@ NTSTATUS WINAPI NtQuerySystemInformation(
         {
             SYSTEM_PERFORMANCE_INFORMATION spi;
             static BOOL fixme_written = FALSE;
+#ifdef linux
             FILE *fp;
+#endif
 
             memset(&spi, 0 , sizeof(spi));
             len = sizeof(spi);
 
             spi.Reserved3 = 0x7fffffff; /* Available paged pool memory? */
 
+#ifdef linux
             if ((fp = fopen("/proc/uptime", "r")))
             {
                 double uptime, idle_time;
@@ -2439,7 +2442,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
 
             if ((fp = fopen("/proc/meminfo", "r")))
             {
-                unsigned long long totalram, freeram, totalswap, freeswap;
+                unsigned long long totalram = 0, freeram = 0, totalswap = 0, freeswap = 0;
                 char line[64];
                 while (fgets(line, sizeof(line), fp))
                 {
@@ -2467,6 +2470,7 @@ NTSTATUS WINAPI NtQuerySystemInformation(
                 spi.TotalCommittedPages = (totalram + totalswap - freeram - freeswap) / page_size;
                 spi.TotalCommitLimit    = (totalram + totalswap) / page_size;
             }
+#endif
 
             if (Length >= len)
             {
-- 
2.23.0




More information about the wine-devel mailing list