iolog: use a define instead of a raw bit mask
authorJens Axboe <axboe@fb.com>
Fri, 4 Jul 2014 00:01:11 +0000 (18:01 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 4 Jul 2014 00:01:11 +0000 (18:01 -0600)
Add a comment too, while in there.

Signed-off-by: Jens Axboe <axboe@fb.com>
iolog.c
iolog.h

diff --git a/iolog.c b/iolog.c
index c3b42b3be1cf02f66bcea1a798276b087ff20418..8bfd5bcf25ee5401ce7bbeaf29e1f1868cab3509 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -565,7 +565,7 @@ void setup_log(struct io_log **log, struct log_params *p,
        l->td = p->td;
 
        if (l->log_offset)
-               l->log_ddir_mask = 0x80000000;
+               l->log_ddir_mask = LOG_OFFSET_SAMPLE_BIT;
 
        INIT_FLIST_HEAD(&l->chunk_list);
 
@@ -622,10 +622,7 @@ static void flush_samples(FILE *f, void *samples, uint64_t sample_size)
                return;
 
        s = __get_sample(samples, 0, 0);
-       if (s->__ddir & 0x80000000)
-               log_offset = 1;
-       else
-               log_offset = 0;
+       log_offset = (s->__ddir & LOG_OFFSET_SAMPLE_BIT) != 0;
 
        nr_samples = sample_size / __log_entry_sz(log_offset);
 
diff --git a/iolog.h b/iolog.h
index d268fe2ee048dd22791d65b47f161b260e7a5e81..fcd6794278edd6a39e1c6fd73997370e314b120b 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -93,7 +93,11 @@ struct io_log {
        struct flist_head chunk_list;
 };
 
-#define io_sample_ddir(io)     ((io)->__ddir & ~0x80000000U)
+/*
+ * If the upper bit is set, then we have the offset as well
+ */
+#define LOG_OFFSET_SAMPLE_BIT  0x80000000U
+#define io_sample_ddir(io)     ((io)->__ddir & ~LOG_OFFSET_SAMPLE_BIT)
 
 static inline void io_sample_set_ddir(struct io_log *log,
                                      struct io_sample *io,