Skip to contentSkip to conversation

fio: simplify parse_is_percent()

PATCH In review Alexey Dobriyan 2 participants 3 messages Feb 14, 2021 – Feb 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fio: simplify parse_is_percent()

Check like this

unsigned long long val <= -1ULL

is tautologically true because of how type conversions work.

---

 parse.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
parse.h +1 -1
@@ -131,7 +131,7 @@ static inline void *td_var(void *to, const struct fio_option *o,
 
 static inline int parse_is_percent(unsigned long long val)
 {
-	return val <= -1ULL && val >= (-1ULL - 100ULL);
+	return val >= -101;
 }
 
 #define ZONE_BASE_VAL ((-1ULL >> 1) + 1)
#1 lore raw
Quoted 6 lines

-----Original Message-----
From: Alexey Dobriyan <[email protected]>
Sent: Sunday, February 14, 2021 2:15 PM
To: [email protected]
Cc: [email protected]
Subject: [PATCH] fio: simplify parse_is_percent()

fio: -> parse:?

Quoted 16 lines

Check like this

unsigned long long val <= -1ULL

is tautologically true because of how type conversions work.

---

 parse.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

parse.h static inline void *td_var(void *to, const struct · line 135

Quoted 6 lines
parse.h +1 -1
@@ -131,7 +131,7 @@ static inline void *td_var(void *to, const struct
 fio_option *o,
 
 static inline int parse_is_percent(unsigned long long val)
 {
-	return val <= -1ULL && val >= (-1ULL - 100ULL);
+	return val >= -101;

Nice cleanup, but wouldn't that be better to keep the ULL suffix for the sake of clarity?

Quoted 3 lines
parse.h +0 -0
 }
 

#define ZONE_BASE_VAL ((-1ULL >> 1) + 1)

This patch is based on your earlier patch
"zbd: support 'z' suffix for zone granularity" that is still in review, why not to combine these two in a series?

#2 lore raw
Quoted 27 lines · Dmitry Fomichev
Quoted 6 lines

-----Original Message-----
From: Alexey Dobriyan <[email protected]>
Sent: Sunday, February 14, 2021 2:15 PM
To: [email protected]
Cc: [email protected]
Subject: [PATCH] fio: simplify parse_is_percent()

fio: -> parse:?

Quoted 18 lines

Check like this

unsigned long long val <= -1ULL

is tautologically true because of how type conversions work.

---

 parse.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
parse.h +0 -0
@@ -131,7 +131,7 @@ static inline void *td_var(void *to, const struct
 fio_option *o,
 
Quoted 7 lines

parse.h static inline void *td_var(void *to, const struct fio_option *o, · line 134

Quoted 4 lines
parse.h +1 -1
 static inline int parse_is_percent(unsigned long long val)
 {
-	return val <= -1ULL && val >= (-1ULL - 100ULL);
+	return val >= -101;

Nice cleanup, but wouldn't that be better to keep the ULL suffix for the sake of clarity?

ULL is unnecessary here. fio has lots of unnecessary ULLs :-\

Quoted 7 lines
Quoted 3 lines
parse.h +0 -0
 }
 

#define ZONE_BASE_VAL ((-1ULL >> 1) + 1)

This patch is based on your earlier patch
"zbd: support 'z' suffix for zone granularity" that is still in review, why not to combine these two in a series?

Yes, this one should go first.