* [e2fsprogs PATCH] libext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()
@ 2023-01-04 9:01 Eric Biggers
2023-01-04 10:43 ` Lukas Czerner
0 siblings, 1 reply; 2+ messages in thread
From: Eric Biggers @ 2023-01-04 9:01 UTC (permalink / raw
To: linux-ext4
From: Eric Biggers <ebiggers@google.com>
Since the 'now' variable is only used to calculate 'inuse', and 'inuse'
is only used when defined(ENABLE_BMAP_STATS_OPS), it makes sense to
guard the declaration and initialization of 'now' and 'inuse' by the
same condition, just like the '*_perc' variables in the same function.
This addresses the following compiler warning with clang -Wall:
gen_bitmap64.c:187:9: warning: variable 'inuse' set but not used [-Wunused-but-set-variable]
double inuse;
^
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
lib/ext2fs/gen_bitmap64.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index c860c10e..1a1eeefe 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -183,11 +183,9 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
#ifdef ENABLE_BMAP_STATS_OPS
float mark_seq_perc = 0.0, test_seq_perc = 0.0;
float mark_back_perc = 0.0, test_back_perc = 0.0;
-#endif
- double inuse;
struct timeval now;
+ double inuse;
-#ifdef ENABLE_BMAP_STATS_OPS
if (stats->test_count) {
test_seq_perc = ((float)stats->test_seq /
stats->test_count) * 100;
@@ -201,7 +199,6 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
mark_back_perc = ((float)stats->mark_back /
stats->mark_count) * 100;
}
-#endif
if (gettimeofday(&now, (struct timezone *) NULL) == -1) {
perror("gettimeofday");
@@ -212,6 +209,7 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
(((double) now.tv_usec) * 0.000001);
inuse -= (double) stats->created.tv_sec + \
(((double) stats->created.tv_usec) * 0.000001);
+#endif /* ENABLE_BMAP_STATS_OPS */
fprintf(stderr, "\n[+] %s bitmap (type %d)\n", bitmap->description,
stats->type);
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [e2fsprogs PATCH] libext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics()
2023-01-04 9:01 [e2fsprogs PATCH] libext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics() Eric Biggers
@ 2023-01-04 10:43 ` Lukas Czerner
0 siblings, 0 replies; 2+ messages in thread
From: Lukas Czerner @ 2023-01-04 10:43 UTC (permalink / raw
To: Eric Biggers; +Cc: linux-ext4
On Wed, Jan 04, 2023 at 01:01:16AM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Since the 'now' variable is only used to calculate 'inuse', and 'inuse'
> is only used when defined(ENABLE_BMAP_STATS_OPS), it makes sense to
> guard the declaration and initialization of 'now' and 'inuse' by the
> same condition, just like the '*_perc' variables in the same function.
>
> This addresses the following compiler warning with clang -Wall:
>
> gen_bitmap64.c:187:9: warning: variable 'inuse' set but not used [-Wunused-but-set-variable]
> double inuse;
> ^
Looks good, thanks!
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> lib/ext2fs/gen_bitmap64.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
> index c860c10e..1a1eeefe 100644
> --- a/lib/ext2fs/gen_bitmap64.c
> +++ b/lib/ext2fs/gen_bitmap64.c
> @@ -183,11 +183,9 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
> #ifdef ENABLE_BMAP_STATS_OPS
> float mark_seq_perc = 0.0, test_seq_perc = 0.0;
> float mark_back_perc = 0.0, test_back_perc = 0.0;
> -#endif
> - double inuse;
> struct timeval now;
> + double inuse;
>
> -#ifdef ENABLE_BMAP_STATS_OPS
> if (stats->test_count) {
> test_seq_perc = ((float)stats->test_seq /
> stats->test_count) * 100;
> @@ -201,7 +199,6 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
> mark_back_perc = ((float)stats->mark_back /
> stats->mark_count) * 100;
> }
> -#endif
>
> if (gettimeofday(&now, (struct timezone *) NULL) == -1) {
> perror("gettimeofday");
> @@ -212,6 +209,7 @@ static void ext2fs_print_bmap_statistics(ext2fs_generic_bitmap_64 bitmap)
> (((double) now.tv_usec) * 0.000001);
> inuse -= (double) stats->created.tv_sec + \
> (((double) stats->created.tv_usec) * 0.000001);
> +#endif /* ENABLE_BMAP_STATS_OPS */
>
> fprintf(stderr, "\n[+] %s bitmap (type %d)\n", bitmap->description,
> stats->type);
> --
> 2.39.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-04 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-04 9:01 [e2fsprogs PATCH] libext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics() Eric Biggers
2023-01-04 10:43 ` Lukas Czerner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).