Small fio cleanups and fixes
v3 cover Small fio cleanups and fixes
From: Ammar Faizi <[email protected]>
Hi Jens,
This is the v3 series of small fio cleanups and fixes. I dropped the patches about ENOMEM handling this time. I will resend those in a different series later because I think we have many places to fix them, so I will dedicate more time to it.
There are 3 patches in this series:
1. Trivial indentation fix.
2. Small optimization for the JSON code.
3. Fix -Wimplicit-fallthrough warning when compiling with clang-15.
Please review, thanks!
---
Ammar Faizi (3):
backend: Fix indentation
json: Change if (!strlen(str)) to if (!str[0])
Makefile: Suppress -Wimplicit-fallthrough when compiling lex.yy
Makefile | 6 +++++- backend.c | 2 +- json.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
base-commit: 5f2d43188c2d65674aaba6280e2a87107e5d7099
Signature · 1 line
Ammar Faizi
PATCH v3 1/3 backend: Fix indentation
From: Ammar Faizi <[email protected]>
--- backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
backend.c +1 -1
@@ -2021,7 +2021,7 @@ static void reap_threads(unsigned int *nr_running, uint64_t *t_rate,for_each_td (td, i) {int flags =0 ; -if (!strcmp (td->o.ioengine,"cpuio" )) +if (!strcmp (td->o.ioengine,"cpuio" )) cputhreads++;else realthreads++;
Signature · 1 line
Ammar Faizi
PATCH v3 2/3 json: Change `if (!strlen(str))` to `if (!str[0])`
In reply to Ammar FaiziFrom: Ammar Faizi <[email protected]>
No need to traverse the whole string. Using !strlen(str) as a *conditional expression* is effectively the same with !str[0].
--- json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
json.c +1 -1
@@ -56,7 +56,7 @@ static char *strdup_escape(const char *str)char *p, *ret;int escapes; -if (!strlen (str)) +if (!str[0 ])return NULL ; escapes =0 ;
Signature · 1 line
Ammar Faizi
PATCH v3 3/3 Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy`
In reply to Ammar FaiziFrom: Ammar Faizi <[email protected]>
lex.yy.c is an auto generated C file. When compiling with clang-15, we got the following warning:
```
CC lex.yy.o
lex.yy.c:1444:5: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
case EOB_ACT_END_OF_FILE:
^
lex.yy.c:1444:5: note: insert '__attribute__((fallthrough));' to silence this warning
case EOB_ACT_END_OF_FILE:
^
__attribute__((fallthrough));
lex.yy.c:1444:5: note: insert 'break;' to avoid fall-through
case EOB_ACT_END_OF_FILE:
^
break;
1 warning generated.
```There is nothing we can do to fix lex.yy.c since it's an auto generated file. Fix this by appending -Wno-implicit-fallthrough when compiling this file if we have -Wimplicit-fallthrough flag enabled.
--- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
@@ -530,8 +530,12 @@ else $(QUIET_LEX)$(LEX) $< endif +ifneq (,$(findstring -Wimplicit-fallthrough,$(CFLAGS))) +LEX_YY_CFLAGS := -Wno-implicit-fallthrough +endif + lex.yy.o: lex.yy.c y.tab.h - $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< + $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LEX_YY_CFLAGS) -c $< y.tab.o: y.tab.c y.tab.h $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
Signature · 1 line
Ammar Faizi
Quoted 25 lines · Ammar Faizi
From: Ammar Faizi <[email protected]>
Hi Jens,
This is the v3 series of small fio cleanups and fixes. I dropped the patches about ENOMEM handling this time. I will resend those in a different series later because I think we have many places to fix them, so I will dedicate more time to it.
There are 3 patches in this series:
1. Trivial indentation fix.
2. Small optimization for the JSON code.
3. Fix-Wimplicit-fallthroughwarning when compiling with clang-15.Please review, thanks!
Signed-off-by Ammar Faizi <[email protected]>---
Ammar Faizi (3):
backend: Fix indentation
json: Changeif (!strlen(str))toif (!str[0])
Makefile: Suppress-Wimplicit-fallthroughwhen compilinglex.yy
Quoted 10 lines
Makefile | 6 +++++- backend.c | 2 +- json.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)base-commit:
5f2d43188c2d65674aaba6280e2a87107e5d7099Signature · 1 line
Ammar Faizi
For the series: