Cleanups and Fixes
v4 cover Cleanups and Fixes
Hi Jens,
This is the v4 series of small fio cleanups and fixes. I dropped the patches about ENOMEM handling this time. The most noticable change is patch #3 (fix clang warning). The rest is just small optimization and indentation clean up.
v4:
- Append Reviewed-by tags from Niklas Cassel.
- Rebase the series.
Link v3: https://lore.kernel.org/fio/[email protected]/
---
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: d338e8760f3f442b3e4498598854130e55745eb9
Signature · 1 line
Ammar Faizi
PATCH v4 1/3 backend: Fix indentation
--- 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 v4 2/3 json: Change `if (!strlen(str))` to `if (!str[0])`
In reply to Ammar FaiziNo 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
Re: [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])`
Quoted 14 lines · Ammar Faizi
No need to traverse the whole string. Using
!strlen(str)as a *conditional expression* is effectively the same with!str[0].Reviewed-by Niklas Cassel <[email protected]>Signed-off-by Ammar Faizi <[email protected]>--- json.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)json.c +0
-0
json.c static char *strdup_escape(const char *str) · line 60
Quoted 6 lines
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 ;
This seems like a useless optimization, strlen() should already be doing this.
Signature · 1 line
Jens Axboe
PATCH v4 3/3 Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy`
In reply to Ammar Faizilex.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
@@ -535,8 +535,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
Jens Axboe
AppliedRe: (subset) [PATCH v4 0/3] Cleanups and Fixes
In reply to Ammar FaiziQuoted 10 lines · Ammar Faizi
This is the v4 series of small fio cleanups and fixes. I dropped the patches about ENOMEM handling this time. The most noticable change is patch #3 (fix clang warning). The rest is just small optimization and indentation clean up.
v4:
- Append Reviewed-by tags from Niklas Cassel.
- Rebase the series.[...]
Applied, thanks!
[1/3] backend: Fix indentation
commit: 74ee19043ebb12dd6b0aa243f8cdb7ccd63af857
[3/3] Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy`
commit: 6f1a24593c227a4f392f454698aca20e95f0006cBest regards,
Signature · 1 line
Jens Axboe