From f6ac240cd290ca0fb8f4205b6af55ecc59abbb7a Mon Sep 17 00:00:00 2001 From: Brian Wolfe Date: Mon, 15 Jun 2020 14:02:15 -0700 Subject: [PATCH] timers: silence format overflow warning --- src/timers.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/timers.cc b/src/timers.cc index 221b594a..2501bab9 100644 --- a/src/timers.cc +++ b/src/timers.cc @@ -212,8 +212,10 @@ std::string LocalDateTimeString() { offset_minutes *= -1; tz_offset_sign = '-'; } + + // Apply % 100 to hour to guarantee range [0, 99]. tz_len = ::sprintf(tz_offset, "%c%02li:%02li", tz_offset_sign, - offset_minutes / 100, offset_minutes % 100); + (offset_minutes / 100) % 100, offset_minutes % 100); CHECK(tz_len == 6); ((void)tz_len); // Prevent unused variable warning in optimized build. } else {