[Olsr-cvs] olsrd-current/src olsr.c,1.58,1.59

Bernd Petrovitsch (spam-protected)
Fri Oct 5 22:57:56 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9340/src

Modified Files:
	olsr.c 
Log Message:
* simplify the formula avoiding unnecessary floating point calculations and
  give the compiler as much freedom as possible.


Index: olsr.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -d -r1.58 -r1.59
*** olsr.c	16 Sep 2007 21:20:16 -0000	1.58
--- olsr.c	5 Oct 2007 20:57:53 -0000	1.59
***************
*** 395,406 ****
  void
  set_buffer_timer(struct interface *ifn)
! {
!   float jitter;
!       
    /* Set timer */
!   jitter = (float) random()/RAND_MAX;
!   jitter *= olsr_cnf->max_jitter;
! 
!   ifn->fwdtimer = GET_TIMESTAMP(jitter*1000);
  }
  
--- 395,401 ----
  void
  set_buffer_timer(struct interface *ifn)
! {      
    /* Set timer */
!   ifn->fwdtimer = GET_TIMESTAMP(random() * olsr_cnf->max_jitter * 1000 / RAND_MAX);
  }
  
***************
*** 486,490 ****
      }
  
!   snprintf(type, 20, "UNKNOWN(%d)", msgtype);
    return type;
  }
--- 481,485 ----
      }
  
!   snprintf(type, sizeof(type), "UNKNOWN(%d)", msgtype);
    return type;
  }
***************
*** 512,516 ****
      }
  
!   snprintf(type, 20, "UNKNOWN(%d)", linktype);
    return type;
  }
--- 507,511 ----
      }
  
!   snprintf(type, sizeof(type), "UNKNOWN(%d)", linktype);
    return type;
  }
***************
*** 534,538 ****
      }
  
!   snprintf(type, 20, "UNKNOWN(%d)", status);
    return type;
  }
--- 529,533 ----
      }
  
!   snprintf(type, sizeof(type), "UNKNOWN(%d)", status);
    return type;
  }
***************
*** 570,576 ****
  olsr_malloc(size_t size, const char *id)
  {
!   void *ptr;
! 
!   if((ptr = malloc(size)) == 0) 
      {
        const char * const err_msg = strerror(errno);
--- 565,570 ----
  olsr_malloc(size_t size, const char *id)
  {
!   void *ptr = malloc(size);
!   if(ptr == 0) 
      {
        const char * const err_msg = strerror(errno);





More information about the Olsr-cvs mailing list