5df4ac5c2048475a1b19915200cd360e125f41a3 galt Thu Nov 21 17:13:25 2013 -0800 fixing compiler warnings diff --git src/lib/udc.c src/lib/udc.c index a864432..4c1746a 100644 --- src/lib/udc.c +++ src/lib/udc.c @@ -112,31 +112,31 @@ #define udcBitmapHeaderSize (64) static int cacheTimeout = 0; #define MAX_SKIP_TO_SAVE_RECONNECT (udcMaxBytesPerRemoteFetch / 2) static void readAndIgnore(int sd, bits64 size) /* Read size bytes from sd and return. */ { static char *buf = NULL; if (buf == NULL) buf = needMem(udcBlockSize); bits64 remaining = size, total = 0; while (remaining > 0) { bits64 chunkSize = min(remaining, udcBlockSize); - bits64 rd = read(sd, buf, chunkSize); + ssize_t rd = read(sd, buf, chunkSize); if (rd < 0) errnoAbort("readAndIgnore: error reading socket after %lld bytes", total); remaining -= rd; total += rd; } if (total < size) errAbort("readAndIgnore: got EOF at %lld bytes (wanted %lld)", total, size); } static int connInfoGetSocket(struct connInfo *ci, char *url, bits64 offset, int size) /* If ci has an open socket and the given offset matches ci's current offset, * reuse ci->socket. Otherwise close the socket, open a new one, and update ci, * or return -1 if there is an error opening a new one. */ { if (ci != NULL && ci->socket > 0 && ci->offset != offset) @@ -352,36 +352,37 @@ } boolean udcInfoViaHttp(char *url, struct udcRemoteFileInfo *retInfo) /* Gets size and last modified time of URL * and returns status of HEAD GET. */ { verbose(2, "checking http remote info on %s\n", url); struct hash *hash = newHash(0); int status = netUrlHead(url, hash); if (status != 200) // && status != 302 && status != 301) return FALSE; char *sizeString = hashFindValUpperCase(hash, "Content-Length:"); if (sizeString == NULL) { /* try to get remote file size by an alternate method */ - retInfo->size = netUrlSizeByRangeResponse(url); - if (retInfo->size < 0) + long long retSize = netUrlSizeByRangeResponse(url); + if (retSize < 0) { hashFree(&hash); errAbort("No Content-Length: returned in header for %s, can't proceed, sorry", url); } + retInfo->size = retSize; } else { retInfo->size = atoll(sizeString); } char *lastModString = hashFindValUpperCase(hash, "Last-Modified:"); if (lastModString == NULL) { // Date is a poor substitute! It will always appear that the cache is stale. // But at least we can read files from dropbox.com. lastModString = hashFindValUpperCase(hash, "Date:"); if (lastModString == NULL) { hashFree(&hash);