[dm-devel] [PATCH 2/6] kpartx: fix -Wsign-compare error
Martin Wilck
Martin.Wilck at suse.com
Thu Aug 6 10:30:30 UTC 2020
On Mon, 2020-07-27 at 14:24 -0500, Benjamin Marzinski wrote:
> Signed-off-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
> kpartx/kpartx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
> index c24ad6d9..653ce0c8 100644
> --- a/kpartx/kpartx.c
> +++ b/kpartx/kpartx.c
> @@ -738,7 +738,7 @@ struct block {
> /* blknr is always in 512 byte blocks */
> char *
> getblock (int fd, unsigned int blknr) {
> - unsigned int secsz = get_sector_size(fd);
> + int secsz = get_sector_size(fd);
> unsigned int blks_per_sec = secsz / 512;
> unsigned int secnr = blknr / blks_per_sec;
> unsigned int blk_off = (blknr % blks_per_sec) * 512;
I was wondering why I didn't see this one. Turns out that it occurs
only for 32bit compilations. It looks like sort of an overzealous
compiler warning to me, as it's only about a "!=" comparison that can
hardly produce a wrong or unexpected result.
Btw, not that it would matter much, but the value of he BLKSSZGET ioctl
is actually unsigned.
Anyway, ack.
--
Dr. Martin Wilck <mwilck at suse.com>, Tel. +49 (0)911 74053 2107
SUSE Software Solutions Germany GmbH
HRB 36809, AG Nürnberg GF: Felix
Imendörffer
More information about the dm-devel
mailing list