[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] quoteargs: fix comparison between signed and unsigned warnin
From: |
Bruno Haible |
Subject: |
Re: [PATCH] quoteargs: fix comparison between signed and unsigned warning |
Date: |
Thu, 19 Oct 2017 22:13:10 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-96-generic; KDE/5.18.0; x86_64; ; ) |
Sami Kerola wrote:
>
> - if (MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) <= n)
> + if (MIN (INT_MAX, MIN (PTRDIFF_MAX, SIZE_MAX) / sizeof *sv) <=
> (size_t) n)
> xalloc_die ();
>
I would find it better to cast n to 'unsigned int' instead. Then the code does
not need to make an assumption about the relative sizes of 'size_t' versus
'int'.
Bruno