trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sandhyasun <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #647: [TRAFODION-2146] Use of CQD to set sc...
Date Wed, 10 Aug 2016 06:10:37 GMT
Github user sandhyasun commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/647#discussion_r74190129
  
    --- Diff: core/sql/generator/GenResources.cpp ---
    @@ -97,92 +77,74 @@ static ExScratchDiskDrive * genScratchDriveList(const NAString &def,
       LIST(ExScratchDiskDrive *) tempList;
       CollHeap *heap = generator->wHeap();
       Space *space = generator->getSpace();
    +  struct stat st;
    +  
    + 
    +  Lng32 nodeNum;
    +  char *token = new(heap) char[PATH_MAX];
     
    -  // ---------------------------------------------------------------------
    -  // process the NT default
    -  // ---------------------------------------------------------------------
    -  while (str && *str)
    +  char *sep = (char *)":";
    +  token = strtok((char *)str,sep);
    +  while (token != NULL)
         {
    -      Lng32 nodeNum;
    -      char *driveLetter = new(heap) char[2];
    -
    -      driveLetter[1] = 0;
    -      if (ValidateDiskListNT::getNextDriveLetterAndAdvance(
    -	   str,nodeNum,driveLetter[0]))
    -	{
    -	  // syntax error in default, issue a warning (not an error)
    -	  *CmpCommon::diags() << DgSqlCode(2055)
    +      //validate the directory
    +      if ((stat(token,&st) != 0 ) &&  !S_ISDIR(st.st_mode) ) //&&
(numDirs > MAX_SCRATCH_LOCATIONS))
    +        {
    +          // syntax error in default, issue a warning (not an error)
    +          *CmpCommon::diags() << DgSqlCode(2055)
     			      << DgString0(def)
     			      << DgString1(defName);
    -	  // don't continue after a syntax error
    -	  str = NULL;
    -	}
    +          // don't continue after a syntax error
    +          str = NULL;
    +        }
           else
    -	{
    -	  tempList.insert(new(heap) ExScratchDiskDrive(
    -	       driveLetter,
    -	       1, // Thanks to Bill Gates
    -	       nodeNum));
    -	}
    -
    -      NADELETEBASIC(driveLetter, heap);
    -      driveLetter = NULL;
    -
    +        {
    +          tempList.insert(new(heap) ExScratchDiskDrive(
    +                               token,
    +                               strlen(token) ));
    +        }
    +      token = strtok(NULL,sep);
         }
    +      
    +  NADELETEBASIC(token, heap);
    --- End diff --
    
    Changed it to not allocate the string at all. token would just point to the static array.
Also changed to use strtok_r. Thank you for pointing this out !


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message