[Olsr-cvs] olsrd-current/src main.c,1.102,1.103

Bernd Petrovitsch (spam-protected)
Wed Nov 21 00:19:10 CET 2007


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

Modified Files:
	main.c 
Log Message:
* use "__attribute__((unused))"
* "olsr_argv = argv" is not used in Win32 so compile completely it out
* Fixed a compiler warning reported by (spam-protected)
* avoid to cluttered source
* sanitize macros


Index: main.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/main.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -C2 -d -r1.102 -r1.103
*** main.c	8 Nov 2007 22:47:41 -0000	1.102
--- main.c	20 Nov 2007 23:19:08 -0000	1.103
***************
*** 96,102 ****
  		       struct if_config_options *);
  
  static char **olsr_argv;
  
! static char copyright_string[] = "The olsr.org Optimized Link-State Routing daemon(olsrd) Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  
--- 96,104 ----
  		       struct if_config_options *);
  
+ #ifndef WIN32
  static char **olsr_argv;
+ #endif
  
! static char copyright_string[] __attribute__((unused)) = "The olsr.org Optimized Link-State Routing daemon(olsrd) Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  
***************
*** 119,128 ****
  #endif
  
-   /* Stop the compiler from complaining */
-   (void)copyright_string;
- 
    debug_handle = stdout;
    olsr_argv = argv;
! 
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
--- 121,128 ----
  #endif
  
    debug_handle = stdout;
+ #ifndef WIN32
    olsr_argv = argv;
! #endif
    setbuf(stdout, NULL);
    setbuf(stderr, NULL);
***************
*** 145,157 ****
  #endif
  
-   /* Grab initial timestamp */
-   now_times = times(&tms_buf);
- 
    /* Open syslog */
    olsr_openlog("olsrd");
  
!   /* Get initial timestep */
    do {
!     nowtm = localtime(&now.tv_sec);
    } while (nowtm == NULL);
      
--- 145,156 ----
  #endif
  
    /* Open syslog */
    olsr_openlog("olsrd");
  
!   /* Grab initial timestamp */
!   now_times = times(&tms_buf);
    do {
!     time_t t = now.tv_sec;
!     nowtm = localtime(&t);
    } while (nowtm == NULL);
      
***************
*** 216,224 ****
        olsr_cnf = olsrd_get_default_cnf();
      }
!   if((default_ifcnf = get_default_if_config()) == NULL)
!     {
!       fprintf(stderr, "No default ifconfig found!\n");
!       exit(EXIT_FAILURE);
!     }
  
    /* Initialize tick resolution */
--- 215,224 ----
        olsr_cnf = olsrd_get_default_cnf();
      }
! 
!   default_ifcnf = get_default_if_config();
!   if (default_ifcnf == NULL) {
!     fprintf(stderr, "No default ifconfig found!\n");
!     exit(EXIT_FAILURE);
!   }
  
    /* Initialize tick resolution */
***************
*** 385,397 ****
    /* daemon mode */
  #ifndef WIN32
!   if((olsr_cnf->debug_level == 0) && (!olsr_cnf->no_fork))
!     {
!       printf("%s detaching from the current process...\n", olsrd_version);
!       if(daemon(0, 0) < 0)
! 	{
! 	  printf("daemon(3) failed: %s\n", strerror(errno));
! 	  exit(EXIT_FAILURE);
! 	}
      }
  #endif
  
--- 385,395 ----
    /* daemon mode */
  #ifndef WIN32
!   if(olsr_cnf->debug_level == 0 && !olsr_cnf->no_fork) {
!     printf("%s detaching from the current process...\n", olsrd_version);
!     if (daemon(0, 0) < 0) {
!       printf("daemon(3) failed: %s\n", strerror(errno));
!       exit(EXIT_FAILURE);
      }
+   }
  #endif
  
***************
*** 430,436 ****
    scheduler();
  
-   /* Stop the compiler from complaining */
-   (void)copyright_string;
- 
    /* Like we're ever going to reach this ;-) */
    return 1;
--- 428,431 ----
***************
*** 573,587 ****
  
  
! #define NEXT_ARG argv++;argc--
! #define CHECK_ARGC if(!argc) { \
        if((argc - 1) == 1){ \
        fprintf(stderr, "Error parsing command line options!\n"); \
-       olsr_exit(__func__, EXIT_FAILURE); \
        } else { \
        argv--; \
        fprintf(stderr, "You must provide a parameter when using the %s switch!\n", *argv); \
-       olsr_exit(__func__, EXIT_FAILURE); \
       } \
!      }
  
  /**
--- 568,581 ----
  
  
! #define NEXT_ARG do { argv++;argc--; } while (0)
! #define CHECK_ARGC do { if(!argc) { \
        if((argc - 1) == 1){ \
        fprintf(stderr, "Error parsing command line options!\n"); \
        } else { \
        argv--; \
        fprintf(stderr, "You must provide a parameter when using the %s switch!\n", *argv); \
       } \
!      olsr_exit(__func__, EXIT_FAILURE); \
!      } } while (0)
  
  /**





More information about the Olsr-cvs mailing list