[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] tests: avoid too-large constants



On 08/09/2013 07:53 AM, Daniel P. Berrange wrote:
> On Fri, Aug 09, 2013 at 07:45:16AM -0600, Eric Blake wrote:
>> Compiling with gcc 4.1.2 (RHEL 5) complains:
>>
>> virdbustest.c: In function 'testMessageSimple':
>> virdbustest.c:61: warning: integer constant is too large for 'long' type
>> virdbustest.c:62: warning: integer constant is too large for 'long' type
>> virdbustest.c: In function 'testMessageArray':
>> virdbustest.c:183: warning: this decimal constant is unsigned only in ISO C90
>> virdbustest.c: In function 'testMessageStruct':
>> virdbustest.c:239: warning: integer constant is too large for 'long' type
>> virdbustest.c:240: warning: integer constant is too large for 'long' type
>>
>> * tests/virdbustest.c (testMessageSiple, testMessageArray)
>> (testMessageStruct): Don't violate C89 constant constraints.
>>
>> Signed-off-by: Eric Blake <eblake redhat com>
>> ---
>>
>> Pushing under the build-breaker rule.
>>

>> @@ -178,9 +178,9 @@ static int testMessageArray(const void *args ATTRIBUTE_UNUSED)
>>      DBusMessage *msg = NULL;
>>      int ret = -1;
>>      const char *in_str1 = "Hello";
>> -    int in_int32a = 1000000000, out_int32a = 0;
>> -    int in_int32b = 2000000000, out_int32b = 0;
>> -    int in_int32c = 3000000000, out_int32c = 0;
>> +    int in_int32a = 100000000, out_int32a = 0;
>> +    int in_int32b = 200000000, out_int32b = 0;
>> +    int in_int32c = 300000000, out_int32c = 0;
> 
> I actually intentionally choose 300000000 as a value that would
> be above MAX_INT32 (2147483647). I guess what I really should
> have done was use something like -2147483640 instead, so we
> didn't rely on wrapping of 3000000000. 
> 
> Could you change this test to use a large -ve number for the
> 3rd int, rather than stripping a 0 from all 3.

Will do.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]