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.
From master commit da715e3
References:
http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html
This commit is contained in:
parent
91ee02f076
commit
bf97da3059
@ -543,11 +543,11 @@ ENTER(0x160);
|
|||||||
"%c "
|
"%c "
|
||||||
"%d %d %d %d %d "
|
"%d %d %d %d %d "
|
||||||
"%lu %lu %lu %lu %lu "
|
"%lu %lu %lu %lu %lu "
|
||||||
"%Lu %Lu %Lu %Lu " /* utime stime cutime cstime */
|
"%llu %llu %llu %llu " /* utime stime cutime cstime */
|
||||||
"%ld %ld "
|
"%ld %ld "
|
||||||
"%d "
|
"%d "
|
||||||
"%ld "
|
"%ld "
|
||||||
"%Lu " /* start_time */
|
"%llu " /* start_time */
|
||||||
"%lu "
|
"%lu "
|
||||||
"%ld "
|
"%ld "
|
||||||
"%lu %"KLF"u %"KLF"u %"KLF"u %"KLF"u %"KLF"u "
|
"%lu %"KLF"u %"KLF"u %"KLF"u %"KLF"u %"KLF"u "
|
||||||
|
@ -131,7 +131,7 @@ PROCPS_EXPORT int procps_stat_read (
|
|||||||
break;
|
break;
|
||||||
*tail = '\0';
|
*tail = '\0';
|
||||||
if (0 == strcmp(head, "cpu")) {
|
if (0 == strcmp(head, "cpu")) {
|
||||||
if (sscanf(tail+1, "%Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
|
if (sscanf(tail+1, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu",
|
||||||
&(info->data.cpu.user),
|
&(info->data.cpu.user),
|
||||||
&(info->data.cpu.nice),
|
&(info->data.cpu.nice),
|
||||||
&(info->data.cpu.system),
|
&(info->data.cpu.system),
|
||||||
@ -390,7 +390,7 @@ PROCPS_EXPORT int procps_stat_read_jiffs (
|
|||||||
// remember from last time around
|
// remember from last time around
|
||||||
memcpy(&sum_ptr->cpu.old, &sum_ptr->cpu.new, sizeof(struct procps_jiffs));
|
memcpy(&sum_ptr->cpu.old, &sum_ptr->cpu.new, sizeof(struct procps_jiffs));
|
||||||
// then value the summary line
|
// then value the summary line
|
||||||
if (8 > sscanf(bp, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
|
if (8 > sscanf(bp, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu"
|
||||||
, &sum_ptr->cpu.new.user, &sum_ptr->cpu.new.nice, &sum_ptr->cpu.new.system
|
, &sum_ptr->cpu.new.user, &sum_ptr->cpu.new.nice, &sum_ptr->cpu.new.system
|
||||||
, &sum_ptr->cpu.new.idle, &sum_ptr->cpu.new.iowait, &sum_ptr->cpu.new.irq
|
, &sum_ptr->cpu.new.idle, &sum_ptr->cpu.new.iowait, &sum_ptr->cpu.new.irq
|
||||||
, &sum_ptr->cpu.new.sirq, &sum_ptr->cpu.new.stolen
|
, &sum_ptr->cpu.new.sirq, &sum_ptr->cpu.new.stolen
|
||||||
@ -405,7 +405,7 @@ reap_em_again:
|
|||||||
bp = 1 + strchr(bp, '\n');
|
bp = 1 + strchr(bp, '\n');
|
||||||
// remember from last time around
|
// remember from last time around
|
||||||
memcpy(&cpu_ptr->cpu.old, &cpu_ptr->cpu.new, sizeof(struct procps_jiffs));
|
memcpy(&cpu_ptr->cpu.old, &cpu_ptr->cpu.new, sizeof(struct procps_jiffs));
|
||||||
if (8 > (rc = sscanf(bp, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
|
if (8 > (rc = sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu"
|
||||||
, &cpu_ptr->cpu.id
|
, &cpu_ptr->cpu.id
|
||||||
, &cpu_ptr->cpu.new.user, &cpu_ptr->cpu.new.nice, &cpu_ptr->cpu.new.system
|
, &cpu_ptr->cpu.new.user, &cpu_ptr->cpu.new.nice, &cpu_ptr->cpu.new.system
|
||||||
, &cpu_ptr->cpu.new.idle, &cpu_ptr->cpu.new.iowait, &cpu_ptr->cpu.new.irq
|
, &cpu_ptr->cpu.new.idle, &cpu_ptr->cpu.new.iowait, &cpu_ptr->cpu.new.irq
|
||||||
|
Loading…
Reference in New Issue
Block a user