]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Turned SwapDir.flags, Format::Token.flags CossMemBuf.flags, CossState.flags,
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 31 Jan 2013 15:05:34 +0000 (16:05 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 31 Jan 2013 15:05:34 +0000 (16:05 +0100)
Fs::Ufs::RebuildState.flags to bool

src/SwapDir.cc
src/SwapDir.h
src/format/Token.cc
src/format/Token.h
src/fs/coss/store_coss.h
src/fs/coss/store_dir_coss.cc
src/fs/coss/store_io_coss.cc
src/fs/ufs/RebuildState.cc
src/fs/ufs/RebuildState.h
src/store_dir.cc

index 94e7de2d2347719fac27493d7668de165afa0bd6..384125dc51b7ee569a26a8e302481b51bfe28431 100644 (file)
@@ -238,7 +238,7 @@ SwapDir::getOptionTree() const
 void
 SwapDir::parseOptions(int isaReconfig)
 {
-    unsigned int old_read_only = flags.read_only;
+    const bool old_read_only = flags.read_only;
     char *name, *value;
 
     ConfigOption *newOption = getOptionTree();
@@ -290,12 +290,12 @@ SwapDir::optionReadOnlyParse(char const *option, const char *value, int isaRecon
     if (strcmp(option, "no-store") != 0 && strcmp(option, "read-only") != 0)
         return false;
 
-    int read_only = 0;
+    bool read_only = 0;
 
     if (value)
-        read_only = xatoi(value);
+        read_only = (xatoi(value) != 0);
     else
-        read_only = 1;
+        read_only = true;
 
     flags.read_only = read_only;
 
index 488cafca918279a9b82177561874b9fadba12e31..16e24ab87069b506de8bb6ae863bf1bb5d686ffe 100644 (file)
@@ -192,9 +192,9 @@ public:
     int scanned;
 
     struct Flags {
-        Flags() : selected(0), read_only(0) {}
-        unsigned int selected:1;
-        unsigned int read_only:1;
+        Flags() : selected(false), read_only(false) {}
+        bool selected;
+        bool read_only;
     } flags;
     virtual void init() = 0;   /* Initialise the fs */
     virtual void create();     /* Create a new fs */
index 7c24bb0ce0a6136e7b489178c1cf6630df60ae84..b9c0a63b31ccbe97282add3915a42767170d06c9 100644 (file)
@@ -322,12 +322,12 @@ Format::Token::parse(const char *def, Quoting *quoting)
     }
 
     if (*cur == '-') {
-        left = 1;
+        left = true;
         ++cur;
     }
 
     if (*cur == '0') {
-        zero = 1;
+        zero = false;
         ++cur;
     }
 
@@ -403,7 +403,7 @@ Format::Token::parse(const char *def, Quoting *quoting)
     }
 
     if (*cur == ' ') {
-        space = 1;
+        space = true;
         ++cur;
     }
 
index 07eb4e32a69ef9c40dd592dcf89830f57a378b53..7579191f5a50c11692d8721ecde17f3f00af495c 100644 (file)
@@ -32,9 +32,9 @@ public:
             widthMin(-1),
             widthMax(-1),
             quote(LOG_QUOTE_NONE),
-            left(0),
-            space(0),
-            zero(0),
+            left(false),
+            space(false),
+            zero(false),
             divisor(0),
             next(NULL)
     { data.string = NULL; }
@@ -65,9 +65,9 @@ public:
     int widthMin; ///< minimum field width
     int widthMax; ///< maximum field width
     enum Quoting quote;
-    unsigned int left:1;
-    unsigned int space:1;
-    unsigned int zero:1;
+    bool left;
+    bool space;
+    bool zero;
     int divisor;
     Token *next;       /* todo: move from linked list to array */
 
index 3d0b1aa657d6e4c292cda562f0c0106f32a7b96f..acdb6dbf0b75b2c4424cb89de99d43b97ab9024e 100644 (file)
@@ -36,8 +36,9 @@ public:
     char buffer[COSS_MEMBUF_SZ];
 
     struct _cossmembuf_flags {
-        unsigned int full:1;
-        unsigned int writing:1;
+        _cossmembuf_flags() : full(false), writing(false) {}
+        bool full;
+        bool writing;
     } flags;
 };
 
@@ -68,9 +69,9 @@ public:
     size_t requestoffset;      /* in blocks */
     int64_t reqdiskoffset;     /* in blocks */
 
-    struct {
-        unsigned int reading:1;
-        unsigned int writing:1;
+    struct CossFlags {
+        bool reading;
+        bool writing;
     } flags;
 
     CossMemBuf *locked_membuf;
index 6dfd98e0af56dae3e5632290497b604b7748946b..72a592ced36f2a827fd89d5c9f94bca0929d436d 100644 (file)
@@ -176,7 +176,7 @@ CossSwapDir::readCompleted(const char *buf, int len, int errflag, RefCount<ReadR
     ssize_t rlen;
 
     debugs(79, 3, "storeCossReadDone: fileno " << sio->swap_filen << ", len " << len);
-    cstate->flags.reading = 0;
+    cstate->flags.reading = false;
 
     if (errflag) {
         ++ StoreFScoss::GetInstance().stats.read.fail;
index 8aac78ee1295d8269c76219e258cec3e2cd15736..91356658032068a33587fc94a00ec82f8a3fe0cf 100644 (file)
@@ -87,7 +87,7 @@ CossSwapDir::allocate(const StoreEntry * e, int which)
          * back to the beginning
          */
         ++ StoreFScoss::GetInstance().stats.disk_overflows;
-        current_membuf->flags.full = 1;
+        current_membuf->flags.full = true;
         current_membuf->diskend = current_offset;
         current_membuf->maybeWrite(this);
         current_offset = 0;    /* wrap back to beginning */
@@ -102,7 +102,7 @@ CossSwapDir::allocate(const StoreEntry * e, int which)
          * Skip the blank space at the end of the stripe. start over.
          */
         ++ StoreFScoss::GetInstance().stats.stripe_overflows;
-        current_membuf->flags.full = 1;
+        current_membuf->flags.full = true;
         current_offset = current_membuf->diskend;
         current_membuf->maybeWrite(this);
         debugs(79, 2, "CossSwapDir::allocate: New offset - " << current_offset);
@@ -183,8 +183,8 @@ CossSwapDir::createStoreIO(StoreEntry &e, StoreIOState::STFNCB * file_callback,
     sio->callback_data = cbdataReference(callback_data);
     sio->e = &e;
 
-    cstate->flags.writing = 0;
-    cstate->flags.reading = 0;
+    cstate->flags.writing = false;
+    cstate->flags.reading = false;
     cstate->readbuffer = NULL;
     cstate->reqdiskoffset = -1;
 
@@ -220,8 +220,8 @@ CossSwapDir::openStoreIO(StoreEntry & e, StoreIOState::STFNCB * file_callback,
     cstate->st_size = e.swap_file_sz;
     sio->e = &e;
 
-    cstate->flags.writing = 0;
-    cstate->flags.reading = 0;
+    cstate->flags.writing = false;
+    cstate->flags.reading = false;
     cstate->readbuffer = NULL;
     cstate->reqdiskoffset = -1;
     p = storeCossMemPointerFromDiskOffset(storeCossFilenoToDiskOffset(f), NULL);
@@ -308,7 +308,7 @@ CossState::read_(char *buf, size_t size, off_t offset, STRCB * callback, void *c
     read.callback_data = cbdataReference(callback_data);
     debugs(79, 3, "storeCossRead: offset " << offset);
     offset_ = offset;
-    flags.reading = 1;
+    flags.reading = true;
 
     if ((offset + (off_t)size) > st_size)
         size = st_size - offset;
@@ -542,7 +542,7 @@ CossMemBuf::write(CossSwapDir * SD)
 {
     ++ StoreFScoss::GetInstance().stats.stripe_write.ops;
     debugs(79, 3, "CossMemBuf::write: offset " << diskstart << ", len " << (diskend - diskstart));
-    flags.writing = 1;
+    flags.writing = true;
     /* XXX Remember that diskstart/diskend are block offsets! */
     SD->theFile->write(new CossWrite(WriteRequest((char const *)&buffer, diskstart, diskend - diskstart, NULL), this));
 }
@@ -562,8 +562,6 @@ CossSwapDir::createMemBuf(off_t start, sfileno curfn, int *collision)
     debugs(79, 3, "CossSwapDir::createMemBuf: creating new membuf at " << newmb->diskstart);
     debugs(79, 3, "CossSwapDir::createMemBuf: at " << newmb);
     newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ;
-    newmb->flags.full = 0;
-    newmb->flags.writing = 0;
     newmb->lockcount = 0;
     newmb->SD = this;
     /* XXX This should be reversed, with the new buffer last in the chain */
index eeb3d086e4abe7c4818ce32a2d0ca6f5b5a39046..b3c2d0d090f16ba94faebe068f2f8671ccf8a573 100644 (file)
@@ -63,7 +63,7 @@ Fs::Ufs::RebuildState::RebuildState(RefCount<UFSSwapDir> aSwapDir) :
      * use commonUfsDirRebuildFromDirectory() to open up each file
      * and suck in the meta data.
      */
-    int clean = 0;
+    int clean = 0; //TODO: change to bool
     int zeroLengthLog = 0;
     FILE *fp = sd->openTmpSwapLog(&clean, &zeroLengthLog);
 
@@ -78,11 +78,11 @@ Fs::Ufs::RebuildState::RebuildState(RefCount<UFSSwapDir> aSwapDir) :
 
     } else {
         fromLog = true;
-        flags.clean = (unsigned int) clean;
+        flags.clean = (clean != 0);
     }
 
     if (!clean)
-        flags.need_to_validate = 1;
+        flags.need_to_validate = true;
 
     debugs(47, DBG_IMPORTANT, "Rebuilding storage in " << sd->path << " (" <<
            (clean ? "clean log" : (LogParser ? "dirty log" : "no log")) << ")");
@@ -444,12 +444,12 @@ Fs::Ufs::RebuildState::getNextFile(sfileno * filn_p, int *size)
     while (fd < 0 && done == 0) {
         fd = -1;
 
-        if (0 == flags.init) {  /* initialize, open first file */
+        if (!flags.init) {  /* initialize, open first file */
             done = 0;
             curlvl1 = 0;
             curlvl2 = 0;
             in_dir = 0;
-            flags.init = 1;
+            flags.init = true;
             assert(Config.cacheSwap.n_configured > 0);
         }
 
index 552da45d31468aaeb9650eaab0e8fc8bd3ef667c..6a89e055d41fefb743533ff433ea40a24a21a165 100644 (file)
@@ -62,10 +62,11 @@ public:
     int curlvl1;
     int curlvl2;
 
-    struct {
-        unsigned int need_to_validate:1;
-        unsigned int clean:1;
-        unsigned int init:1;
+    struct Flags {
+        Flags() : need_to_validate(false), clean(false), init(false) {}
+        bool need_to_validate;
+        bool clean;
+        bool init;
     } flags;
     int in_dir;
     int done;
index be1337e0972cc6361f3c0dbeaf6017ea4b9574ab..73da88265782f41d0a18c13b48b2a29ffe9934e7 100644 (file)
@@ -262,7 +262,7 @@ storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
 
     for (i = 0; i < Config.cacheSwap.n_configured; ++i) {
         SD = dynamic_cast<SwapDir *>(INDEXSD(i));
-        SD->flags.selected = 0;
+        SD->flags.selected = false;
 
         if (!SD->canStore(*e, objsize, load))
             continue;
@@ -295,7 +295,7 @@ storeDirSelectSwapDirLeastLoad(const StoreEntry * e)
     }
 
     if (dirn >= 0)
-        dynamic_cast<SwapDir *>(INDEXSD(dirn))->flags.selected = 1;
+        dynamic_cast<SwapDir *>(INDEXSD(dirn))->flags.selected = true;
 
     return dirn;
 }