[Olsr-cvs] olsrd-current/src/cfgparser Makefile, 1.22, 1.23 olsrd_conf.c, 1.51, 1.52 oparse.y, 1.31, 1.32 oscan.lex, 1.21, 1.22

Bernd Petrovitsch (spam-protected)
Fri Apr 20 15:46:07 CEST 2007


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

Modified Files:
	Makefile olsrd_conf.c oparse.y oscan.lex 
Log Message:
cleanup, 1. step (to get some local changes away):
* killed lots of warnings
* added __attribure__((unused)) and __attribure__((format(printf, ..., ...)))
* added "const"
* moved declarations of static functions into .c files
* added "static" declarations
* removed all "inline" declarations. Usually the compiler knows better anyways.
* removed emtpy "return" statements at the end of functions
* localized declarations
* avoided unnecessary data copies
* removed lots of empty lines
There is much more to do.



Index: Makefile
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/Makefile,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Makefile	27 Mar 2007 03:05:21 -0000	1.22
--- Makefile	20 Apr 2007 13:46:05 -0000	1.23
***************
*** 90,98 ****
  		$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
  
! oscan.c:	oscan.lex
! 		$(FLEX) -ooscan.c oscan.lex
  
! oparse.c:	oparse.y olsrd_conf.h
! 		$(BISON) -d -ooparse.c oparse.y
  
  .PHONY: install clean uberclean
--- 90,107 ----
  		$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
  
! oscan.c:	oscan.lex Makefile
! 		$(FLEX) -Cem -ooscan.c oscan.lex
! 		mv oscan.c oscan.c-tmp && \
! 			sed	-e '/^static/s/yy_get_next_buffer[\(][\)]/yy_get_next_buffer(void)/' \
! 				-e '/^static/s/yy_get_previous_state[\(][\)]/yy_get_previous_state(void)/' \
! 				-e '/^static/s/input[\(][\)]/input(void)/' \
! 				-e '/^static  *void  *yy_fatal_error/s/^\(.*)\)\();\)$$/\1 __attribute__((noreturn)) \2/' \
! 				< oscan.c-tmp >oscan.c
! 		$(RM) oscan.c-tmp
  
! oparse.c:	oparse.y olsrd_conf.h Makefile
! 		$(BISON) -d -o oparse.c oparse.y
! 
! #oscan.o oparse.o:: CFLAGS := $(filter-out -Wunreachable-code, $(CFLAGS))
  
  .PHONY: install clean uberclean
***************
*** 106,109 ****
--- 115,119 ----
  		rm -f $(LIBNAME)
  		rm -f $(BINNAME)
+ 		$(RM) oparse.c-tmp
  
  uberclean:	clean

Index: oscan.lex
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/oscan.lex,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** oscan.lex	17 Apr 2006 18:31:09 -0000	1.21
--- oscan.lex	20 Apr 2007 13:46:05 -0000	1.22
***************
*** 75,79 ****
  
  struct conf_token *
