In various places, we store IPv4 addresses packed into an (unsigned)
integer type.
The code was reviewed in the light of the desire to target an x86_64
platform.
The code was originally targetted for the i386 32-bit platform where
'unsigned long' was a 32-bit unsigned integer.
On the version of G++ used, 'unsigned long' turned out to be a 64-bit
unsigned integer. Whilst this will probably not break anything, it calls
into question whether that is the right type to be using.
It turns out that we can use the type 'uint_fast32_t' to tell the compiler
that we want to store at least 32 bits, but that it should use the fastest
convenient representation.
If we use this, we then don't know which type the compiler will choose, so
if we are having these values formatted by 'printf', then we need to cast
them to a known integer type first. We can use 'unsigned long' for this
purpose, as this is unlikely to ever be less than 32 bits.
Also, the function name 'dotted_quad_to_ulong' therefore becomes a
misnomer. The function can be renamed to 'dotted_quad_to_uint'.
William Blunn
None
None
Public
|
Date: 2009-06-03 02:58 Fixed in release 0.03 |
|
Date: 2009-06-03 01:10 Fixed in CVS as of |
| Field | Old Value | Date | By |
|---|---|---|---|
| status_id | Open | 2009-06-03 02:58 | bonebill |
| resolution_id | Accepted | 2009-06-03 02:58 | bonebill |
| close_date | - | 2009-06-03 02:58 | bonebill |
| resolution_id | None | 2009-06-03 00:11 | bonebill |