@cryptotaxi247 / netdata-1 / commits / 3e42ff51a

fixed format strings

Costa Tsaousis (ktsaou) committed Jun 1, 2014 at 13:43 UTC 3e42ff51af404dd5641109e3e857662ac0e1c6b1
1 file changed +12 -9
apps_plugin.c
+12 -9
@@ -1,3 +1,6 @@
1 +#define __STDC_FORMAT_MACROS
2 +#include <inttypes.h>
3 +
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
@@ -212,7 +215,7 @@ struct target *get_target(const char *id, struct target *target)
215
216 w = calloc(sizeof(struct target), 1);
217 if(!w) {
215 - fprintf(stderr, "apps.plugin: cannot allocate %lu bytes of memory\n", sizeof(struct target));
218 + fprintf(stderr, "apps.plugin: cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(struct target));
219 return NULL;
220 }
221
@@ -426,13 +429,13 @@ struct pid_stat *get_entry(pid_t pid)
429
430 all_pids[pid] = calloc(sizeof(struct pid_stat), 1);
431 if(!all_pids[pid]) {
429 - fprintf(stderr, "apps.plugin: ERROR: Cannot allocate %lu bytes of memory", sizeof(struct pid_stat));
432 + fprintf(stderr, "apps.plugin: ERROR: Cannot allocate %lu bytes of memory", (unsigned long)sizeof(struct pid_stat));
433 return NULL;
434 }
435
436 all_pids[pid]->fds = calloc(sizeof(int), 100);
437 if(!all_pids[pid]->fds)
435 - fprintf(stderr, "apps.plugin: ERROR: Cannot allocate %ld bytes of memory\n", sizeof(int) * 100);
438 + fprintf(stderr, "apps.plugin: ERROR: Cannot allocate %ld bytes of memory\n", (unsigned long)(sizeof(int) * 100));
439 else all_pids[pid]->fds_size = 100;
440
441 if(root) root->prev = all_pids[pid];
@@ -693,20 +696,20 @@ int update_from_proc(void)
696 int parsed = sscanf(buffer,
697 "%d (%[^)]) %c" // pid, comm, state
698 " %d %d %d %d %d" // ppid, pgrp, session, tty_nr, tpgid
696 - " %lu %llu %llu %llu %llu" // flags, minflt, cminflt, majflt, cmajflt
699 + " %" PRIu64 " %llu %llu %llu %llu" // flags, minflt, cminflt, majflt, cmajflt
700 " %llu %llu %llu %llu" // utime, stime, cutime, cstime
698 - " %ld %ld" // priority, nice
701 + " %" PRId64 " %" PRId64 // priority, nice
702 " %d" // num_threads
700 - " %ld" // itrealvalue
703 + " %" PRId64 // itrealvalue
704 " %llu" // starttime
705 " %llu" // vsize
706 " %llu" // rss
707 " %llu %llu %llu %llu %llu %llu" // rsslim, starcode, endcode, startstack, kstkesp, kstkeip
705 - " %lu %lu %lu %lu" // signal, blocked, sigignore, sigcatch
706 - " %lu %lu %lu" // wchan, nswap, cnswap
708 + " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 // signal, blocked, sigignore, sigcatch
709 + " %" PRIu64 " %" PRIu64 " %" PRIu64 // wchan, nswap, cnswap
710 " %d %d" // exit_signal, processor
711 " %u %u" // rt_priority, policy
709 - " %llu %lu %ld"
712 + " %llu %" PRIu64 " %" PRId64 // delayacct_blkio_ticks, guest_time, cguest_time
713 , &p->pid, name, &p->state
714 , &p->ppid, &p->pgrp, &p->session, &p->tty_nr, &p->tpgid
715 , &p->flags, &p->minflt, &p->cminflt, &p->majflt, &p->cmajflt