src: fix warnings in aliased_buffer

* Unary minus usages on unsigned type
* Implicit casts to/from input parameters

PR-URL: https://github.com/nodejs/node/pull/19665
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
This commit is contained in:
Kyle Farnung
2018-03-23 17:31:04 -07:00
parent 085ad541d9
commit 0d64f33c96

View File

@@ -126,13 +126,11 @@ class AliasedBuffer {
index_(that.index_) {
}
template <typename T>
inline Reference& operator=(const T& val) {
inline Reference& operator=(const NativeT& val) {
aliased_buffer_->SetValue(index_, val);
return *this;
}
// This is not caught by the template operator= above.
inline Reference& operator=(const Reference& val) {
return *this = static_cast<NativeT>(val);
}
@@ -141,9 +139,8 @@ class AliasedBuffer {
return aliased_buffer_->GetValue(index_);
}
template <typename T>
inline Reference& operator+=(const T& val) {
const T current = aliased_buffer_->GetValue(index_);
inline Reference& operator+=(const NativeT& val) {
const NativeT current = aliased_buffer_->GetValue(index_);
aliased_buffer_->SetValue(index_, current + val);
return *this;
}
@@ -152,9 +149,10 @@ class AliasedBuffer {
return this->operator+=(static_cast<NativeT>(val));
}
template <typename T>
inline Reference& operator-=(const T& val) {
return this->operator+=(-val);
inline Reference& operator-=(const NativeT& val) {
const NativeT current = aliased_buffer_->GetValue(index_);
aliased_buffer_->SetValue(index_, current - val);
return *this;
}
private: