Commit da715e3c authored by Craig Small's avatar Craig Small

Replace %Lu with standard %llu

Multiple scanf()s use the GNU-permitted %Lu. This is not supported in
other libraries and isn't to the POSIX specification. The L modifier
is only used for floats in POSIX.

Replacing %Lu with %llu is the same for GNU libc (scanf(3) says as much)
but means other libraries will work fine.

Closes: #19

References:
 http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html
parent 666b2946
......@@ -571,11 +571,11 @@ ENTER(0x160);
"%c "
"%d %d %d %d %d "
"%lu %lu %lu %lu %lu "
"%Lu %Lu %Lu %Lu " /* utime stime cutime cstime */
"%llu %llu %llu %llu " /* utime stime cutime cstime */
"%ld %ld "
"%d "
"%ld "
"%Lu " /* start_time */
"%llu " /* start_time */
"%lu "
"%ld "
"%lu %"KLF"u %"KLF"u %"KLF"u %"KLF"u %"KLF"u "
......
......@@ -198,7 +198,7 @@ static void old_Hertz_hack(void){
FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_1);
/* uptime(&up_1, NULL); */
FILE_TO_BUF(STAT_FILE,stat_fd);
sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j, &other_j, &wait_j, &hirq_j, &sirq_j, &stol_j);
sscanf(buf, "cpu %llu %llu %llu %llu %llu %llu %llu %llu", &user_j, &nice_j, &sys_j, &other_j, &wait_j, &hirq_j, &sirq_j, &stol_j);
FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_2);
/* uptime(&up_2, NULL); */
} while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */
......@@ -326,7 +326,7 @@ void eight_cpu_numbers(double *restrict uret, double *restrict nret, double *res
new_z = 0;
FILE_TO_BUF(STAT_FILE,stat_fd);
sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &new_u, &new_n, &new_s, &new_i, &new_w, &new_x, &new_y, &new_z);
sscanf(buf, "cpu %llu %llu %llu %llu %llu %llu %llu %llu", &new_u, &new_n, &new_s, &new_i, &new_w, &new_x, &new_y, &new_z);
ticks_past = (new_u+new_n+new_s+new_i+new_w+new_x+new_y+new_z)-(old_u+old_n+old_s+old_i+old_w+old_x+old_y+old_z);
if(ticks_past){
scale = 100.0 / (double)ticks_past;
......@@ -466,7 +466,7 @@ void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff
*czzz = 0; /* not separated out until the 2.6.11 kernel */
b = strstr(buff, "cpu ");
if(b) sscanf(b, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", cuse, cice, csys, cide, ciow, cxxx, cyyy, czzz);
if(b) sscanf(b, "cpu %llu %llu %llu %llu %llu %llu %llu %llu", cuse, cice, csys, cide, ciow, cxxx, cyyy, czzz);
b = strstr(buff, "page ");
if(b) sscanf(b, "page %lu %lu", pin, pout);
......@@ -477,11 +477,11 @@ void getstat(jiff *restrict cuse, jiff *restrict cice, jiff *restrict csys, jiff
else need_vmstat_file = 1;
b = strstr(buff, "intr ");
if(b) sscanf(b, "intr %Lu", &llbuf);
if(b) sscanf(b, "intr %llu", &llbuf);
*intr = llbuf;
b = strstr(buff, "ctxt ");
if(b) sscanf(b, "ctxt %Lu", &llbuf);
if(b) sscanf(b, "ctxt %llu", &llbuf);
*ctxt = llbuf;
b = strstr(buff, "btime ");
......
......@@ -2385,7 +2385,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
sum_ptr = &cpus[sumSLOT];
memcpy(&sum_ptr->sav, &sum_ptr->cur, sizeof(CT_t));
// then value the last slot with the cpu summary line
if (4 > sscanf(bp, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
if (4 > sscanf(bp, "cpu %llu %llu %llu %llu %llu %llu %llu %llu"
, &sum_ptr->cur.u, &sum_ptr->cur.n, &sum_ptr->cur.s
, &sum_ptr->cur.i, &sum_ptr->cur.w, &sum_ptr->cur.x
, &sum_ptr->cur.y, &sum_ptr->cur.z))
......@@ -2416,7 +2416,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
bp = 1 + strchr(bp, '\n');
// remember from last time around
memcpy(&cpu_ptr->sav, &cpu_ptr->cur, sizeof(CT_t));
if (4 > sscanf(bp, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &cpu_ptr->id
if (4 > sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu", &cpu_ptr->id
, &cpu_ptr->cur.u, &cpu_ptr->cur.n, &cpu_ptr->cur.s
, &cpu_ptr->cur.i, &cpu_ptr->cur.w, &cpu_ptr->cur.x
, &cpu_ptr->cur.y, &cpu_ptr->cur.z)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment