libselinux: selinux_restorecon: fix printf format string specifier for uint64_t
PATCH 1/1 libselinux: selinux_restorecon: fix printf format string specifier for uint64_t
fc_count is defined as uint64_t, which needs to be printed with PRIu64 (it is "llu" on x86 and "lu" on x86-64). Otherwise, building with 'CC="gcc -m32"' fails with:
selinux_restorecon.c: In function ‘restorecon_sb’:
selinux_restorecon.c:633:26: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
fprintf(stdout, "\r%luk", fc_count / STAR_COUNT);
~~^
%llu
--- libselinux/src/selinux_restorecon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libselinux/src/selinux_restorecon.c +2 -1
@@ -15,6 +15,7 @@#include <errno.h> #include <fcntl.h> #include <fts.h> +#include <inttypes.h> #include <limits.h> #include <stdint.h> #include <sys/types.h>
@@ -630,7 +631,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb, fc_count / efile_count) : 100;fprintf (stdout,"\r%-.1f%%" , (double )pc); }else { -fprintf (stdout,"\r%luk" , fc_count /STAR_COUNT ); +fprintf (stdout,"\r%" PRIu64"k" , fc_count /STAR_COUNT ); }fflush (stdout); }
Signature · 1 line
2.19.1
Quoted 12 lines · Nicolas Iooss
fc_countis defined asuint64_t, which needs to be printed with PRIu64 (it is "llu" on x86 and "lu" on x86-64). Otherwise, building with 'CC="gcc -m32"' fails with:
selinux_restorecon.c: In function ‘restorecon_sb’:
selinux_restorecon.c:633:26: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
fprintf(stdout, "\r%luk", fc_count / STAR_COUNT);
~~^
%llu
Quoted 1 line
Signed-off-by Nicolas Iooss <[email protected]>
Quoted 26 lines
--- libselinux/src/selinux_restorecon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)libselinux/src/selinux_restorecon.c +2
-1@@ -15,6 +15,7 @@#include <errno.h> #include <fcntl.h> #include <fts.h> +#include <inttypes.h> #include <limits.h> #include <stdint.h> #include <sys/types.h> @@ -630,7 +631,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb, fc_count / efile_count) : 100;fprintf (stdout,"\r%-.1f%%" , (double )pc); }else { -fprintf (stdout,"\r%luk" , fc_count /STAR_COUNT ); +fprintf (stdout,"\r%" PRIu64"k" , fc_count /STAR_COUNT ); }fflush (stdout); }
Quoted 14 lines · Stephen Smalley
Quoted 12 lines · Nicolas Iooss
fc_countis defined asuint64_t, which needs to be printed with PRIu64 (it is "llu" on x86 and "lu" on x86-64). Otherwise, building with 'CC="gcc -m32"' fails with:
selinux_restorecon.c: In function ‘restorecon_sb’:
selinux_restorecon.c:633:26: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
fprintf(stdout, "\r%luk", fc_count / STAR_COUNT);
~~^
%llu
Quoted 3 lines
Quoted 1 line
Signed-off-by Nicolas Iooss <[email protected]>Acked-by Stephen Smalley <[email protected]>
Merged.
Nicolas