PUD: change signature of getBestUplinkGateway function
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 6 Mar 2012 15:43:53 +0000 (16:43 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Mar 2012 13:28:43 +0000 (14:28 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c
lib/pud/src/uplinkGateway.c
lib/pud/src/uplinkGateway.h

index b14b6eb..8db152a 100644 (file)
@@ -706,7 +706,7 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
        bool internalStateChange = false;
        bool externalStateChange = false;
        bool updateTransmitGpsInformation = false;
-       union olsr_ip_addr bestGateway;
+       union olsr_ip_addr bestGateway;
        PositionUpdateEntry txPosition;
        union olsr_ip_addr txGateway;
 
@@ -768,9 +768,9 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
         * Movement detection
         */
 
-       bestGateway = getBestUplinkGateway();
+       getBestUplinkGateway(&bestGateway);
        clearMovementType(&movementResult);
-       detemineMovingFromGateway(bestGateway,&txGateway, &movementResult);
+       detemineMovingFromGateway(&bestGateway, &txGateway, &movementResult);
        if (movementResult.moving != SET) {
                detemineMovingFromPosition(posAvgEntry, &txPosition, &movementResult);
        }
@@ -866,7 +866,7 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
        if ((state.externalState == MOVING) || updateTransmitGpsInformation) {
                (void) pthread_mutex_lock(&transmitGpsInformation.mutex);
                transmitGpsInformation.txPosition.nmeaInfo = posAvgEntry->nmeaInfo;
-               transmitGpsInformation.txGateway = *bestGateway;
+               transmitGpsInformation.txGateway = bestGateway;
                transmitGpsInformation.updated = true;
                (void) pthread_mutex_unlock(&transmitGpsInformation.mutex);
 
index b055516..0b3793a 100644 (file)
@@ -37,10 +37,10 @@ static inline unsigned long long gw_speed(struct gateway_entry *gw) {
  * It adjusted for best gateway selection but otherwise kept the same as much
  * as possible.
  *
- * @return
- * a pointer to the IP address of the best gateway
+ * @param bestGateway
+ * a pointer to the variable in which to store the best gateway
  */
-union olsr_ip_addr * getBestUplinkGateway(void) {
+void getBestUplinkGateway(union olsr_ip_addr * bestGateway) {
        struct gateway_entry *gw_best = NULL;
        unsigned long long gw_best_value = 0;
        struct gateway_entry *gw;
@@ -97,8 +97,9 @@ union olsr_ip_addr * getBestUplinkGateway(void) {
 
        if (!gw_best) {
                /* degrade gracefully */
-               return &olsr_cnf->main_addr;
+               *bestGateway = olsr_cnf->main_addr;
+               return;
        }
 
-       return &gw_best->originator;
+       *bestGateway = gw_best->originator;
 }
index 2996748..6d2fd2b 100644 (file)
@@ -8,6 +8,6 @@
 
 /* System includes */
 
-union olsr_ip_addr * getBestUplinkGateway(void);
+void getBestUplinkGateway(union olsr_ip_addr * bestGateway);
 
 #endif /* _PUD_UPLINKGATEWAY_H_ */