Skip to content

Commit a9cfe9e

Browse files
Nibedita JenaRavi Reddy
authored andcommitted
8350820: OperatingSystemMXBean CpuLoad() methods return -1.0 on Windows
Backport-of: d8d055ed0dcfa270ab091ea9e9856eb57d105b6c
1 parent 01e27b6 commit a9cfe9e

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/jdk.management/windows/native/libmanagement_ext/OperatingSystemImpl.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -436,13 +436,13 @@ makeFullCounterPath(const char* const objectName,
436436
return NULL;
437437
}
438438

439-
snprintf(fullCounterPath,
440-
fullCounterPathLen,
441-
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
442-
objectName,
443-
imageName,
444-
instance,
445-
counterName);
439+
_snprintf(fullCounterPath,
440+
fullCounterPathLen,
441+
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
442+
objectName,
443+
imageName,
444+
instance,
445+
counterName);
446446
} else {
447447
if (instance) {
448448
/*
@@ -472,18 +472,18 @@ makeFullCounterPath(const char* const objectName,
472472
}
473473

474474
if (instance) {
475-
snprintf(fullCounterPath,
476-
fullCounterPathLen,
477-
OBJECT_WITH_INSTANCES_COUNTER_FMT,
478-
objectName,
479-
instance,
480-
counterName);
475+
_snprintf(fullCounterPath,
476+
fullCounterPathLen,
477+
OBJECT_WITH_INSTANCES_COUNTER_FMT,
478+
objectName,
479+
instance,
480+
counterName);
481481
} else {
482-
snprintf(fullCounterPath,
483-
fullCounterPathLen,
484-
OBJECT_COUNTER_FMT,
485-
objectName,
486-
counterName);
482+
_snprintf(fullCounterPath,
483+
fullCounterPathLen,
484+
OBJECT_COUNTER_FMT,
485+
objectName,
486+
counterName);
487487
}
488488
}
489489

@@ -719,10 +719,10 @@ currentQueryIndexForProcess(void) {
719719
PDH_FMT_COUNTERVALUE counterValue;
720720
PDH_STATUS res;
721721

722-
snprintf(fullIDProcessCounterPath,
723-
MAX_PATH,
724-
pdhIDProcessCounterFmt,
725-
index);
722+
_snprintf(fullIDProcessCounterPath,
723+
MAX_PATH,
724+
pdhIDProcessCounterFmt,
725+
index);
726726

727727
if (addCounter(tmpQuery, fullIDProcessCounterPath, &handleCounter) != 0) {
728728
break;
@@ -1059,13 +1059,13 @@ allocateAndInitializePdhConstants() {
10591059
}
10601060

10611061
/* "\Process(java#%d)\ID Process" */
1062-
snprintf(pdhIDProcessCounterFmt,
1063-
pdhIDProcessCounterFmtLen,
1064-
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
1065-
pdhLocalizedProcessObject,
1066-
pdhProcessImageName,
1067-
"%d",
1068-
pdhLocalizedIDProcessCounter);
1062+
_snprintf(pdhIDProcessCounterFmt,
1063+
pdhIDProcessCounterFmtLen,
1064+
PROCESS_OBJECT_INSTANCE_COUNTER_FMT,
1065+
pdhLocalizedProcessObject,
1066+
pdhProcessImageName,
1067+
"%d",
1068+
pdhLocalizedIDProcessCounter);
10691069

10701070
pdhIDProcessCounterFmt[pdhIDProcessCounterFmtLen] = '\0';
10711071

0 commit comments

Comments
 (0)