From: amosjeffries <> Date: Tue, 26 Feb 2008 06:08:50 +0000 (+0000) Subject: Author: hno X-Git-Tag: SQUID_3_0_STABLE2~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a890cff6e65dffa4a1ed78731087deb171b01910;p=thirdparty%2Fsquid.git Author: hno More off_t related cleanups triggered by Bug #2164. This patch cleans up various pieces of code, from an off_t usage audit triggered by Bug #2164. off_t should be used for on-disk file offsets/positions only, not internal buffers or object offsets. object offsets should use int64_t buffer offsets size_t or int, or maybe ssize_t if negative values allowed --- diff --git a/src/ESI.cc b/src/ESI.cc index bbefa3232d..58c95c86cc 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.26.2.1 2008/02/10 10:43:09 serassio Exp $ + * $Id: ESI.cc,v 1.26.2.2 2008/02/25 23:08:50 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -1566,7 +1566,7 @@ esiLiteral::esiLiteral(ESIContext *context, const char *s, int numberOfCharacter assert (s); buffer = new ESISegment; ESISegment::Pointer local = buffer; - off_t start = 0; + size_t start = 0; int remainingCharacters = numberOfCharacters; while (remainingCharacters > 0) { diff --git a/src/Store.h b/src/Store.h index 4f363d211a..eedc311d8a 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.40 2007/11/18 17:19:35 serassio Exp $ + * $Id: Store.h,v 1.40.2.1 2008/02/25 23:08:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -301,9 +301,6 @@ private: typedef RefCount StorePointer; SQUIDCEXTERN size_t storeEntryInUse(); -#if UNUSED_CODE_20070420 -SQUIDCEXTERN off_t storeLowestMemReaderOffset(const StoreEntry * entry); -#endif SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *); extern void storeEntryReplaceObject(StoreEntry *, HttpReply *); diff --git a/src/StoreMetaUnpacker.cc b/src/StoreMetaUnpacker.cc index 07a0df6bc7..a73e77e3f8 100644 --- a/src/StoreMetaUnpacker.cc +++ b/src/StoreMetaUnpacker.cc @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaUnpacker.cc,v 1.5.4.1 2008/02/24 11:28:09 amosjeffries Exp $ + * $Id: StoreMetaUnpacker.cc,v 1.5.4.2 2008/02/25 23:08:50 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager Swapfile Unpacker * AUTHOR: Robert Collins @@ -37,7 +37,7 @@ #include "StoreMetaUnpacker.h" #include "StoreMeta.h" -off_t const StoreMetaUnpacker::MinimumBufferLength = sizeof(char) + sizeof(int); +int const StoreMetaUnpacker::MinimumBufferLength = sizeof(char) + sizeof(int); bool StoreMetaUnpacker::isBufferSane() diff --git a/src/StoreMetaUnpacker.h b/src/StoreMetaUnpacker.h index 8cc261e82c..5457132dba 100644 --- a/src/StoreMetaUnpacker.h +++ b/src/StoreMetaUnpacker.h @@ -1,6 +1,6 @@ /* - * $Id: StoreMetaUnpacker.h,v 1.2 2003/02/21 22:50:06 robertc Exp $ + * $Id: StoreMetaUnpacker.h,v 1.2.4.1 2008/02/25 23:08:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -45,7 +45,7 @@ public: bool isBufferSane(); private: - static off_t const MinimumBufferLength; + static int const MinimumBufferLength; void getBufferLength(); void getType(); @@ -57,7 +57,7 @@ private: char const * const buf; ssize_t buflen; int *hdr_len; - off_t position; + int position; char type; int length; StoreMeta **tail; diff --git a/src/asn.cc b/src/asn.cc index a533f2dd11..61f917e75b 100644 --- a/src/asn.cc +++ b/src/asn.cc @@ -1,6 +1,6 @@ /* - * $Id: asn.cc,v 1.115 2007/09/21 11:41:52 amosjeffries Exp $ + * $Id: asn.cc,v 1.115.2.1 2008/02/25 23:08:50 amosjeffries Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -89,7 +89,7 @@ struct ASState store_client *sc; HttpRequest *request; int as_number; - off_t offset; + int64_t offset; int reqofs; char reqbuf[AS_REQBUF_SZ]; bool dataRead; @@ -299,7 +299,7 @@ asHandleReply(void *data, StoreIOBuffer result) */ s = buf; - while (s - buf < (off_t)(result.length + asState->reqofs) && *s != '\0') { + while ((size_t)(s - buf) < result.length + asState->reqofs && *s != '\0') { while (*s && xisspace(*s)) s++; diff --git a/src/client_side.h b/src/client_side.h index 5f40f37e1e..0ad21f186f 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -1,5 +1,5 @@ /* - * $Id: client_side.h,v 1.26 2007/10/31 04:52:16 amosjeffries Exp $ + * $Id: client_side.h,v 1.26.2.1 2008/02/25 23:08:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -95,7 +95,7 @@ unsigned parsed_ok: 1; /* Was this parsed correctly? */ }; DeferredParams deferredparams; - off_t writtenToSocket; + int64_t writtenToSocket; void pullData(); int64_t getNextRangeOffset() const; bool canPackMoreRanges() const; diff --git a/src/client_side_reply.h b/src/client_side_reply.h index de223bbc30..df572ac5b2 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.h,v 1.17 2007/05/09 07:36:24 wessels Exp $ + * $Id: client_side_reply.h,v 1.17.4.1 2008/02/25 23:08:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -98,7 +98,7 @@ public: StoreIOBuffer tempBuffer; /* For use in validating requests via IMS */ int old_reqsize; /* ... again, for the buffer */ size_t reqsize; - off_t reqofs; + size_t reqofs; char tempbuf[HTTP_REQBUF_SZ]; /* a temporary buffer if we need working storage */ #if USE_CACHE_DIGESTS diff --git a/src/client_side_request.h b/src/client_side_request.h index 92e1b7848d..eabff48907 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.h,v 1.32 2007/08/13 17:20:51 hno Exp $ + * $Id: client_side_request.h,v 1.32.2.1 2008/02/25 23:08:50 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -183,7 +183,7 @@ private: BodyPipe::Pointer icapBodySource; bool request_satisfaction_mode; - off_t request_satisfaction_offset; + int64_t request_satisfaction_offset; #endif }; diff --git a/src/comm.cc b/src/comm.cc index 03628e9e10..5b9390a09d 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,5 +1,5 @@ /* - * $Id: comm.cc,v 1.438.2.1 2008/02/25 03:45:24 amosjeffries Exp $ + * $Id: comm.cc,v 1.438.2.2 2008/02/25 23:08:50 amosjeffries Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1898,7 +1898,7 @@ commHandleWrite(int fd, void *data) { /* A successful write, continue */ state->offset += len; - if (state->offset < (off_t)state->size) { + if (state->offset < state->size) { /* Not done, reinstall the write handler and write some more */ commSetSelect(fd, COMM_SELECT_WRITE, diff --git a/src/helper.h b/src/helper.h index 67992019d0..42239f400f 100644 --- a/src/helper.h +++ b/src/helper.h @@ -1,6 +1,6 @@ /* - * $Id: helper.h,v 1.9 2007/05/07 18:38:40 wessels Exp $ + * $Id: helper.h,v 1.9.4.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -117,7 +117,7 @@ struct _helper_server MemBuf *writebuf; char *rbuf; size_t rbuf_sz; - off_t roffset; + size_t roffset; struct timeval dispatch_time; @@ -164,7 +164,7 @@ struct _helper_stateful_server /* MemBuf writebuf; */ char *rbuf; size_t rbuf_sz; - off_t roffset; + size_t roffset; struct timeval dispatch_time; diff --git a/src/net_db.cc b/src/net_db.cc index 96ceead08a..fb8265501b 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.198 2007/11/27 07:48:40 amosjeffries Exp $ + * $Id: net_db.cc,v 1.198.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -72,7 +72,7 @@ typedef struct StoreEntry *e; store_client *sc; HttpRequest *r; - off_t used; + int64_t used; size_t buf_sz; char buf[NETDB_REQBUF_SZ]; int buf_ofs; @@ -678,7 +678,7 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData) { netdbExchangeState *ex = (netdbExchangeState *)data; int rec_sz = 0; - off_t o; + int o; struct IN_ADDR addr; double rtt; diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 602a0162f1..ca7e003243 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.127 2007/08/27 12:50:43 hno Exp $ + * $Id: peer_digest.cc,v 1.127.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -724,10 +724,10 @@ peerDigestSwapInMask(void *data, char *buf, ssize_t size) fetch->mask_offset += size; - if (fetch->mask_offset >= (off_t)pd->cd->mask_size) { + if (fetch->mask_offset >= pd->cd->mask_size) { debugs(72, 2, "peerDigestSwapInMask: Done! Got " << fetch->mask_offset << ", expected " << pd->cd->mask_size); - assert(fetch->mask_offset == (off_t)pd->cd->mask_size); + assert(fetch->mask_offset == pd->cd->mask_size); assert(peerDigestFetchedEnough(fetch, NULL, 0, "peerDigestSwapInMask")); return -1; /* XXX! */ } else { diff --git a/src/store_client.cc b/src/store_client.cc index 3ba1c2c011..35ed66b0fb 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.159 2007/08/27 12:50:43 hno Exp $ + * $Id: store_client.cc,v 1.159.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -698,14 +698,6 @@ storeUnregister(store_client * sc, StoreEntry * e, void *data) return 1; } -#if UNUSED_CODE_20070420 -off_t -storeLowestMemReaderOffset(const StoreEntry * entry) -{ - return entry->mem_obj->lowestMemReaderOffset(); -} -#endif - /* Call handlers waiting for data to be appended to E. */ void StoreEntry::invokeHandlers() diff --git a/src/store_digest.cc b/src/store_digest.cc index 21dba733b5..5a5f9b8c25 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: store_digest.cc,v 1.76 2007/08/13 17:20:51 hno Exp $ + * $Id: store_digest.cc,v 1.76.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -466,7 +466,7 @@ storeDigestSwapOutStep(void *data) assert(e); /* _add_ check that nothing bad happened while we were waiting @?@ @?@ */ - if ((size_t)(sd_state.rewrite_offset + chunk_size) > store_digest->mask_size) + if (sd_state.rewrite_offset + chunk_size > store_digest->mask_size) chunk_size = store_digest->mask_size - sd_state.rewrite_offset; e->append(store_digest->mask + sd_state.rewrite_offset, chunk_size); @@ -478,7 +478,7 @@ storeDigestSwapOutStep(void *data) sd_state.rewrite_offset += chunk_size; /* are we done ? */ - if ((size_t)sd_state.rewrite_offset >= store_digest->mask_size) + if (sd_state.rewrite_offset >= store_digest->mask_size) storeDigestRewriteFinish(e); else eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, data, 0.0, 1, false); diff --git a/src/store_swapmeta.cc b/src/store_swapmeta.cc index 5f8cca2532..8c2601abc9 100644 --- a/src/store_swapmeta.cc +++ b/src/store_swapmeta.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapmeta.cc,v 1.27 2007/11/15 16:47:35 wessels Exp $ + * $Id: store_swapmeta.cc,v 1.27.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -110,7 +110,7 @@ storeSwapMetaPack(tlv * tlv_list, int *length) { int buflen = 0; tlv *t; - off_t j = 0; + int j = 0; char *buf; assert(length != NULL); buflen++; /* STORE_META_OK */ diff --git a/src/structs.h b/src/structs.h index ce2a077bf3..67749d902c 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.568 2007/12/02 08:23:56 amosjeffries Exp $ + * $Id: structs.h,v 1.568.2.1 2008/02/25 23:08:51 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -774,26 +774,12 @@ struct _dread_ctrl void *client_data; }; -struct _dnsserver_t -{ - int id; - int inpipe; - int outpipe; - time_t answer; - off_t offset; - size_t size; - char ip_inbuf[DNS_INBUF_SZ]; - - struct timeval dispatch_time; - void *data; -}; - struct _dwrite_q { off_t file_offset; char *buf; - int len; - off_t buf_offset; + size_t len; + size_t buf_offset; dwrite_q *next; FREE *free_func; }; @@ -1637,7 +1623,7 @@ struct _CacheDigest { /* public, read-only */ char *mask; /* bit mask */ - size_t mask_size; /* mask size in bytes */ + int mask_size; /* mask size in bytes */ int capacity; /* expected maximum for .count, not a hard limit */ int bits_per_entry; /* number of bits allocated for each entry from capacity */ int count; /* number of digested entries */ @@ -1665,7 +1651,7 @@ struct _Logfile char path[MAXPATHLEN]; char *buf; size_t bufsz; - off_t offset; + size_t offset; struct { diff --git a/src/typedefs.h b/src/typedefs.h index 2246ba0ba6..e47c2658c8 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.190 2007/05/09 07:45:58 wessels Exp $ + * $Id: typedefs.h,v 1.190.4.1 2008/02/25 23:08:51 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -98,8 +98,6 @@ typedef struct _close_handler close_handler; typedef struct _dread_ctrl dread_ctrl; -typedef struct _dnsserver_t dnsserver_t; - typedef struct _dwrite_q dwrite_q; typedef struct _ETag ETag;