Commit ee528fbd authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Timers: Add typecast to unit-converting macros

parent 92cc1e74
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -80,8 +80,7 @@ CF_DECLS
%type <iface> ipa_scope

%type <i> expr bool pxlen4
%type <i32> expr_us
%type <time> time
%type <time> expr_us time
%type <a> ipa
%type <net> net_ip4_ net_ip6_ net_ip6 net_ip_ net_ip net_or_ipa
%type <net_ptr> net_ net_any net_vpn4_ net_vpn6_ net_vpn_ net_roa4_ net_roa6_ net_roa_
@@ -137,9 +136,9 @@ expr:


expr_us:
   expr S  { $$ = (u32) $1 * 1000000; }
 | expr MS { $$ = (u32) $1 * 1000; }
 | expr US { $$ = (u32) $1 * 1; }
   expr S  { $$ = $1 S_; }
 | expr MS { $$ = $1 MS_; }
 | expr US { $$ = $1 US_; }
 ;

/* Switches */
+4 −3
Original line number Diff line number Diff line
@@ -71,9 +71,9 @@ static inline int u64_cmp(u64 i1, u64 i2)
typedef s64 btime;
typedef s64 bird_clock_t;

#define S_	*1000000
#define MS_	*1000
#define US_	*1
#define S_	* (btime) 1000000
#define MS_	* (btime) 1000
#define US_	* (btime) 1
#define TO_S	/1000000
#define TO_MS	/1000
#define TO_US	/1
@@ -82,6 +82,7 @@ typedef s64 bird_clock_t;
#define S	S_
#define MS	MS_
#define US	US_
#define NS	/1000
#endif


+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include "nest/bird.h"
#include "nest/password.h"
#include "lib/string.h"
#include "lib/timer.h"
#include "lib/mac.h"

struct password_item *last_password_item = NULL;
+3 −3
Original line number Diff line number Diff line
@@ -55,8 +55,8 @@ radv_timer(timer *tm)

  /* Update timer */
  ifa->last = current_time();
  btime t = (btime) ifa->cf->min_ra_int S;
  btime r = (btime) (ifa->cf->max_ra_int - ifa->cf->min_ra_int) S;
  btime t = ifa->cf->min_ra_int S;
  btime r = (ifa->cf->max_ra_int - ifa->cf->min_ra_int) S;
  t += random() % (r + 1);

  if (ifa->initial)
@@ -93,7 +93,7 @@ radv_iface_notify(struct radv_iface *ifa, int event)
  }

  /* Update timer */
  btime t = ifa->last + (btime) ifa->cf->min_delay S - current_time();
  btime t = ifa->last + ifa->cf->min_delay S - current_time();
  tm2_start(ifa->timer, t);
}

+3 −3
Original line number Diff line number Diff line
@@ -147,9 +147,9 @@ rip_iface_item:
 | SPLIT HORIZON bool	{ RIP_IFACE->split_horizon = $3; }
 | POISON REVERSE bool	{ RIP_IFACE->poison_reverse = $3; }
 | CHECK ZERO bool	{ RIP_IFACE->check_zero = $3; }
 | UPDATE TIME expr	{ RIP_IFACE->update_time = (btime) $3 S_; if ($3<=0) cf_error("Update time must be positive"); }
 | TIMEOUT TIME expr	{ RIP_IFACE->timeout_time = (btime) $3 S_; if ($3<=0) cf_error("Timeout time must be positive"); }
 | GARBAGE TIME expr	{ RIP_IFACE->garbage_time = (btime) $3 S_; if ($3<=0) cf_error("Garbage time must be positive"); }
 | UPDATE TIME expr	{ RIP_IFACE->update_time = $3 S_; if ($3<=0) cf_error("Update time must be positive"); }
 | TIMEOUT TIME expr	{ RIP_IFACE->timeout_time = $3 S_; if ($3<=0) cf_error("Timeout time must be positive"); }
 | GARBAGE TIME expr	{ RIP_IFACE->garbage_time = $3 S_; if ($3<=0) cf_error("Garbage time must be positive"); }
 | ECMP WEIGHT expr	{ RIP_IFACE->ecmp_weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("ECMP weight must be in range 1-256"); }
 | RX BUFFER expr	{ RIP_IFACE->rx_buffer = $3; if (($3<256) || ($3>65535)) cf_error("RX length must be in range 256-65535"); }
 | TX LENGTH expr	{ RIP_IFACE->tx_length = $3; if (($3<256) || ($3>65535)) cf_error("TX length must be in range 256-65535"); }
Loading