Fix some warnings against size_t to int conversion

This commit is contained in:
Stanislav Ershov 2018-03-12 13:51:47 +03:00 committed by Alex
parent bf0dc8e64e
commit ceb9828910
4 changed files with 12 additions and 12 deletions

View File

@ -415,29 +415,29 @@ private:
class Subscriber { class Subscriber {
protected: protected:
template <typename EventType, typename Handler, typename Lambda> template <typename EventType, typename Handler, typename Lambda>
int subscribe(base::Observable<EventType, Handler> &observable, Lambda &&handler) { size_t subscribe(base::Observable<EventType, Handler> &observable, Lambda &&handler) {
_subscriptions.push_back(observable.add_subscription(std::forward<Lambda>(handler))); _subscriptions.push_back(observable.add_subscription(std::forward<Lambda>(handler)));
return _subscriptions.size(); return _subscriptions.size();
} }
template <typename EventType, typename Handler, typename Lambda> template <typename EventType, typename Handler, typename Lambda>
int subscribe(base::Observable<EventType, Handler> *observable, Lambda &&handler) { size_t subscribe(base::Observable<EventType, Handler> *observable, Lambda &&handler) {
return subscribe(*observable, std::forward<Lambda>(handler)); return subscribe(*observable, std::forward<Lambda>(handler));
} }
template <typename Type, typename Lambda> template <typename Type, typename Lambda>
int subscribe(const base::Variable<Type> &variable, Lambda &&handler) { size_t subscribe(const base::Variable<Type> &variable, Lambda &&handler) {
return subscribe(variable.changed(), std::forward<Lambda>(handler)); return subscribe(variable.changed(), std::forward<Lambda>(handler));
} }
template <typename Type, typename Lambda> template <typename Type, typename Lambda>
int subscribe(const base::Variable<Type> *variable, Lambda &&handler) { size_t subscribe(const base::Variable<Type> *variable, Lambda &&handler) {
return subscribe(variable->changed(), std::forward<Lambda>(handler)); return subscribe(variable->changed(), std::forward<Lambda>(handler));
} }
void unsubscribe(int index) { void unsubscribe(size_t index) {
if (!index) return; if (!index) return;
auto count = static_cast<int>(_subscriptions.size()); auto count = _subscriptions.size();
Assert(index > 0 && index <= count); Assert(index > 0 && index <= count);
_subscriptions[index - 1].destroy(); _subscriptions[index - 1].destroy();
if (index == count) { if (index == count) {

View File

@ -241,10 +241,10 @@ private:
return &ZeroRuntimeComposerMetadata; return &ZeroRuntimeComposerMetadata;
} }
void *_dataptrunsafe(int skip) const { void *_dataptrunsafe(size_t skip) const {
return (char*)_data + skip; return (char*)_data + skip;
} }
void *_dataptr(int skip) const { void *_dataptr(size_t skip) const {
return (skip >= sizeof(_meta())) ? _dataptrunsafe(skip) : nullptr; return (skip >= sizeof(_meta())) ? _dataptrunsafe(skip) : nullptr;
} }
const RuntimeComposerMetadata *&_meta() const { const RuntimeComposerMetadata *&_meta() const {

View File

@ -339,8 +339,8 @@ std::vector<One> Items;\n\
source_->popNamespace().newline().pushNamespace("internal"); source_->popNamespace().newline().pushNamespace("internal");
source_->stream() << "\ source_->stream() << "\
\n\ \n\
EmojiPtr ByIndex(int index) {\n\ EmojiPtr ByIndex(size_t index) {\n\
return (index >= 0 && index < Items.size()) ? &Items[index] : nullptr;\n\ return index < Items.size() ? &Items[index] : nullptr;\n\
}\n\ }\n\
\n\ \n\
EmojiPtr FindReplace(const QChar *start, const QChar *end, int *outLength) {\n\ EmojiPtr FindReplace(const QChar *start, const QChar *end, int *outLength) {\n\
@ -384,7 +384,7 @@ bool Generator::writeHeader() {
\n\ \n\
void Init();\n\ void Init();\n\
\n\ \n\
EmojiPtr ByIndex(int index);\n\ EmojiPtr ByIndex(size_t index);\n\
\n\ \n\
EmojiPtr Find(const QChar *ch, const QChar *end, int *outLength = nullptr);\n\ EmojiPtr Find(const QChar *ch, const QChar *end, int *outLength = nullptr);\n\
\n\ \n\

View File

@ -66,7 +66,7 @@ public:
} }
void write(QDataStream &to) const { void write(QDataStream &to) const {
to.writeRawData(reinterpret_cast<const char*>(_key.data()), _key.size()); to.writeRawData(reinterpret_cast<const char*>(_key.data()), static_cast<int>(_key.size()));
} }
bool equals(const std::shared_ptr<AuthKey> &other) const { bool equals(const std::shared_ptr<AuthKey> &other) const {