BLWebSocketsServer icon indicating copy to clipboard operation
BLWebSocketsServer copied to clipboard

Value conversion issues

Open paulyoung opened this issue 11 years ago • 5 comments

This picks up where #6 left off.

When building my project I receive 28 warnings stating that Implicit conversion loses integer precision.

All but one of the implicit conversion warnings originate from libwebsockets.

The other is coming from BLAsyncMessageQueue.m:

screen shot 2014-08-30 at 02 55 53

paulyoung avatar Aug 30 '14 07:08 paulyoung

@bdkjones - I'm wondering what you did here.

paulyoung avatar Sep 05 '14 06:09 paulyoung

Yea. These are pedantic warnings.

An unsigned long is a 64-bit wide chunk of memory where all 64 bits will be devoted to storing the value (versus a signed long, where 63 bits will store the value and 1 bit will determine if that value is negative or positive)

So an unsigned long can store any number in the range 0 - 18,446,744,073,709,600,000.

A regular signed int is 32-bits wide, but only 31 bits are available for storing the value. The largest positive value it can store is 2,147,483,647

As a matter of practicality, if there are 2.1 billion messages queued, your socket has LONG since stopped working and your user is likely plotting several painful ways to kill you.

So, in this case, the warnings can be ignored; the lossy conversion isn't going to bite you. To get rid of the warnings, you can typecast the right-hand operand to an int, but the long-term solution would be to update the class to use 64-bit integers rather than ints.

bdkjones avatar Sep 05 '14 06:09 bdkjones

Yep. Thanks. I should have clarified that I was wondering what practical steps you took.

I'd prefer to fork + fix but libwebsockets is a dependency all of it's own. For now I'm doing this:

screen shot 2014-09-05 at 20 09 14

Given the issues and lack of activity here I'm considering using an alternative.

@bdkjones - please let me know if you find anything for your own purposes!

paulyoung avatar Sep 06 '14 00:09 paulyoung

The warnings are harmless indeed except if you get in the situation @bdkjones describe. Will fix the issue in BLWebSockets, as for libwebsockets I didn't check if they have a version that compile in 64 bits.

benlodotcom avatar Sep 06 '14 03:09 benlodotcom

The would be great.

paulyoung avatar Sep 07 '14 05:09 paulyoung