Skip to contentSkip to conversation

Small fio cleanups and fixes

PATCH Superseded Ammar Faizi 2 participants 5 messages Apr 28, 2022 – Apr 29, 2022 Kbuild

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index 317e4f6c..071fd1d1 100644
@@ -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
#2 lore raw

PATCH v3 2/3 json: Change `if (!strlen(str))` to `if (!str[0])`

In reply to Ammar Faizi

From: 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
index cd3d5d74..8b650721 100644
@@ -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
#3 lore raw

PATCH v3 3/3 Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy`

In reply to Ammar Faizi

From: 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
index e670c1f2..1e15a69e 100644
@@ -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
Reviewed-by on the v3 series
#4 lore raw
In reply to 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-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

Quoted 10 lines
 Makefile  | 6 +++++-
 backend.c | 2 +-
 json.c    | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

base-commit: 5f2d43188c2d65674aaba6280e2a87107e5d7099

Signature · 1 line
Ammar Faizi

For the series: