]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: hno
authoramosjeffries <>
Tue, 26 Feb 2008 06:08:50 +0000 (06:08 +0000)
committeramosjeffries <>
Tue, 26 Feb 2008 06:08:50 +0000 (06:08 +0000)
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

17 files changed:
src/ESI.cc
src/Store.h
src/StoreMetaUnpacker.cc
src/StoreMetaUnpacker.h
src/asn.cc
src/client_side.h
src/client_side_reply.h
src/client_side_request.h
src/comm.cc
src/helper.h
src/net_db.cc
src/peer_digest.cc
src/store_client.cc
src/store_digest.cc
src/store_swapmeta.cc
src/structs.h
src/typedefs.h

index bbefa3232d3c25dd9387943540aa4b236ef6954e..58c95c86cc174e9d2a5281e544c6d85879eebfcc 100644 (file)
@@ -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) {
index 4f363d211af933159e6cdb76eef8075e93a09027..eedc311d8a7388382e7b4d6f1426d72adfe70c05 100644 (file)
@@ -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<Store> 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 *);
 
index 07a0df6bc7f30e83c411361eb02ac7f5514e8131..a73e77e3f8db487af8eb393ad89ff4a09cf2bd08 100644 (file)
@@ -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()
index 8cc261e82c350e00cafba47ae8fc7d4cb30a96cc..5457132dba5ef757bba0e07dc8c1a603fcd799bc 100644 (file)
@@ -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;
index a533f2dd112498927ecca745a07b17792e64ceb6..61f917e75b8ecfd7ed35251d3a4d899ee4f03571 100644 (file)
@@ -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++;
 
index 5f40f37e1e23b972c1921798a6fbd2a8ca514c3d..0ad21f186faba0ad503ea00a1af57f63beb14212 100644 (file)
@@ -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;
index de223bbc30e9790e7ed310bec3f247f47b8eadce..df572ac5b28b9e4abab8eca1d8c73e88c5af9fb7 100644 (file)
@@ -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
 
index 92e1b7848d91078dd5b0eca5659d0032ed2fa5c5..eabff48907523850c5e5d3d12214156e7a143ac4 100644 (file)
@@ -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
 };
 
index 03628e9e10b5b78aaade19ce78769b8bad6142eb..5b9390a09d7c8f11b2560b5ed5b472f8f44e9c18 100644 (file)
@@ -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,
index 67992019d0f81f5e98b49c0fa06d4cddbf23dfe8..42239f400f2114c182991f619823a52fe2aba687 100644 (file)
@@ -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;
 
index 96ceead08a31a0d945ab1a85a2955dc734a8b3ad..fb8265501b786cc3079fc50bcaa0770ace601e62 100644 (file)
@@ -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;
index 602a0162f15ac0cc842f99d204af5de8ca323c85..ca7e00324398319ea0e89bf2548a2647aef87e5c 100644 (file)
@@ -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 {
index 3ba1c2c01175c956b5fc9635fb7b564dd9a5a946..35ed66b0fb34ea565f42e9b8832e908e77f7b79f 100644 (file)
@@ -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()
index 21dba733b5144e594a08949e156a3e071200c448..5a5f9b8c256a459f611dc7954f23e72a5a57ba9b 100644 (file)
@@ -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);
index 5f8cca253217eecfb8401babf3510c74daad5b77..8c2601abc9f88d84d7cdbb36be96495c0beb2e11 100644 (file)
@@ -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 */
index ce2a077bf36d0cf161010550ace3ff695bdc496d..67749d902caa92f6afe3244526aaecf4b824ef0b 100644 (file)
@@ -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
     {
index 2246ba0ba6071b22b013653e8a5362dd340e6e75..e47c2658c808cd5d4ebbebcad18aa553b07f0728 100644 (file)
@@ -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;