/ Check-in [26c7689c]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix compiler warnings in the proxy locking code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mistake
Files: files | file ages | folders
SHA1: 26c7689cfedf03e65bcd51df68d128101ed2c1ec
User & Date: drh 2010-07-02 17:10:40
Context
2010-07-02
18:15
Fix a couple more compiler warnings under MSVC. check-in: 26bc27e3 user: shaneh tags: mistake
17:10
Fix compiler warnings in the proxy locking code. check-in: 26c7689c user: drh tags: mistake
17:07
Remove a couple of C++ style comments from pager.c. check-in: 4f12e8eb user: drh tags: mistake
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  5063   5063   
  5064   5064     if( lPath[len-1]!='/' ){
  5065   5065       len = strlcat(lPath, "/", maxLen);
  5066   5066     }
  5067   5067     
  5068   5068     /* transform the db path to a unique cache name */
  5069   5069     dbLen = (int)strlen(dbPath);
  5070         -  for( i=0; i<dbLen && (i+len+7)<maxLen; i++){
         5070  +  for( i=0; i<dbLen && (i+len+7)<(int)maxLen; i++){
  5071   5071       char c = dbPath[i];
  5072   5072       lPath[i+len] = (c=='/')?'_':c;
  5073   5073     }
  5074   5074     lPath[i+len]='\0';
  5075   5075     strlcat(lPath, ":auto:", maxLen);
  5076   5076     OSTRACE(("GETLOCKPATH  proxy lock path=%s pid=%d\n", lPath, getpid()));
  5077   5077     return SQLITE_OK;
................................................................................
  5204   5204   #ifdef SQLITE_TEST
  5205   5205   /* simulate multiple hosts by creating unique hostid file paths */
  5206   5206   int sqlite3_hostid_num = 0;
  5207   5207   #endif
  5208   5208   
  5209   5209   #define PROXY_HOSTIDLEN    16  /* conch file host id length */
  5210   5210   
         5211  +/* Not always defined in the headers as it ought to be */
         5212  +extern int gethostuuid(uuid_t id, const struct timespec *wait);
         5213  +
  5211   5214   /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN 
  5212   5215   ** bytes of writable memory.
  5213   5216   */
  5214   5217   static int proxyGetHostID(unsigned char *pHostID, int *pError){
  5215   5218     struct timespec timeout = {1, 0}; /* 1 sec timeout */
  5216   5219     
  5217   5220     assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
................................................................................
  5253   5256     char buf[PROXY_MAXCONCHLEN];
  5254   5257     char *cPath = pCtx->conchFilePath;
  5255   5258     size_t readLen = 0;
  5256   5259     size_t pathLen = 0;
  5257   5260     char errmsg[64] = "";
  5258   5261     int fd = -1;
  5259   5262     int rc = -1;
         5263  +  UNUSED_PARAMETER(myHostID);
  5260   5264   
  5261   5265     /* create a new path by replace the trailing '-conch' with '-break' */
  5262   5266     pathLen = strlcpy(tPath, cPath, MAXPATHLEN);
  5263   5267     if( pathLen>MAXPATHLEN || pathLen<6 || 
  5264   5268        (strlcpy(&tPath[pathLen-5], "break", 6) != 5) ){
  5265   5269       sprintf(errmsg, "path error (len %d)", (int)pathLen);
  5266   5270       goto end_breaklock;
................................................................................
  5273   5277     }
  5274   5278     /* write it out to the temporary break file */
  5275   5279     fd = open(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS);
  5276   5280     if( fd<0 ){
  5277   5281       sprintf(errmsg, "create failed (%d)", errno);
  5278   5282       goto end_breaklock;
  5279   5283     }
  5280         -  if( pwrite(fd, buf, readLen, 0) != readLen ){
         5284  +  if( pwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){
  5281   5285       sprintf(errmsg, "write failed (%d)", errno);
  5282   5286       goto end_breaklock;
  5283   5287     }
  5284   5288     if( rename(tPath, cPath) ){
  5285   5289       sprintf(errmsg, "rename failed (%d)", errno);
  5286   5290       goto end_breaklock;
  5287   5291     }