Code

rely on what the function returns. errno is only for informatio not for detection...
[rrdtool-all.git] / program / src / rrd_tool.c
index 2068b6fbba943a4129b731f38e3a520b8307e505..dfd9890ff2157ac9b333eeb6b664fbc3787b66a5 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.2.22  Copyright by Tobi Oetiker, 1997-2007
+ * RRDtool 1.2.28  Copyright by Tobi Oetiker, 1997-2008
  *****************************************************************************
  * rrd_tool.c  Startup wrapper
  *****************************************************************************/
@@ -22,7 +22,7 @@ void PrintUsage(char *cmd)
 {
 
     char help_main[] =
-          "RRDtool " PACKAGE_VERSION "  Copyright 1997-2007 by Tobias Oetiker <tobi@oetiker.ch>\n"
+          "RRDtool " PACKAGE_VERSION "  Copyright 1997-2008 by Tobias Oetiker <tobi@oetiker.ch>\n"
            "               Compiled " __DATE__ " " __TIME__ "\n\n"
           "Usage: rrdtool [options] command command_options\n\n";
 
@@ -364,11 +364,8 @@ int main(int argc, char *argv[])
          struct rusage  myusage;
          struct timeval starttime;
          struct timeval currenttime;
-         struct timezone tz;
 
-           tz.tz_minuteswest =0;
-           tz.tz_dsttime=0;
-           gettimeofday(&starttime,&tz);
+         gettimeofday(&starttime, NULL);
 #endif
          RemoteMode=1;
           if ((argc == 3) && strcmp("",argv[2])){
@@ -382,8 +379,7 @@ int main(int argc, char *argv[])
                 == 0 ){
 
 #ifdef HAVE_CHROOT
-                chroot(argv[2]);
-                if (errno!=0){
+                if (chroot(argv[2]) != 0){
                    fprintf(stderr,"ERROR: can't change root to '%s' errno=%d\n",
                            argv[2],errno);
                     exit(errno);
@@ -400,8 +396,7 @@ int main(int argc, char *argv[])
              }
           }
           if (strcmp(firstdir,"")){
-             chdir(firstdir);
-             if (errno!=0){
+             if (chdir(firstdir)!=0){
                 fprintf(stderr,"ERROR: %s\n",rrd_strerror(errno));
                 exit(errno);
              }
@@ -426,7 +421,7 @@ int main(int argc, char *argv[])
 
 #if HAVE_GETRUSAGE
                     getrusage(RUSAGE_SELF,&myusage);
-                    gettimeofday(&currenttime,&tz);
+                    gettimeofday(&currenttime,NULL);
                     printf("OK u:%1.2f s:%1.2f r:%1.2f\n",
                       (double)myusage.ru_utime.tv_sec+
                       (double)myusage.ru_utime.tv_usec/1000000.0,
@@ -499,8 +494,7 @@ int HandleInputLine(int argc, char **argv, FILE* out)
              return(1); 
           }
 #endif
-          chdir(argv[2]);
-          if (errno!=0){
+          if (chdir(argv[2]) != 0){
              printf("ERROR: %s\n",rrd_strerror(errno));
             return(1);
           }
@@ -532,8 +526,7 @@ int HandleInputLine(int argc, char **argv, FILE* out)
              return(1); 
           }
 #endif
-          mkdir(argv[2],0777);
-          if (errno!=0){
+          if (mkdir(argv[2],0777) != 0){
              printf("ERROR: %s\n",rrd_strerror(errno));
              return(1);
           }