! get_conf_token()
  {
    struct conf_token *t = malloc(sizeof(struct conf_token));
--- 75,79 ----
  
  struct conf_token *
! get_conf_token(void)
  {
    struct conf_token *t = malloc(sizeof(struct conf_token));

Index: olsrd_conf.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/olsrd_conf.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** olsrd_conf.c	14 Mar 2007 13:59:30 -0000	1.51
--- olsrd_conf.c	20 Apr 2007 13:46:05 -0000	1.52
***************
*** 420,424 ****
  
  struct olsrd_config *
! olsrd_get_default_cnf()
  {
    cnf = malloc(sizeof(struct olsrd_config));
--- 420,424 ----
  
  struct olsrd_config *
! olsrd_get_default_cnf(void)
  {
    cnf = malloc(sizeof(struct olsrd_config));
***************
*** 482,486 ****
  
  struct if_config_options *
! get_default_if_config()
  {
    struct if_config_options *io = malloc(sizeof(struct if_config_options));
--- 482,486 ----
  
  struct if_config_options *
! get_default_if_config(void)
  {
    struct if_config_options *io = malloc(sizeof(struct if_config_options));
***************
*** 733,736 ****
  }
  #else
! void win32_stdio_hack(unsigned int handle) {}
  #endif
--- 733,736 ----
  }
  #else
! void win32_stdio_hack(unsigned int handle __attribute__((unused))) {}
  #endif

Index: oparse.y
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/cfgparser/oparse.y,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** oparse.y	31 Jan 2007 12:36:50 -0000	1.31
--- oparse.y	20 Apr 2007 13:46:05 -0000	1.32
***************
*** 56,59 ****
--- 56,65 ----
  #define PARSER_DEBUG 0
  
+ #if PARSER_DEBUG
+ #define PARSER_DEBUG_PRINTF(x, ...)   printf(x, ##args)
+ #else
+ #define PARSER_DEBUG_PRINTF(x, ...)   do { } while (0)
+ #endif
+ 
  #define YYSTYPE struct conf_token *
  
***************
*** 306,310 ****
    struct ipc_host *ipch;
  
!   if(PARSER_DEBUG) printf("\tIPC host: %s\n", $2->string);
    
    if(inet_aton($2->string, &in) == 0)
--- 312,316 ----
    struct ipc_host *ipch;
  
!   PARSER_DEBUG_PRINTF("\tIPC host: %s\n", $2->string);
    
    if(inet_aton($2->string, &in) == 0)
***************
*** 331,335 ****
    struct ipc_net *ipcn;
  
!   if(PARSER_DEBUG) printf("\tIPC net: %s/%s\n", $2->string, $3->string);
    
    if(inet_aton($2->string, &in1) == 0)
--- 337,341 ----
    struct ipc_net *ipcn;
  
!   PARSER_DEBUG_PRINTF("\tIPC net: %s/%s\n", $2->string, $3->string);
    
    if(inet_aton($2->string, &in1) == 0)
***************
*** 365,369 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("Fixed willingness: %d\n", $2->integer);
  
    while(ifcnt)
--- 371,375 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("Fixed willingness: %d\n", $2->integer);
  
    while(ifcnt)
***************
*** 386,390 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tIPv4 broadcast: %s\n", $2->string);
  
    if(inet_aton($2->string, &in) == 0)
--- 392,396 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tIPv4 broadcast: %s\n", $2->string);
  
    if(inet_aton($2->string, &in) == 0)
***************
*** 443,447 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tIPv6 site-local multicast: %s\n", $2->string);
  
    if(inet_pton(AF_INET6, $2->string, &in6) < 0)
--- 449,453 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tIPv6 site-local multicast: %s\n", $2->string);
  
    if(inet_pton(AF_INET6, $2->string, &in6) < 0)
***************
*** 472,476 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tIPv6 global multicast: %s\n", $2->string);
  
    if(inet_pton(AF_INET6, $2->string, &in6) < 0)
--- 478,482 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tIPv6 global multicast: %s\n", $2->string);
  
    if(inet_pton(AF_INET6, $2->string, &in6) < 0)
***************
*** 498,502 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tHELLO interval: %0.2f\n", $2->floating);
  
    while(ifcnt)
--- 504,508 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tHELLO interval: %0.2f\n", $2->floating);
  
    while(ifcnt)
***************
*** 516,520 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tHELLO validity: %0.2f\n", $2->floating);
  
    while(ifcnt)
--- 522,526 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tHELLO validity: %0.2f\n", $2->floating);
  
    while(ifcnt)
***************
*** 534,538 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tTC interval: %0.2f\n", $2->floating);
  
    while(ifcnt)
--- 540,544 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tTC interval: %0.2f\n", $2->floating);
  
    while(ifcnt)
***************
*** 551,555 ****
    struct olsr_if *ifs = cnf->interfaces;
    
!   if(PARSER_DEBUG) printf("\tTC validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
--- 557,561 ----
    struct olsr_if *ifs = cnf->interfaces;
    
!   PARSER_DEBUG_PRINTF("\tTC validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
***************
*** 569,573 ****
  
  
!   if(PARSER_DEBUG) printf("\tMID interval: %0.2f\n", $2->floating);
    while(ifcnt)
      {
--- 575,579 ----
  
  
!   PARSER_DEBUG_PRINTF("\tMID interval: %0.2f\n", $2->floating);
    while(ifcnt)
      {
***************
*** 586,590 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tMID validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
--- 592,596 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tMID validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
***************
*** 603,607 ****
    struct olsr_if *ifs = cnf->interfaces;
    
!   if(PARSER_DEBUG) printf("\tHNA interval: %0.2f\n", $2->floating);
    while(ifcnt)
      {
--- 609,613 ----
    struct olsr_if *ifs = cnf->interfaces;
    
!   PARSER_DEBUG_PRINTF("\tHNA interval: %0.2f\n", $2->floating);
    while(ifcnt)
      {
***************
*** 620,624 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tHNA validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
--- 626,630 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tHNA validity: %0.2f\n", $2->floating);
    while(ifcnt)
      {
***************
*** 637,641 ****
    struct olsr_if *ifs = cnf->interfaces;
  
!   if(PARSER_DEBUG) printf("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
    while(ifcnt)
      {
--- 643,647 ----
    struct olsr_if *ifs = cnf->interfaces;
  
!   PARSER_DEBUG_PRINTF("\tAutodetect changes: %s\n", $2->boolean ? "YES" : "NO");
    while(ifcnt)
      {
***************
*** 674,678 ****
  
    cnf->debug_level = $2->integer;
!   if(PARSER_DEBUG) printf("Debug level: %d\n", cnf->debug_level);
    free($2);
  }
--- 680,684 ----
  
    cnf->debug_level = $2->integer;
!   PARSER_DEBUG_PRINTF("Debug level: %d\n", cnf->debug_level);
    free($2);
  }
***************
*** 692,696 ****
      }
  
!   if(PARSER_DEBUG) printf("IpVersion: %d\n", $2->integer);
    free($2);
  }
--- 698,702 ----
      }
  
!   PARSER_DEBUG_PRINTF("IpVersion: %d\n", $2->integer);
    free($2);
  }
***************
*** 703,707 ****
    struct in_addr in;
  
!   if(PARSER_DEBUG) printf("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
  
    if(h == NULL)
--- 709,713 ----
    struct in_addr in;
  
!   PARSER_DEBUG_PRINTF("HNA IPv4 entry: %s/%s\n", $1->string, $2->string);
  
    if(h == NULL)
***************
*** 741,745 ****
    struct in6_addr in6;
  
!   if(PARSER_DEBUG) printf("HNA IPv6 entry: %s/%d\n", $1->string, $2->integer);
  
    if(h == NULL)
--- 747,751 ----
    struct in6_addr in6;
  
!   PARSER_DEBUG_PRINTF("HNA IPv6 entry: %s/%d\n", $1->string, $2->integer);
  
    if(h == NULL)
***************
*** 756,760 ****
    memcpy(&h->net, &in6, sizeof(struct in6_addr));
  
!   if(($2->integer < 0) || ($2->integer > 128))
      {
        fprintf(stderr, "ihna6entry: Illegal IPv6 prefix length %d\n", $2->integer);
--- 762,766 ----
    memcpy(&h->net, &in6, sizeof(struct in6_addr));
  
!   if($2->integer > 128)
      {
        fprintf(stderr, "ihna6entry: Illegal IPv6 prefix length %d\n", $2->integer);
***************
*** 776,780 ****
  ifstart: TOK_INTERFACE
  {
!   if(PARSER_DEBUG) printf("setting ifs_in_curr_cfg = 0\n");
    ifs_in_curr_cfg = 0;
  }
--- 782,786 ----
  ifstart: TOK_INTERFACE
  {
!   PARSER_DEBUG_PRINTF("setting ifs_in_curr_cfg = 0\n");
    ifs_in_curr_cfg = 0;
  }
***************
*** 813,817 ****
  bnoint: TOK_NOINT TOK_BOOLEAN
  {
!   if(PARSER_DEBUG) printf("Noint set to %d\n", $2->boolean);
  
    cnf->allow_no_interfaces = $2->boolean;
--- 819,823 ----
  bnoint: TOK_NOINT TOK_BOOLEAN
  {
!   PARSER_DEBUG_PRINTF("Noint set to %d\n", $2->boolean);
  
    cnf->allow_no_interfaces = $2->boolean;
***************
*** 823,827 ****
  atos: TOK_TOS TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("TOS: %d\n", $2->integer);
    cnf->tos = $2->integer;
  
--- 829,833 ----
  atos: TOK_TOS TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("TOS: %d\n", $2->integer);
    cnf->tos = $2->integer;
  
***************
*** 835,839 ****
    cnf->willingness_auto = OLSR_FALSE;
  
!   if(PARSER_DEBUG) printf("Willingness: %d\n", $2->integer);
    cnf->willingness = $2->integer;
  
--- 841,845 ----
    cnf->willingness_auto = OLSR_FALSE;
  
!   PARSER_DEBUG_PRINTF("Willingness: %d\n", $2->integer);
    cnf->willingness = $2->integer;
  
***************
*** 850,858 ****
    if(cnf->use_hysteresis)
      {
!       if(PARSER_DEBUG) printf("Hysteresis enabled\n");
      }
    else
      {
!       if(PARSER_DEBUG) printf("Hysteresis disabled\n");
      }
    free($2);
--- 856,864 ----
    if(cnf->use_hysteresis)
      {
!       PARSER_DEBUG_PRINTF("Hysteresis enabled\n");
      }
    else
      {
!       PARSER_DEBUG_PRINTF("Hysteresis disabled\n");
      }
    free($2);
***************
*** 865,869 ****
  {
    cnf->hysteresis_param.scaling = $2->floating;
!   if(PARSER_DEBUG) printf("Hysteresis Scaling: %0.2f\n", $2->floating);
    free($2);
  }
--- 871,875 ----
  {
    cnf->hysteresis_param.scaling = $2->floating;
!   PARSER_DEBUG_PRINTF("Hysteresis Scaling: %0.2f\n", $2->floating);
    free($2);
  }
***************
*** 874,878 ****
  {
    cnf->hysteresis_param.thr_high = $2->floating;
!   if(PARSER_DEBUG) printf("Hysteresis UpperThr: %0.2f\n", $2->floating);
    free($2);
  }
--- 880,884 ----
  {
    cnf->hysteresis_param.thr_high = $2->floating;
!   PARSER_DEBUG_PRINTF("Hysteresis UpperThr: %0.2f\n", $2->floating);
    free($2);
  }
***************
*** 883,887 ****
  {
    cnf->hysteresis_param.thr_low = $2->floating;
!   if(PARSER_DEBUG) printf("Hysteresis LowerThr: %0.2f\n", $2->floating);
    free($2);
  }
--- 889,893 ----
  {
    cnf->hysteresis_param.thr_low = $2->floating;
!   PARSER_DEBUG_PRINTF("Hysteresis LowerThr: %0.2f\n", $2->floating);
    free($2);
  }
***************
*** 890,894 ****
  fpollrate: TOK_POLLRATE TOK_FLOAT
  {
!   if(PARSER_DEBUG) printf("Pollrate %0.2f\n", $2->floating);
    cnf->pollrate = $2->floating;
  
--- 896,900 ----
  fpollrate: TOK_POLLRATE TOK_FLOAT
  {
!   PARSER_DEBUG_PRINTF("Pollrate %0.2f\n", $2->floating);
    cnf->pollrate = $2->floating;
  
***************
*** 899,903 ****
  fnicchgspollrt: TOK_NICCHGSPOLLRT TOK_FLOAT
  {
!   if(PARSER_DEBUG) printf("NIC Changes Pollrate %0.2f\n", $2->floating);
    cnf->nic_chgs_pollrate = $2->floating;
  
--- 905,909 ----
  fnicchgspollrt: TOK_NICCHGSPOLLRT TOK_FLOAT
  {
!   PARSER_DEBUG_PRINTF("NIC Changes Pollrate %0.2f\n", $2->floating);
    cnf->nic_chgs_pollrate = $2->floating;
  
***************
*** 908,912 ****
  atcredundancy: TOK_TCREDUNDANCY TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("TC redundancy %d\n", $2->integer);
    cnf->tc_redundancy = $2->integer;
    free($2);
--- 914,918 ----
  atcredundancy: TOK_TCREDUNDANCY TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("TC redundancy %d\n", $2->integer);
    cnf->tc_redundancy = $2->integer;
    free($2);
***************
*** 916,920 ****
  amprcoverage: TOK_MPRCOVERAGE TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("MPR coverage %d\n", $2->integer);
    cnf->mpr_coverage = $2->integer;
    free($2);
--- 922,926 ----
  amprcoverage: TOK_MPRCOVERAGE TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("MPR coverage %d\n", $2->integer);
    cnf->mpr_coverage = $2->integer;
    free($2);
***************
*** 924,928 ****
  alq_level: TOK_LQ_LEVEL TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("Link quality level %d\n", $2->integer);
    cnf->lq_level = $2->integer;
    free($2);
--- 930,934 ----
  alq_level: TOK_LQ_LEVEL TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("Link quality level %d\n", $2->integer);
    cnf->lq_level = $2->integer;
    free($2);
***************
*** 932,936 ****
  alq_fish: TOK_LQ_FISH TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("Link quality fish eye %d\n", $2->integer);
    cnf->lq_fish = $2->integer;
    free($2);
--- 938,942 ----
  alq_fish: TOK_LQ_FISH TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("Link quality fish eye %d\n", $2->integer);
    cnf->lq_fish = $2->integer;
    free($2);
***************
*** 940,944 ****
  alq_dlimit: TOK_LQ_DLIMIT TOK_INTEGER TOK_FLOAT
  {
!   if(PARSER_DEBUG) printf("Link quality dijkstra limit %d, %0.2f\n", $2->integer, $3->floating);
    cnf->lq_dlimit = $2->integer;
    cnf->lq_dinter = $3->floating;
--- 946,950 ----
  alq_dlimit: TOK_LQ_DLIMIT TOK_INTEGER TOK_FLOAT
  {
!   PARSER_DEBUG_PRINTF("Link quality dijkstra limit %d, %0.2f\n", $2->integer, $3->floating);
    cnf->lq_dlimit = $2->integer;
    cnf->lq_dinter = $3->floating;
***************
*** 949,953 ****
  alq_wsize: TOK_LQ_WSIZE TOK_INTEGER
  {
!   if(PARSER_DEBUG) printf("Link quality window size %d\n", $2->integer);
    cnf->lq_wsize = $2->integer;
    free($2);
--- 955,959 ----
  alq_wsize: TOK_LQ_WSIZE TOK_INTEGER
  {
!   PARSER_DEBUG_PRINTF("Link quality window size %d\n", $2->integer);
    cnf->lq_wsize = $2->integer;
    free($2);
***************
*** 959,964 ****
    cnf->clear_screen = $2->boolean;
  
!   if (PARSER_DEBUG)
!     printf("Clear screen %s\n", cnf->clear_screen ? "enabled" : "disabled");
  
    free($2);
--- 965,969 ----
    cnf->clear_screen = $2->boolean;
  
!   PARSER_DEBUG_PRINTF("Clear screen %s\n", cnf->clear_screen ? "enabled" : "disabled");
  
    free($2);
***************
*** 980,984 ****
    pe->params = NULL;
    
!   if(PARSER_DEBUG) printf("Plugin: %s\n", $2->string);
  
    /* Queue */
--- 985,989 ----
    pe->params = NULL;
    
!   PARSER_DEBUG_PRINTF("Plugin: %s\n", $2->string);
  
    /* Queue */
***************
*** 1000,1004 ****
      }
    
!   if(PARSER_DEBUG) printf("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
    
    pp->key = $2->string;
--- 1005,1009 ----
      }
    
!   PARSER_DEBUG_PRINTF("Plugin param key:\"%s\" val: \"%s\"\n", $2->string, $3->string);
    
    pp->key = $2->string;
***************
*** 1016,1020 ****
  vcomment:       TOK_COMMENT
  {
!     //if(PARSER_DEBUG) printf("Comment\n");
  }
  ;
--- 1021,1025 ----
  vcomment:       TOK_COMMENT
  {
!     //PARSER_DEBUG_PRINTF("Comment\n");
  }
  ;





More information about the Olsr-cvs mailing list