From 7299ee19dd3a9aed15bcaf4905ae312290f250d0 Mon Sep 17 00:00:00 2001 From: Florin Iucha Date: Fri, 29 Nov 2019 20:57:14 -0500 Subject: [PATCH] Clean-up sign-conversion warnings (1 of n) --- include/fmt/chrono.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 9abe7c4f..ee4801b5 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -696,7 +696,7 @@ inline int to_nonnegative_int(T value, int upper) { template ::value)> inline T mod(T x, int y) { - return x % y; + return x % static_cast(y); } template ::value)> inline T mod(T x, int y) { @@ -793,11 +793,7 @@ struct chrono_formatter { explicit chrono_formatter(FormatContext& ctx, OutputIt o, std::chrono::duration d) - : context(ctx), out(o), val(d.count()), negative(false) { - if (d.count() < 0) { - val = 0 - val; - negative = true; - } + : context(ctx), out(o), val(static_cast(std::abs(d.count()))), negative(d.count() < 0) { // this may overflow and/or the result may not fit in the // target type. @@ -1023,8 +1019,8 @@ struct formatter, Char> { void on_error(const char* msg) { FMT_THROW(format_error(msg)); } void on_fill(Char fill) { f.specs.fill[0] = fill; } void on_align(align_t align) { f.specs.align = align; } - void on_width(unsigned width) { f.specs.width = width; } - void on_precision(unsigned _precision) { f.precision = _precision; } + void on_width(int width) { f.specs.width = width; } + void on_precision(int _precision) { f.precision = _precision; } void end_precision() {} template void on_dynamic_width(Id arg_id) {