From 5b14b97afe37864fe5d889b110b2147dac2923b1 Mon Sep 17 00:00:00 2001 From: Davide Berardi Date: Tue, 19 Jul 2016 13:51:21 +0200 Subject: [PATCH] printf warnings. --- cado.c | 3 ++- caprint.c | 9 +++++++-- capset_from_namelist.c | 2 +- read_conf.c | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cado.c b/cado.c index a0f7a47..26a51ac 100644 --- a/cado.c +++ b/cado.c @@ -30,6 +30,7 @@ #include #include #include +#include static void printcapset(uint64_t capset, char *indent) { cap_value_t cap; @@ -41,7 +42,7 @@ static void printcapset(uint64_t capset, char *indent) { } } if (count > 1) - printf("%s %016llx\n",indent,capset); + printf("%s %016" PRIx64 "\n",indent,capset); } #define OPTSTRING "hqvs" diff --git a/caprint.c b/caprint.c index 8809dc1..6a0a1a2 100644 --- a/caprint.c +++ b/caprint.c @@ -27,6 +27,7 @@ #include #include #include +#include char *tag="CapAmb:\t"; uint64_t get_capamb(pid_t pid) { @@ -46,7 +47,9 @@ uint64_t get_capamb(pid_t pid) { if (c == tag[status]) { status++; if (status == target) { - fscanf(f,"%llx",&capamb); + int fields = 0; + if ((fields = fscanf(f,"%" PRIx64 "",&capamb)) != 1) + fprintf(stderr, "WARNING: fscanf on %s return %d fields.\n", filename, fields); break; } } else @@ -126,6 +129,8 @@ int main(int argc, char *argv[]) { if (prompt) printf("#"); if (compact) printf("\n"); if (longlist && count > 1) - printf(" %016llx\n",capamb); + printf(" %016" PRIx64 "\n",capamb); } + + return 0; } diff --git a/capset_from_namelist.c b/capset_from_namelist.c index 8ce1229..14f52a9 100644 --- a/capset_from_namelist.c +++ b/capset_from_namelist.c @@ -51,7 +51,7 @@ static int addcap(char *name, uint64_t *capset) { int capset_from_namelist(char *namelist, uint64_t *capset) { int rv=0; char *onecap; - char *tmptok; + char *tmptok = NULL; for (; (onecap=strtok_r(namelist,",",&tmptok)) != NULL; namelist=NULL) rv |= addcap(onecap,capset); return rv; diff --git a/read_conf.c b/read_conf.c index d008961..29201bc 100644 --- a/read_conf.c +++ b/read_conf.c @@ -51,7 +51,8 @@ uint64_t get_authorized_caps(char **user_groups) { f=fopen(CADO_CONF, "r"); if (f) { char *line=NULL; - ssize_t len,n=0; + size_t n = 0; + ssize_t len = 0; while ((len=getline(&line, &n, f)) > 0) { //printf("%s",line); char *scan=line;