From 82acd483ae0ed9db509bbc97f44c0521b9d66a2e Mon Sep 17 00:00:00 2001 From: vitaut Date: Fri, 30 Oct 2015 07:54:55 -0700 Subject: [PATCH] Fix warnings (#216) --- format.cc | 2 +- format.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/format.cc b/format.cc index a9577028..5f696799 100644 --- a/format.cc +++ b/format.cc @@ -444,7 +444,7 @@ class BasicArgFormatter : public ArgVisitor { typedef typename BasicWriter::CharPtr CharPtr; Char fill = internal::CharTraits::cast(spec_.fill()); CharPtr out = CharPtr(); - const int CHAR_WIDTH = 1; + const unsigned CHAR_WIDTH = 1; if (spec_.width_ > CHAR_WIDTH) { out = writer_.grow_buffer(spec_.width_); if (spec_.align_ == ALIGN_RIGHT) { diff --git a/format.h b/format.h index 68c7e51b..29a7f0f2 100644 --- a/format.h +++ b/format.h @@ -292,7 +292,9 @@ class BasicStringRef { int compare(BasicStringRef other) const { std::size_t size = std::min(size_, other.size_); int result = std::char_traits::compare(data_, other.data_, size); - return result != 0 ? result : size_ - other.size_; + if (result == 0) + result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1); + return result; } friend bool operator==(BasicStringRef lhs, BasicStringRef rhs) {