All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] libselinux: selinux_restorecon: fix printf format string specifier for uint64_t
@ 2018-11-05 20:57 Nicolas Iooss
  2018-11-06 16:13 ` Stephen Smalley
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Iooss @ 2018-11-05 20:57 UTC (permalink / raw)
  To: selinux

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

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/selinux_restorecon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 41f2225081e0..3df2d382d50b 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -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);
 		}
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] libselinux: selinux_restorecon: fix printf format string specifier for uint64_t
  2018-11-05 20:57 [PATCH 1/1] libselinux: selinux_restorecon: fix printf format string specifier for uint64_t Nicolas Iooss
@ 2018-11-06 16:13 ` Stephen Smalley
  2018-11-11 20:48   ` Nicolas Iooss
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Smalley @ 2018-11-06 16:13 UTC (permalink / raw)
  To: Nicolas Iooss, selinux

On 11/5/18 3:57 PM, Nicolas Iooss wrote:
> 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
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Acked-by: Stephen Smalley <sds@tycho.nsa.gov>

> ---
>   libselinux/src/selinux_restorecon.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> index 41f2225081e0..3df2d382d50b 100644
> --- a/libselinux/src/selinux_restorecon.c
> +++ b/libselinux/src/selinux_restorecon.c
> @@ -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);
>   		}
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] libselinux: selinux_restorecon: fix printf format string specifier for uint64_t
  2018-11-06 16:13 ` Stephen Smalley
@ 2018-11-11 20:48   ` Nicolas Iooss
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Iooss @ 2018-11-11 20:48 UTC (permalink / raw)
  To: Stephen Smalley, selinux

On Tue, Nov 6, 2018 at 5:11 PM Stephen Smalley <sds@tycho.nsa.gov> wrote:
>
> On 11/5/18 3:57 PM, Nicolas Iooss wrote:
> > 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
> >
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>
> Acked-by: Stephen Smalley <sds@tycho.nsa.gov>

Merged.

Nicolas


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-11 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05 20:57 [PATCH 1/1] libselinux: selinux_restorecon: fix printf format string specifier for uint64_t Nicolas Iooss
2018-11-06 16:13 ` Stephen Smalley
2018-11-11 20:48   ` Nicolas Iooss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.