Message ID | 20240221092728.1281499-5-davidgow@google.com (mailing list archive) |
---|---|
State | Mainlined |
Commit | 133e267ef4a26d19c93996a874714e9f3f8c70aa |
Headers | show |
Series | kunit: Fix printf format specifier issues in KUnit assertions | expand |
On Wed, Feb 21, 2024 at 05:27:17PM +0800, David Gow wrote: > 'days' is a s64 (from div_s64), and so should use a %lld specifier. > > This was found by extending KUnit's assertion macros to use gcc's > __printf attribute. > > Fixes: 276010551664 ("time: Improve performance of time64_to_tm()") > Signed-off-by: David Gow <davidgow@google.com> Tested-by: Guenter Roeck <linux@roeck-us.net> > --- > kernel/time/time_test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/time_test.c b/kernel/time/time_test.c > index ca058c8af6ba..3e5d422dd15c 100644 > --- a/kernel/time/time_test.c > +++ b/kernel/time/time_test.c > @@ -73,7 +73,7 @@ static void time64_to_tm_test_date_range(struct kunit *test) > > days = div_s64(secs, 86400); > > - #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %ld", \ > + #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %lld", \ > year, month, mdday, yday, days > > KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG); > -- > 2.44.0.rc0.258.g7320e95886-goog >
Hi, On Wed, Feb 21, 2024 at 05:27:17PM +0800, David Gow wrote: > 'days' is a s64 (from div_s64), and so should use a %lld specifier. > > This was found by extending KUnit's assertion macros to use gcc's > __printf attribute. > > Fixes: 276010551664 ("time: Improve performance of time64_to_tm()") > Signed-off-by: David Gow <davidgow@google.com> Reviewed-by: Justin Stitt <justinstitt@google.com> > --- > kernel/time/time_test.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/time/time_test.c b/kernel/time/time_test.c > index ca058c8af6ba..3e5d422dd15c 100644 > --- a/kernel/time/time_test.c > +++ b/kernel/time/time_test.c > @@ -73,7 +73,7 @@ static void time64_to_tm_test_date_range(struct kunit *test) > > days = div_s64(secs, 86400); > > - #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %ld", \ > + #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %lld", \ > year, month, mdday, yday, days > > KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG); > -- > 2.44.0.rc0.258.g7320e95886-goog > Thanks Justin
diff --git a/kernel/time/time_test.c b/kernel/time/time_test.c index ca058c8af6ba..3e5d422dd15c 100644 --- a/kernel/time/time_test.c +++ b/kernel/time/time_test.c @@ -73,7 +73,7 @@ static void time64_to_tm_test_date_range(struct kunit *test) days = div_s64(secs, 86400); - #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %ld", \ + #define FAIL_MSG "%05ld/%02d/%02d (%2d) : %lld", \ year, month, mdday, yday, days KUNIT_ASSERT_EQ_MSG(test, year - 1900, result.tm_year, FAIL_MSG);
'days' is a s64 (from div_s64), and so should use a %lld specifier. This was found by extending KUnit's assertion macros to use gcc's __printf attribute. Fixes: 276010551664 ("time: Improve performance of time64_to_tm()") Signed-off-by: David Gow <davidgow@google.com> --- kernel/time/time_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)