unistd.h for getopt()
stdint.h for integer definitions
Use inttypes.h codes for scanf to avoid 32/64 issues. Use %zd for size_t.
diff --git a/schedtop.c b/schedtop.c
index c0e0141..1cdcfaa 100644
--- a/schedtop.c
+++ b/schedtop.c
@@ -11,6 +11,9 @@
#include <signal.h>
#include <pwd.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <unistd.h>
struct thread_info {
int pid;
@@ -108,7 +111,7 @@
sprintf(line, "/proc/%d/schedstat", pid);
if (read_line(line, sizeof(line)))
return;
- if(sscanf(line, "%llu %llu %u", &info->exec_time, &info->delay_time, &info->run_count) != 3)
+ if(sscanf(line, SCNu64 " " SCNu64 " " SCNu32, &info->exec_time, &info->delay_time, &info->run_count) != 3)
return;
if (proc_info) {
proc_info->exec_time += info->exec_time;
@@ -210,7 +213,7 @@
}
if (!(flags & FLAG_BATCH))
printf("\e[H\e[0J");
- printf("Processes: %d, Threads %d\n", processes.active, threads.active);
+ printf("Processes: %zd, Threads %zd\n", processes.active, threads.active);
switch (time_dp) {
case 3:
printf(" TID --- SINCE LAST ---- ---------- TOTAL ----------\n");
@@ -332,4 +335,3 @@
closedir(d);
return 0;
}
-