Bug #6239 | Compiler Complains of "Result is Always False" | ||
---|---|---|---|
Submitted: | 25 Oct 2004 2:49 | Modified: | 9 Nov 2004 16:41 |
Reporter: | James Barwick | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Command-line Clients | Severity: | S1 (Critical) |
Version: | 4.1.6-gamma | OS: | Linux (SuSE 9.1 (amd64)) |
Assigned to: | Lars Thalmann | CPU Architecture: | Any |
[25 Oct 2004 2:49]
James Barwick
[26 Oct 2004 4:58]
James Barwick
I realized that the suggested fix is NOT a fix and only removes the compiler warning!!! However, it will still ALWAYS return false!!! My Mistake! (Woke up in the middle of the night with cold sweats!) the function returns a uint? Right!? I haven't checked, but I suspect it does. If the function returns a uint, and the packet_error is defined as a ulong ~0, then we have packet_error = 0xFFFFFFFF The uint return result...if it's ever going to return a -1, will be set to a uint of 0x0000FFFF if it is indeed returning a uint, not a int. If it was an int, then I suspect if the function calls return a -1, the compiler would be smart enough to return a 0xFFFFFFFF integer. But..we need to be sure! So, if the my_xxx functions are indeed returning a uint, then let's let them return a uint and either use a packet_error defined as (uint)~0 or cast the packet_error to a (uint) in these if statements... SORRY GUYS!!!
[26 Oct 2004 6:42]
James Barwick
I have fixed the declarations to uint on my source (now back to distrib). Now...have the compiler warnings...so.. Line 222 From else if (packet_len == packet_error) to else if (packet_len == ((uint)packet_error)) Line 787 From if (len == packet_error) To if (len == ((uint)packet_error)) Now...due to my limitted brain capacity...PLEASE tell me if I'm on the right track now!!! (well, at least the compiler warnings went away) Thanks...
[26 Oct 2004 9:06]
Lars Thalmann
Thanks for notifying us of this problem, James. Your first idea was correct. my_net_read() returns ulong. Your second idea works if length is always smaller than 0xffff, but since packet_error is ulong, it is better to use the larger types. I have made a patch. Thanks again for your comments.
[9 Nov 2004 16:41]
Lars Thalmann
The bug fix for this has now been pushed. Will be part of 4.1.8 release.