projektecarus

possible bug with IPADDR()

Discussion created by projektecarus on Mar 17, 2014
Latest reply on Mar 17, 2014 by Martin Latal

Hi,


we are using MQX Version 4.0. We have implemented network communication over UDP with RTCS. While developing our application we compared the ip address, that was returned by Sendto() with an static ip address. To enter the IP address we used the IPADDR() MACRO, that is defined in the rtcs.h as

#define IPADDR(a,b,c,d) (((uint_32)(a)&0xFF)<<24)|(((uint_32)(b)&0xFF)<<16)|(((uint_32)(c)&0xFF)<<8)|((uint_32)(d)&0xFF)

During debugging we noticed, that our comparison always evaluated as true. After some investigating we noticed that there are no brackets around the IPADDR macro, so the comparison compared the ip address with the first byte of the ip address with of course evaluated as false and the connected the other bytes of the ip address with the bit wise or operator. We think that this behavior might be undesirable and think that it could be considered a bug. We wanted to inform you about it and warn other users, so they will be able to save some debugging time, when they stumble upon the same problem. We currently have no way of telling if this problem is also present in the latest version of MQX.

Outcomes