[CRIU] [PATCH] pie: fix format string

Kir Kolyshkin kir at virtuozzo.com
Mon Feb 22 16:34:08 PST 2016


On 02/21/2016 08:23 AM, Tycho Andersen wrote:
> On some architectures, the result of sizeof() is an int, on others it is a
> long. Let's just always cast it to a long to avoid build failures
>
> Reported-by: Andrew Vagin <avagin at virtuozzo.com>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> CC: Andrew Vagin <avagin at virtuozzo.com>
> ---
>   criu/pie/parasite.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
> index 2466665..035a5fa 100644
> --- a/criu/pie/parasite.c
> +++ b/criu/pie/parasite.c
> @@ -521,7 +521,7 @@ static int __parasite_daemon_reply_ack(unsigned int cmd, int err)
>   	m = ctl_msg_ack(cmd, err);
>   	ret = sys_sendto(tsock, &m, sizeof(m), 0, NULL, 0);
>   	if (ret != sizeof(m)) {
> -		pr_err("Sent only %d bytes while %lu expected\n", ret, sizeof(m));
> +		pr_err("Sent only %d bytes while %lu expected\n", ret, (unsigned long) sizeof(m));
>   		return -1;
>   	}
>   

Maybe it's easier to just add support for z prefix to pie's printf?
Say, something like this:

diff --git a/criu/pie/log-simple.c b/criu/pie/log-simple.c
index 1cc877d..18657b1 100644
--- a/criu/pie/log-simple.c
+++ b/criu/pie/log-simple.c
@@ -225,6 +225,9 @@ void sbuf_printf(struct simple_buf *b, const char 
*format, va_list args)
                         s++;
                         if (*s == 'l')
                                 s++;
+               } else if (*s == 'z') {
+                       along = (sizeof(size_t) == sizeof(long));
+                       s++;
                 }

                 switch (*s) {



More information about the CRIU mailing list