Skip to content

Commit 6c28fcf

Browse files
alramry
authored andcommitted
(char *) casting for all strings args to kstat function to avoid warnings
Fixes nodejs#1071.
1 parent 5d9dc1c commit 6c28fcf

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/platform_sunos.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
160160
*cpus = Array::New();
161161

162162
lookup_instance = 0;
163-
while (ksp = kstat_lookup(kc, "cpu_info", lookup_instance, NULL)){
163+
while (ksp = kstat_lookup(kc, (char *)"cpu_info", lookup_instance, NULL)){
164164
cpuinfo = Object::New();
165165

166166
if (kstat_read(kc, ksp, NULL) == -1) {
@@ -175,9 +175,9 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
175175
cpuinfo->Set(String::New("error"), String::New(strerror(errno)));
176176
(*cpus)->Set(lookup_instance, cpuinfo);
177177
} else {
178-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "clock_MHz");
178+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"clock_MHz");
179179
cpuinfo->Set(String::New("speed"), data_named(knp));
180-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "brand");
180+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"brand");
181181
cpuinfo->Set(String::New("model"), data_named(knp));
182182
(*cpus)->Set(lookup_instance, cpuinfo);
183183
}
@@ -186,21 +186,21 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
186186
}
187187

188188
lookup_instance = 0;
189-
while (ksp = kstat_lookup(kc, "cpu", lookup_instance, "sys")){
189+
while (ksp = kstat_lookup(kc, (char *)"cpu", lookup_instance, (char *)"sys")){
190190
cpuinfo = (*cpus)->Get(lookup_instance)->ToObject();
191191
cputimes = Object::New();
192192

193193
if (kstat_read(kc, ksp, NULL) == -1) {
194194
cputimes->Set(String::New("error"), String::New(strerror(errno)));
195195
cpuinfo->Set(String::New("times"), cpuinfo);
196196
} else {
197-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_kernel");
197+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"cpu_ticks_kernel");
198198
cputimes->Set(String::New("system"), data_named(knp));
199-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_user");
199+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"cpu_ticks_user");
200200
cputimes->Set(String::New("user"), data_named(knp));
201-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "cpu_ticks_idle");
201+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"cpu_ticks_idle");
202202
cputimes->Set(String::New("idle"), data_named(knp));
203-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "intr");
203+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"intr");
204204
cputimes->Set(String::New("irq"), data_named(knp));
205205

206206
cpuinfo->Set(String::New("times"), cputimes);
@@ -226,13 +226,13 @@ double Platform::GetFreeMemory() {
226226
if((kc = kstat_open()) == NULL)
227227
throw "could not open kstat";
228228

229-
ksp = kstat_lookup(kc, "unix", 0, "system_pages");
229+
ksp = kstat_lookup(kc, (char *)"unix", 0, (char *)"system_pages");
230230

231231
if(kstat_read(kc, ksp, NULL) == -1){
232232
throw "could not read kstat";
233233
}
234234
else {
235-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "freemem");
235+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"freemem");
236236
freemem = knp->value.ul;
237237
}
238238

@@ -260,12 +260,12 @@ double Platform::GetUptime() {
260260
if ((kc = kstat_open()) == NULL)
261261
throw "could not open kstat";
262262

263-
ksp = kstat_lookup(kc, "unix", 0, "system_misc");
263+
ksp = kstat_lookup(kc, (char *)"unix", 0, (char *)"system_misc");
264264

265265
if (kstat_read(kc, ksp, NULL) == -1) {
266266
throw "unable to read kstat";
267267
} else {
268-
knp = (kstat_named_t *) kstat_data_lookup(ksp, "clk_intr");
268+
knp = (kstat_named_t *) kstat_data_lookup(ksp, (char *)"clk_intr");
269269
clk_intr = knp->value.ul;
270270
}
271271

0 commit comments

Comments
 (0)