Message ID | 8417dcd7ebdc464d12850873d6c48f95293e673c.1693216959.git.maciej.wieczor-retman@intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3aa779a9d141f65adbe519653b6aee7188c49e27 |
Headers | show |
Series | Add printf attribute to kselftest functions | expand |
On Mon, Aug 28, 2023 at 6:50 AM Wieczor-Retman, Maciej <maciej.wieczor-retman@intel.com> wrote: > > The format specifier in printf() call expects long int variables and > received long long int. > > Change format specifiers to long long int so they match passed > variables. > > Signed-off-by: Wieczor-Retman, Maciej <maciej.wieczor-retman@intel.com> > --- > tools/testing/selftests/cachestat/test_cachestat.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c > index 77620e7ecf56..a7adf42afb20 100644 > --- a/tools/testing/selftests/cachestat/test_cachestat.c > +++ b/tools/testing/selftests/cachestat/test_cachestat.c > @@ -25,7 +25,7 @@ static const char * const dev_files[] = { > void print_cachestat(struct cachestat *cs) > { > ksft_print_msg( > - "Using cachestat: Cached: %lu, Dirty: %lu, Writeback: %lu, Evicted: %lu, Recently Evicted: %lu\n", > + "Using cachestat: Cached: %llu, Dirty: %llu, Writeback: %llu, Evicted: %llu, Recently Evicted: %llu\n", The fields of struct cachestat should all be unsigned longs, Is there a compiler warning that prompt this change? > cs->nr_cache, cs->nr_dirty, cs->nr_writeback, > cs->nr_evicted, cs->nr_recently_evicted); > } > -- > 2.42.0 >
On Mon, Aug 28, 2023 at 10:00 AM Nhat Pham <nphamcs@gmail.com> wrote: > > On Mon, Aug 28, 2023 at 6:50 AM Wieczor-Retman, Maciej > <maciej.wieczor-retman@intel.com> wrote: > > > > The format specifier in printf() call expects long int variables and > > received long long int. > > > > Change format specifiers to long long int so they match passed > > variables. > > > > Signed-off-by: Wieczor-Retman, Maciej <maciej.wieczor-retman@intel.com> > > --- > > tools/testing/selftests/cachestat/test_cachestat.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c > > index 77620e7ecf56..a7adf42afb20 100644 > > --- a/tools/testing/selftests/cachestat/test_cachestat.c > > +++ b/tools/testing/selftests/cachestat/test_cachestat.c > > @@ -25,7 +25,7 @@ static const char * const dev_files[] = { > > void print_cachestat(struct cachestat *cs) > > { > > ksft_print_msg( > > - "Using cachestat: Cached: %lu, Dirty: %lu, Writeback: %lu, Evicted: %lu, Recently Evicted: %lu\n", > > + "Using cachestat: Cached: %llu, Dirty: %llu, Writeback: %llu, Evicted: %llu, Recently Evicted: %llu\n", > The fields of struct cachestat should all be unsigned longs, > Is there a compiler warning that prompt this change? Ah nvm, it's _u64. %llu is probably the better format specifier indeed. Acked-by: Nhat Pham <nphamcs@gmail.com> > > cs->nr_cache, cs->nr_dirty, cs->nr_writeback, > > cs->nr_evicted, cs->nr_recently_evicted); > > } > > -- > > 2.42.0 > >
diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c index 77620e7ecf56..a7adf42afb20 100644 --- a/tools/testing/selftests/cachestat/test_cachestat.c +++ b/tools/testing/selftests/cachestat/test_cachestat.c @@ -25,7 +25,7 @@ static const char * const dev_files[] = { void print_cachestat(struct cachestat *cs) { ksft_print_msg( - "Using cachestat: Cached: %lu, Dirty: %lu, Writeback: %lu, Evicted: %lu, Recently Evicted: %lu\n", + "Using cachestat: Cached: %llu, Dirty: %llu, Writeback: %llu, Evicted: %llu, Recently Evicted: %llu\n", cs->nr_cache, cs->nr_dirty, cs->nr_writeback, cs->nr_evicted, cs->nr_recently_evicted); }
The format specifier in printf() call expects long int variables and received long long int. Change format specifiers to long long int so they match passed variables. Signed-off-by: Wieczor-Retman, Maciej <maciej.wieczor-retman@intel.com> --- tools/testing/selftests/cachestat/test_cachestat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)