From 49e98daa3e1d46c13b570ab3676a22ac849fc4c0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 3 Jul 2014 18:01:11 -0600 Subject: [PATCH] iolog: use a define instead of a raw bit mask Add a comment too, while in there. Signed-off-by: Jens Axboe --- iolog.c | 7 ++----- iolog.h | 6 +++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/iolog.c b/iolog.c index c3b42b3b..8bfd5bcf 100644 --- 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 d268fe2e..fcd67942 100644 --- 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, -- 2.25.1