[zeromq-dev] HP-UX compile.

George Neill georgen at neillnet.com
Tue Nov 18 16:50:18 CET 2008


On Tue, Nov 18, 2008 at 4:58 AM, Martin Sustrik <sustrik at fastmq.com> wrote:
> George,
>
>>> We don't have HP-UX here so it would be helpful if you can check
>>> following
>>> changes and let us know whether they help to get rid of the warnings:
>>>
>>>> "/home/gneill/zmq/trunk/zmq/ip.cpp", line 205: warning #4232-D:
>>>> conversion
>>>>         from "sockaddr *" to a more strictly aligned type "sockaddr_in
>>>> *"
>>>>         may cause misaligned access
>>>>     *addr_ = *((sockaddr_in *) res->ai_addr);
>>>
>>> Copying the memory explicitly may help here:
>>>
>>> memcpy (addr_, res->ai_addr, sizeof (sockaddr_in));
>>
>> Yes this resolves the warning, but probably should be sockaddr (not
>> sockaddr_in),
>>
>> -     *addr_ = *((sockaddr_in *) res->ai_addr);
>> +    memcpy(addr_, res->ai_addr, sizeof(struct sockaddr));
>
> According to POSIX specs, sockaddr should never be used directly (it should
> be used only as pointer, a handle to a generic socket address, it's used
> instead of more appropriate void* for historical reasons - because it
> predates ANSI C specs). So when dealing with IPv4 address proper,
> sockaddr_in should be OK.

You are right, I agree.   (for some reason I was thinking
sizeof(sockaddr) != sizeof(sockaddr_in).

>>>> "/home/gneill/zmq/trunk/zmq/select_thread.cpp", line 243: warning
>>>> #2940-D:
>>>>         missing return statement at end of non-void function
>>>>         "zmq::select_thread_t::process_command"
>>>>  }
>>>
>>> I would say the compiler doesn't recognise "assert (false)" as a
>>> termination
>>> statement. Try this:
>>>
>>> default:
>>>   assert (false);
>>>   return false;
>>
>> This also resolves the warning.
>
> Ok. Fixed.

Thanks!
George



More information about the zeromq-dev mailing list