[libvirt] [PATCH 2/2] utiltest: Don't assume 'char' is always signed

Peter Krempa pkrempa at redhat.com
Mon Jun 8 09:02:26 UTC 2015


On Mon, Jun 08, 2015 at 10:43:39 +0200, Michal Privoznik wrote:
> Not every architecture out there has 'char' signed by default.
> For instance, my arm box has it unsigned by default:
> 
>   $ gcc -dM -E - < /dev/null | grep __CHAR_UNSIGNED__
>   #define __CHAR_UNSIGNED__ 1
> 
> Therefore, after 65c61e50 the test if failing for me. Problem is,
> we are trying to assign couple of negative values into char
> assuming some will overflow and some don't. That can't be the
> case if 'char' is unsigned by default.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tests/utiltest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/utiltest.c b/tests/utiltest.c
> index 3a1f8eb..9eb7fb6 100644
> --- a/tests/utiltest.c
> +++ b/tests/utiltest.c
> @@ -185,7 +185,7 @@ testOverflowCheckMacro(const void *data ATTRIBUTE_UNUSED)
>  {
>      long long tmp;
>      unsigned char luchar;
> -    char lchar;
> +    signed char lchar;

I actually did not know that without explicit specification char may be
signed or unsigned. Anyways, since char is not defined I'd rather change
the type to uint8_t and int8_t.


Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150608/646f3b72/attachment-0001.sig>


More information about the libvir-list mailing list