Skip to contentSkip to conversation

Fix testing and setting set_options bitmap

PATCH Applied Akinobu Mita 2 participants 2 messages Jun 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix testing and setting set_options bitmap

set_options bitmap is an array of uint64_t. But while testing and setting a bit in the bitmap, the bit mask is calculated with an unsigned long value. For the systems which have 32-bit long type, upper 32-bit cannot be set correctly.

Fix it by using (uint64_t)1 instead of 1UL to calculate correct bit mask.

---
 options.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
options.c +2 -2
index 76146a7..ed5d37e 100644
@@ -4365,7 +4365,7 @@ static int opt_is_set(struct thread_options *o, struct fio_option *opt)
 	opt_off = opt - &fio_options[0];
 	index = opt_off / (8 * sizeof(uint64_t));
 	offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
-	return (o->set_options[index] & (1UL << offset)) != 0;
+	return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
 }
 
 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
@@ -4390,5 +4390,5 @@ void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
 	opt_off = opt - &fio_options[0];
 	index = opt_off / (8 * sizeof(uint64_t));
 	offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
-	o->set_options[index] |= 1UL << offset;
+	o->set_options[index] |= (uint64_t)1 << offset;
 }
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 7 lines · Akinobu Mita

set_options bitmap is an array of uint64_t. But while testing and setting a bit in the bitmap, the bit mask is calculated with an unsigned long value. For the systems which have 32-bit long type, upper 32-bit cannot be set correctly.

Fix it by using (uint64_t)1 instead of 1UL to calculate correct bit mask.

Thanks, applied.

Signature · 1 line
Jens Axboe