AddressBook: use unsigned type for row ID's

Fixes build warnings and may also prevent future headaches.
This commit is contained in:
anonimal 2016-12-14 21:37:49 +00:00
parent b97a2f72db
commit 4bb0bff233
No known key found for this signature in database
GPG key ID: 66A76ECF914409F1
5 changed files with 9 additions and 9 deletions

View file

@ -94,7 +94,7 @@ void AddressBookImpl::refresh()
} }
bool AddressBookImpl::deleteRow(int rowId) bool AddressBookImpl::deleteRow(std::size_t rowId)
{ {
LOG_PRINT_L2("Deleting address book row " << rowId); LOG_PRINT_L2("Deleting address book row " << rowId);
bool r = m_wallet->m_wallet->delete_address_book_row(rowId); bool r = m_wallet->m_wallet->delete_address_book_row(rowId);

View file

@ -46,7 +46,7 @@ public:
void refresh(); void refresh();
std::vector<AddressBookRow*> getAll() const; std::vector<AddressBookRow*> getAll() const;
bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description); bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description);
bool deleteRow(int rowId); bool deleteRow(std::size_t rowId);
// Error codes. See AddressBook:ErrorCode enum in wallet2_api.h // Error codes. See AddressBook:ErrorCode enum in wallet2_api.h
std::string errorString() const {return m_errorString;} std::string errorString() const {return m_errorString;}

View file

@ -1569,14 +1569,14 @@ bool wallet2::add_address_book_row(const cryptonote::account_public_address &add
a.m_payment_id = payment_id; a.m_payment_id = payment_id;
a.m_description = description; a.m_description = description;
int old_size = m_address_book.size(); auto old_size = m_address_book.size();
m_address_book.push_back(a); m_address_book.push_back(a);
if(m_address_book.size() == old_size+1) if(m_address_book.size() == old_size+1)
return true; return true;
return false; return false;
} }
bool wallet2::delete_address_book_row(int row_id) { bool wallet2::delete_address_book_row(std::size_t row_id) {
if(m_address_book.size() <= row_id) if(m_address_book.size() <= row_id)
return false; return false;

View file

@ -525,7 +525,7 @@ namespace tools
*/ */
std::vector<address_book_row> get_address_book() const { return m_address_book; } std::vector<address_book_row> get_address_book() const { return m_address_book; }
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description); bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description);
bool delete_address_book_row(int row_id); bool delete_address_book_row(std::size_t row_id);
uint64_t get_num_rct_outputs(); uint64_t get_num_rct_outputs();
const transfer_details &get_transfer_details(size_t idx) const; const transfer_details &get_transfer_details(size_t idx) const;

View file

@ -137,14 +137,14 @@ struct TransactionHistory
*/ */
struct AddressBookRow { struct AddressBookRow {
public: public:
AddressBookRow(int _rowId, const std::string &_address, const std::string &_paymentId, const std::string &_description): AddressBookRow(std::size_t _rowId, const std::string &_address, const std::string &_paymentId, const std::string &_description):
m_rowId(_rowId), m_rowId(_rowId),
m_address(_address), m_address(_address),
m_paymentId(_paymentId), m_paymentId(_paymentId),
m_description(_description) {} m_description(_description) {}
private: private:
int m_rowId; std::size_t m_rowId;
std::string m_address; std::string m_address;
std::string m_paymentId; std::string m_paymentId;
std::string m_description; std::string m_description;
@ -153,7 +153,7 @@ public:
std::string getAddress() const {return m_address;} std::string getAddress() const {return m_address;}
std::string getDescription() const {return m_description;} std::string getDescription() const {return m_description;}
std::string getPaymentId() const {return m_paymentId;} std::string getPaymentId() const {return m_paymentId;}
int getRowId() const {return m_rowId;} std::size_t getRowId() const {return m_rowId;}
}; };
/** /**
@ -171,7 +171,7 @@ struct AddressBook
virtual ~AddressBook() = 0; virtual ~AddressBook() = 0;
virtual std::vector<AddressBookRow*> getAll() const = 0; virtual std::vector<AddressBookRow*> getAll() const = 0;
virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0; virtual bool addRow(const std::string &dst_addr , const std::string &payment_id, const std::string &description) = 0;
virtual bool deleteRow(int rowId) = 0; virtual bool deleteRow(std::size_t rowId) = 0;
virtual void refresh() = 0; virtual void refresh() = 0;
virtual std::string errorString() const = 0; virtual std::string errorString() const = 0;
virtual int errorCode() const = 0; virtual int errorCode() const = 0;