]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
More off_t related cleanups triggered by Bug #2164.
authorhno <>
Tue, 8 Jan 2008 00:12:28 +0000 (00:12 +0000)
committerhno <>
Tue, 8 Jan 2008 00:12:28 +0000 (00:12 +0000)
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 70e83e54497b97e1d50c06a7db20972a0322a714..4fc7b18040da58198e5980432d0c37984c2f83d5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ESI.cc,v 1.27 2007/12/14 23:11:45 amosjeffries Exp $
+ * $Id: ESI.cc,v 1.28 2008/01/07 17:12:28 hno Exp $
  *
  * DEBUG: section 86    ESI processing
  * AUTHOR: Robert Collins
@@ -1560,7 +1560,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..ffd08638b017d9ad3892d9911b27b39a45421013 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.41 2008/01/07 17:12:28 hno 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 f38dfb7b48a50e1d506710959a60d0d276089892..813d97a5164500bfdb18924c66db374e43f71325 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StoreMetaUnpacker.cc,v 1.6 2007/12/14 19:47:54 hno Exp $
+ * $Id: StoreMetaUnpacker.cc,v 1.7 2008/01/07 17:12:28 hno 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..bc7f1b8d8cdbb0ec93431961ffd70d59f9588ed4 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.3 2008/01/07 17:12:28 hno 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 1d0a59dc71a3cb30bc2b2d407f29e028344b5abb..35273064314df55dd959e955e1fcaf68fa5c7903 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: asn.cc,v 1.117 2007/12/20 11:19:48 amosjeffries Exp $
+ * $Id: asn.cc,v 1.118 2008/01/07 17:12:28 hno Exp $
  *
  * DEBUG: section 53    AS Number handling
  * AUTHOR: Duane Wessels, Kostas Anagnostakis
@@ -93,7 +93,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;
@@ -301,7 +301,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 8b7e73aa4672c834376d4049a974482daa7554d9..1dda0416edacb36f356c2cb02014fa2f4d5d2291 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: client_side.h,v 1.27 2007/12/14 23:11:46 amosjeffries Exp $
+ * $Id: client_side.h,v 1.28 2008/01/07 17:12:28 hno 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 0b44eb42011b015703c1da0f31a843a1de4fe118..dbc465f3d25f20b2ef2532d55e2512906a2cb7b9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.h,v 1.18 2007/12/14 23:11:46 amosjeffries Exp $
+ * $Id: client_side_reply.h,v 1.19 2008/01/07 17:12:28 hno 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..d9a242e377765162db31e1f8f39e91325e3401cd 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.33 2008/01/07 17:12:28 hno 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 85c64d9675ca628e3833dc7db79aca9c98e0cbac..03f0bbb03d198661f7173392b3fb24536e172da7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.440 2008/01/07 16:22:06 hno Exp $
+ * $Id: comm.cc,v 1.441 2008/01/07 17:12:28 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -2038,7 +2038,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 504fc1726b1198242a5ec34fb7326b76156732da..2e518614f5a7770280b7fdd39ff7e0678c7621ab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.h,v 1.10 2007/12/14 23:11:46 amosjeffries Exp $
+ * $Id: helper.h,v 1.11 2008/01/07 17:12:28 hno Exp $
  *
  * DEBUG: section 84    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -121,7 +121,7 @@ struct _helper_server
     MemBuf *writebuf;
     char *rbuf;
     size_t rbuf_sz;
-    off_t roffset;
+    size_t roffset;
 
     struct timeval dispatch_time;
 
@@ -170,7 +170,7 @@ struct _helper_stateful_server
     /* MemBuf writebuf; */
     char *rbuf;
     size_t rbuf_sz;
-    off_t roffset;
+    size_t roffset;
 
     struct timeval dispatch_time;
 
index e9192dab06d8ae5974baf3feabd57679a77b6baf..3ce6f28e4c50a322e1d9a23f04383a7414a93e6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: net_db.cc,v 1.201 2007/12/29 18:15:45 hno Exp $
+ * $Id: net_db.cc,v 1.202 2008/01/07 17:12:28 hno Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -73,7 +73,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;
@@ -685,7 +685,7 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer receivedData)
 
     netdbExchangeState *ex = (netdbExchangeState *)data;
     int rec_sz = 0;
-    off_t o;
+    int o;
 
     struct in_addr line_addr;
     double rtt;
index 91561b1e2bbc5803a9a07860c197461960cacf33..ee7190a4b2dd395c1a2bb54759b097a28a4a8b36 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.129 2007/12/16 22:32:10 amosjeffries Exp $
+ * $Id: peer_digest.cc,v 1.130 2008/01/07 17:12:28 hno 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..ccfa95c71cb8c288241bf44a1d4c7b663f26293f 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.160 2008/01/07 17:12:28 hno 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..45bdda3d400aba23865b7581d4ede73cc6a816a9 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.77 2008/01/07 17:12:28 hno 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..a38a9aa5824957196005d9581b1d08f3e13b6091 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.28 2008/01/07 17:12:28 hno 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 65ccdc6dfc35e6fb6e5f0b4cd55f07ccd6f7a951..473bbc780b972f449ff54e4d5c11aef8371e1e11 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.571 2007/12/27 14:55:47 hno Exp $
+ * $Id: structs.h,v 1.572 2008/01/07 17:12:28 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -768,26 +768,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;
 };
@@ -1609,7 +1595,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 */
@@ -1637,7 +1623,7 @@ struct _Logfile
     char path[MAXPATHLEN];
     char *buf;
     size_t bufsz;
-    off_t offset;
+    size_t offset;
 
     struct
     {
index 82c11b6356da0eee558434bcb80da73b6be12737..eda169f8292d612a1549f2d5d719a78f76daced9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.191 2007/12/14 23:11:48 amosjeffries Exp $
+ * $Id: typedefs.h,v 1.192 2008/01/07 17:12:28 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -96,8 +96,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;