public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v4 0/3] Cleanups and Fixes
@ 2022-05-12 16:43 Ammar Faizi
  2022-05-12 16:43 ` [PATCH v4 1/3] backend: Fix indentation Ammar Faizi
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Ammar Faizi @ 2022-05-12 16:43 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Niklas Cassel, fio Mailing List, GNU/Weeb Mailing List,
	Ammar Faizi

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]/

Reviewed-by: Niklas Cassel <[email protected]>
Signed-off-by: Ammar Faizi <[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
-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 1/3] backend: Fix indentation
  2022-05-12 16:43 [PATCH v4 0/3] Cleanups and Fixes Ammar Faizi
@ 2022-05-12 16:43 ` Ammar Faizi
  2022-05-12 16:43 ` [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])` Ammar Faizi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Ammar Faizi @ 2022-05-12 16:43 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Niklas Cassel, fio Mailing List, GNU/Weeb Mailing List,
	Ammar Faizi

Reviewed-by: Niklas Cassel <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backend.c b/backend.c
index ffbb7e2a..e5bb4e25 100644
--- a/backend.c
+++ b/backend.c
@@ -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++;
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])`
  2022-05-12 16:43 [PATCH v4 0/3] Cleanups and Fixes Ammar Faizi
  2022-05-12 16:43 ` [PATCH v4 1/3] backend: Fix indentation Ammar Faizi
@ 2022-05-12 16:43 ` Ammar Faizi
  2022-05-12 16:54   ` Jens Axboe
  2022-05-12 16:43 ` [PATCH v4 3/3] Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy` Ammar Faizi
  2022-05-12 17:03 ` (subset) [PATCH v4 0/3] Cleanups and Fixes Jens Axboe
  3 siblings, 1 reply; 6+ messages in thread
From: Ammar Faizi @ 2022-05-12 16:43 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Niklas Cassel, fio Mailing List, GNU/Weeb Mailing List,
	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(-)

diff --git a/json.c b/json.c
index cd3d5d74..8b650721 100644
--- a/json.c
+++ b/json.c
@@ -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;
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v4 3/3] Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy`
  2022-05-12 16:43 [PATCH v4 0/3] Cleanups and Fixes Ammar Faizi
  2022-05-12 16:43 ` [PATCH v4 1/3] backend: Fix indentation Ammar Faizi
  2022-05-12 16:43 ` [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])` Ammar Faizi
@ 2022-05-12 16:43 ` Ammar Faizi
  2022-05-12 17:03 ` (subset) [PATCH v4 0/3] Cleanups and Fixes Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Ammar Faizi @ 2022-05-12 16:43 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Niklas Cassel, fio Mailing List, GNU/Weeb Mailing List,
	Ammar Faizi

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.

Reviewed-by: Niklas Cassel <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8495e727..ed66305a 100644
--- a/Makefile
+++ b/Makefile
@@ -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 $<
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])`
  2022-05-12 16:43 ` [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])` Ammar Faizi
@ 2022-05-12 16:54   ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-05-12 16:54 UTC (permalink / raw)
  To: Ammar Faizi; +Cc: Niklas Cassel, fio Mailing List, GNU/Weeb Mailing List

On 5/12/22 10:43, Ammar Faizi wrote:
> 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(-)
> 
> diff --git a/json.c b/json.c
> index cd3d5d74..8b650721 100644
> --- a/json.c
> +++ b/json.c
> @@ -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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (subset) [PATCH v4 0/3] Cleanups and Fixes
  2022-05-12 16:43 [PATCH v4 0/3] Cleanups and Fixes Ammar Faizi
                   ` (2 preceding siblings ...)
  2022-05-12 16:43 ` [PATCH v4 3/3] Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy` Ammar Faizi
@ 2022-05-12 17:03 ` Jens Axboe
  3 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-05-12 17:03 UTC (permalink / raw)
  To: ammarfaizi2; +Cc: fio, niklas.cassel, gwml

On Thu, 12 May 2022 23:43:30 +0700, Ammar Faizi wrote:
> 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: 6f1a24593c227a4f392f454698aca20e95f0006c

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-12 17:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-12 16:43 [PATCH v4 0/3] Cleanups and Fixes Ammar Faizi
2022-05-12 16:43 ` [PATCH v4 1/3] backend: Fix indentation Ammar Faizi
2022-05-12 16:43 ` [PATCH v4 2/3] json: Change `if (!strlen(str))` to `if (!str[0])` Ammar Faizi
2022-05-12 16:54   ` Jens Axboe
2022-05-12 16:43 ` [PATCH v4 3/3] Makefile: Suppress `-Wimplicit-fallthrough` when compiling `lex.yy` Ammar Faizi
2022-05-12 17:03 ` (subset) [PATCH v4 0/3] Cleanups and Fixes Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox