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();
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;
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 */
}
if (*cur == '-') {
- left = 1;
+ left = true;
++cur;
}
if (*cur == '0') {
- zero = 1;
+ zero = false;
++cur;
}
}
if (*cur == ' ') {
- space = 1;
+ space = true;
++cur;
}
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; }
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 */
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;
};
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;
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;
* 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 */
* 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);
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;
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);
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;
{
++ 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));
}
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 */
* 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);
} 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")) << ")");
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);
}
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;
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;
}
if (dirn >= 0)
- dynamic_cast<SwapDir *>(INDEXSD(dirn))->flags.selected = 1;
+ dynamic_cast<SwapDir *>(INDEXSD(dirn))->flags.selected = true;
return dirn;
}