All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: ltp@lists.linux.it, linux-nfs@vger.kernel.org,
	Andrea Cervesato <andrea.cervesato@suse.com>
Subject: Re: [PATCH 1/1] aiodio: Fix format string for 32bit
Date: Fri, 5 Aug 2022 11:34:31 +0200	[thread overview]
Message-ID: <YuzkJ8cwOVEEkAVT@yuki> (raw)
In-Reply-To: <20220803173211.14292-1-pvorel@suse.cz>

Hi!
> On 32bit char pointer is int and size_t is unsigned int,
> Cast to long / unsigned long.

Actually char pointer is char pointer, that is not an integer type at
all. If you do a pointer difference you end up with an signed integer
value of ptrdiff_t type, because unlike the result of sizeof(foo)
pointer difference can be negative as well. In C99 ptrdiff_t can be
printed as %td see the "Length modifier" part of man 3 printf.

-- 
Cyril Hrubis
chrubis@suse.cz

WARNING: multiple messages have this Message-ID (diff)
From: Cyril Hrubis <chrubis@suse.cz>
To: Petr Vorel <pvorel@suse.cz>
Cc: linux-nfs@vger.kernel.org, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/1] aiodio: Fix format string for 32bit
Date: Fri, 5 Aug 2022 11:34:31 +0200	[thread overview]
Message-ID: <YuzkJ8cwOVEEkAVT@yuki> (raw)
In-Reply-To: <20220803173211.14292-1-pvorel@suse.cz>

Hi!
> On 32bit char pointer is int and size_t is unsigned int,
> Cast to long / unsigned long.

Actually char pointer is char pointer, that is not an integer type at
all. If you do a pointer difference you end up with an signed integer
value of ptrdiff_t type, because unlike the result of sizeof(foo)
pointer difference can be negative as well. In C99 ptrdiff_t can be
printed as %td see the "Length modifier" part of man 3 printf.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-08-05  9:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 17:32 [PATCH 1/1] aiodio: Fix format string for 32bit Petr Vorel
2022-08-03 17:32 ` [LTP] " Petr Vorel
2022-08-05  9:34 ` Cyril Hrubis [this message]
2022-08-05  9:34   ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuzkJ8cwOVEEkAVT@yuki \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.