Code

rely on what the function returns. errno is only for informatio not for detection...
[rrdtool-all.git] / program / src / rrd_tool.c
index 3a473fa7e91aee809d39651e7ad1559693f2ab72..dfd9890ff2157ac9b333eeb6b664fbc3787b66a5 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.2.19  Copyright by Tobi Oetiker, 1997-2007
+ * RRDtool 1.2.28  Copyright by Tobi Oetiker, 1997-2008
  *****************************************************************************
  * rrd_tool.c  Startup wrapper
  *****************************************************************************/
@@ -22,14 +22,14 @@ 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";
 
     char help_list[] =
           "Valid commands: create, update, updatev, graph, dump, restore,\n"
           "\t\tlast, lastupdate, first, info, fetch, tune,\n"
-          " resize, xport\n\n";
+          "\t\tresize, xport\n\n";
 
     char help_listremote[] =
            "Valid remote commands: quit, ls, cd, mkdir, pwd\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);
           }
@@ -689,8 +682,8 @@ int HandleInputLine(int argc, char **argv, FILE* out)
        char          **legend_v;
         int           enumds = 0;
         int           i;
-        char *vtag = NULL;
-        vtag = malloc( strlen(COL_DATA_TAG)+10);
+        size_t       vtag_s = strlen(COL_DATA_TAG) + 10; 
+        char         *vtag = malloc(vtag_s); 
        for ( i = 2; i < argc; i++){
                if (strcmp("--enumds", argv[i]) == 0)
                        enumds = 1;
@@ -724,9 +717,9 @@ int HandleInputLine(int argc, char **argv, FILE* out)
            for (j = 0; j < col_cnt; j++) {
              rrd_value_t newval = DNAN;
               if (enumds == 1)
-               snprintf(vtag,sizeof(vtag),"%s%lu", COL_DATA_TAG, j);
+               snprintf(vtag,vtag_s,"%s%lu", COL_DATA_TAG, j);
              else
-               snprintf(vtag,sizeof(vtag),"%s",COL_DATA_TAG);
+               snprintf(vtag,vtag_s,"%s",COL_DATA_TAG);
               
              newval = *ptr;
              if(isnan(newval)){