From 28682c762cf7add96dfbd73cfcde67d765cd0a9b Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 6 Mar 2018 03:14:15 -0800 Subject: [PATCH] compile errors --- version2/src/C/CloudComm.cc | 7 +++---- version2/src/C/Commit.cc | 6 +++--- version2/src/C/Makefile | 2 +- version2/src/C/SecureRandom.cc | 1 + version2/src/C/SlotBuffer.cc | 14 +++++++------- version2/src/C/SlotIndexer.cc | 2 +- version2/src/C/Table.cc | 20 ++++++++++---------- version2/src/C/Transaction.cc | 8 ++++---- version2/src/C/Transaction.h | 2 +- version2/src/C/array.h | 2 +- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/version2/src/C/CloudComm.cc b/version2/src/C/CloudComm.cc index dc28355..9055d86 100644 --- a/version2/src/C/CloudComm.cc +++ b/version2/src/C/CloudComm.cc @@ -29,7 +29,6 @@ CloudComm::CloudComm() : salt(NULL), table(NULL), listeningPort(-1), - localServerThread(NULL), doEnd(false), timer(TimingSingleton_getInstance()), getslot(new Array("getslot", 7)), @@ -55,7 +54,6 @@ CloudComm::CloudComm(Table *_table, IoTString *_baseurl, IoTString *_password, salt(NULL), table(_table), listeningPort(_listeningPort), - localServerThread(NULL), doEnd(false), timer(TimingSingleton_getInstance()) { if (listeningPort > 0) { @@ -354,7 +352,8 @@ int getResponseCode(int fd) { } response[offset] = 0; int ver1 = 0, ver2 = 0, respcode = 0; - sscanf(response, "HTTP-%d.%d %d", &ver1, &ver2, &respcode); + sscanf(response, "HTTP/%d.%d %d", &ver1, &ver2, &respcode); + printf("Response code %d\n", respcode); return respcode; } @@ -723,7 +722,7 @@ void CloudComm::localServerWorkerFunction() { void CloudComm::closeCloud() { doEnd = true; - if (localServerThread != NULL) { + if (listeningPort > 0) { if (pthread_join(localServerThread, NULL) != 0) throw new Error("Local Server thread join issue..."); } diff --git a/version2/src/C/Commit.cc b/version2/src/C/Commit.cc index f159f71..cb707e2 100644 --- a/version2/src/C/Commit.cc +++ b/version2/src/C/Commit.cc @@ -115,7 +115,7 @@ void Commit::setDead() { if (!isDead) { isDead = true; // Make all the parts of this transaction dead - for (int32_t partNumber = 0; partNumber < parts->size(); partNumber++) { + for (uint32_t partNumber = 0; partNumber < parts->size(); partNumber++) { CommitPart *part = parts->get(partNumber); if (parts != NULL) part->setDead(); @@ -163,7 +163,7 @@ void Commit::createCommitParts() { void Commit::decodeCommitData() { // Calculate the size of the data section int dataSize = 0; - for (int i = 0; i < parts->size(); i++) { + for (uint i = 0; i < parts->size(); i++) { CommitPart *tp = parts->get(i); if (tp != NULL) dataSize += tp->getDataSize(); @@ -173,7 +173,7 @@ void Commit::decodeCommitData() { int currentPosition = 0; // Stitch all the data sections together - for (int i = 0; i < parts->size(); i++) { + for (uint i = 0; i < parts->size(); i++) { CommitPart *tp = parts->get(i); if (tp != NULL) { System_arraycopy(tp->getData(), 0, combinedData, currentPosition, tp->getDataSize()); diff --git a/version2/src/C/Makefile b/version2/src/C/Makefile index e450130..495cc70 100644 --- a/version2/src/C/Makefile +++ b/version2/src/C/Makefile @@ -28,7 +28,7 @@ all: directories ${OBJ_DIR}/$(LIB_SO) test directories: ${OBJ_DIR} test: bin/lib_iotcloud.so - g++ Test.C -L./bin/ -l_iotcloud -o bin/Test + g++ Test.C -L./bin/ -l_iotcloud -lpthread -lbsd -o bin/Test ${OBJ_DIR}: ${MKDIR_P} ${OBJ_DIR} diff --git a/version2/src/C/SecureRandom.cc b/version2/src/C/SecureRandom.cc index 201de08..84f40c3 100644 --- a/version2/src/C/SecureRandom.cc +++ b/version2/src/C/SecureRandom.cc @@ -1,5 +1,6 @@ #include "SecureRandom.h" #include +#include SecureRandom::SecureRandom() { } diff --git a/version2/src/C/SlotBuffer.cc b/version2/src/C/SlotBuffer.cc index 248abd7..2ce4a66 100644 --- a/version2/src/C/SlotBuffer.cc +++ b/version2/src/C/SlotBuffer.cc @@ -28,7 +28,7 @@ int SlotBuffer::capacity() { } void SlotBuffer::resize(int newsize) { - if (newsize == (array->length() - 1)) + if ((uint32_t)newsize == (array->length() - 1)) return; Array *newarray = new Array(newsize + 1); @@ -36,7 +36,7 @@ void SlotBuffer::resize(int newsize) { int index = tail; for (int i = 0; i < currsize; i++) { newarray->set(i, array->get(index)); - if ((++index) == array->length()) + if (((uint32_t)++index) == array->length()) index = 0; } array = newarray; @@ -46,13 +46,13 @@ void SlotBuffer::resize(int newsize) { void SlotBuffer::incrementHead() { head++; - if (head >= array->length()) + if (((uint32_t)head) >= array->length()) head = 0; } void SlotBuffer::incrementTail() { tail++; - if (tail >= array->length()) + if (((uint32_t)tail) >= array->length()) tail = 0; } @@ -88,14 +88,14 @@ Slot *SlotBuffer::getSlot(int64_t seqnum) { return NULL; } - if (index >= array->length()) { + if (((uint32_t)index) >= array->length()) { if (head >= tail) { return NULL; } - index -= array->length(); + index -= (int32_t) array->length(); } - if (index >= array->length()) { + if (((uint32_t)index) >= array->length()) { return NULL; } diff --git a/version2/src/C/SlotIndexer.cc b/version2/src/C/SlotIndexer.cc index c363318..b49ca45 100644 --- a/version2/src/C/SlotIndexer.cc +++ b/version2/src/C/SlotIndexer.cc @@ -18,7 +18,7 @@ SlotIndexer::SlotIndexer(Array *_updates, SlotBuffer *_buffer) : Slot *SlotIndexer::getSlot(int64_t seqnum) { if (seqnum >= firstslotseqnum) { int32_t offset = (int32_t) (seqnum - firstslotseqnum); - if (offset >= updates->length()) + if (((uint32_t)offset) >= updates->length()) throw new Error("Invalid Slot Sequence Number Reference"); else return updates->get(offset); diff --git a/version2/src/C/Table.cc b/version2/src/C/Table.cc index d70a590..dce3a8f 100644 --- a/version2/src/C/Table.cc +++ b/version2/src/C/Table.cc @@ -420,7 +420,7 @@ TransactionStatus *Table::commitTransaction() { Hashset *arbitratorTriedAndFailed = new Hashset(); uint size = pendingTransactionQueue->size(); uint oldindex = 0; - for (int iter = 0; iter < size; iter++) { + for (uint iter = 0; iter < size; iter++) { Transaction *transaction = pendingTransactionQueue->get(iter); pendingTransactionQueue->set(oldindex++, pendingTransactionQueue->get(iter)); @@ -1307,7 +1307,7 @@ void Table::doRejectedMessages(Slot *s) { s->addEntry(rm); } else { int64_t prev_seqn = -1; - int i = 0; + uint i = 0; /* Go through list of missing messages */ for (; i < rejectedSlotVector->size(); i++) { int64_t curr_seqn = rejectedSlotVector->get(i); @@ -1917,7 +1917,7 @@ bool Table::compactArbitrationData() { bool hadCommit = (lastRound->getCommit() == NULL); bool gotNewCommit = false; - int numberToDelete = 1; + uint numberToDelete = 1; while (numberToDelete < pendingSendArbitrationRounds->size()) { ArbitrationRound *round = pendingSendArbitrationRounds->get(pendingSendArbitrationRounds->size() - numberToDelete - 1); @@ -1968,7 +1968,7 @@ bool Table::compactArbitrationData() { if (numberToDelete == pendingSendArbitrationRounds->size()) { pendingSendArbitrationRounds->clear(); } else { - for (int i = 0; i < numberToDelete; i++) { + for (uint i = 0; i < numberToDelete; i++) { pendingSendArbitrationRounds->removeIndex(pendingSendArbitrationRounds->size() - 1); } } @@ -2067,7 +2067,7 @@ bool Table::updateCommittedTable() { } // Go through each new commit one by one - for (int i = 0; i < commitSequenceNumbers->size(); i++) { + for (uint i = 0; i < commitSequenceNumbers->size(); i++) { int64_t commitSequenceNumber = commitSequenceNumbers->get(i); Commit *commit = commitForClientTable->get(commitSequenceNumber); @@ -2236,7 +2236,7 @@ bool Table::updateSpeculativeTable(bool didProcessNewCommits) { oldestTransactionSequenceNumberSpeculatedOn = transactionSequenceNumbersSorted->get(0); // Find where to start arbitration from - int startIndex = 0; + uint startIndex = 0; for (; startIndex < transactionSequenceNumbersSorted->size(); startIndex++) if (transactionSequenceNumbersSorted->get(startIndex) == lastTransactionSequenceNumberSpeculatedOn) @@ -2251,7 +2251,7 @@ bool Table::updateSpeculativeTable(bool didProcessNewCommits) { Hashset *incompleteTransactionArbitrator = new Hashset(); bool didSkip = true; - for (int i = startIndex; i < transactionSequenceNumbersSorted->size(); i++) { + for (uint i = startIndex; i < transactionSequenceNumbersSorted->size(); i++) { int64_t transactionSequenceNumber = transactionSequenceNumbersSorted->get(i); Transaction *transaction = liveTransactionBySequenceNumberTable->get(transactionSequenceNumber); @@ -2311,7 +2311,7 @@ void Table::updatePendingTransactionSpeculativeTable(bool didProcessNewCommitsOr } // Find where to start arbitration from - int startIndex = 0; + uint startIndex = 0; for (; startIndex < pendingTransactionQueue->size(); startIndex++) if (pendingTransactionQueue->get(startIndex) == firstPendingTransaction) @@ -2322,7 +2322,7 @@ void Table::updatePendingTransactionSpeculativeTable(bool didProcessNewCommitsOr return; } - for (int i = startIndex; i < pendingTransactionQueue->size(); i++) { + for (uint i = startIndex; i < pendingTransactionQueue->size(); i++) { Transaction *transaction = pendingTransactionQueue->get(i); lastPendingTransactionSpeculatedOn = transaction; @@ -2779,7 +2779,7 @@ void Table::addWatchVector(int64_t machineId, RejectedMessage *entry) { * Check if the HMAC chain is not violated */ void Table::checkHMACChain(SlotIndexer *indexer, Array *newSlots) { - for (int i = 0; i < newSlots->length(); i++) { + for (uint i = 0; i < newSlots->length(); i++) { Slot *currSlot = newSlots->get(i); Slot *prevSlot = indexer->getSlot(currSlot->getSequenceNumber() - 1); if (prevSlot != NULL && diff --git a/version2/src/C/Transaction.cc b/version2/src/C/Transaction.cc index 0c2bed3..c7785c5 100644 --- a/version2/src/C/Transaction.cc +++ b/version2/src/C/Transaction.cc @@ -102,7 +102,7 @@ int64_t Transaction::getSequenceNumber() { void Transaction::setSequenceNumber(int64_t _sequenceNumber) { sequenceNumber = _sequenceNumber; - for (int32_t i = 0; i < parts->size(); i++) { + for (uint32_t i = 0; i < parts->size(); i++) { TransactionPart *tp = parts->get(i); if (tp != NULL) tp->setSequenceNumber(sequenceNumber); @@ -214,7 +214,7 @@ void Transaction::setDead() { // Set dead isDead = true; // Make all the parts of this transaction dead - for (int32_t partNumber = 0; partNumber < parts->size(); partNumber++) { + for (uint32_t partNumber = 0; partNumber < parts->size(); partNumber++) { TransactionPart *part = parts->get(partNumber); if (part != NULL) part->setDead(); @@ -229,7 +229,7 @@ TransactionPart *Transaction::getPart(int index) { void Transaction::decodeTransactionData() { // Calculate the size of the data section int dataSize = 0; - for (int i = 0; i < parts->size(); i++) { + for (uint i = 0; i < parts->size(); i++) { TransactionPart *tp = parts->get(i); dataSize += tp->getDataSize(); } @@ -238,7 +238,7 @@ void Transaction::decodeTransactionData() { int currentPosition = 0; // Stitch all the data sections together - for (int i = 0; i < parts->size(); i++) { + for (uint i = 0; i < parts->size(); i++) { TransactionPart *tp = parts->get(i); System_arraycopy(tp->getData(), 0, combinedData, currentPosition, tp->getDataSize()); currentPosition += tp->getDataSize(); diff --git a/version2/src/C/Transaction.h b/version2/src/C/Transaction.h index f7235d0..d6453d6 100644 --- a/version2/src/C/Transaction.h +++ b/version2/src/C/Transaction.h @@ -19,7 +19,7 @@ private: int64_t arbitratorId; int64_t machineId; Pair transactionId; - int nextPartToSend; + uint32_t nextPartToSend; bool flddidSendAPartToServer; TransactionStatus *transactionStatus; bool hadServerFailure; diff --git a/version2/src/C/array.h b/version2/src/C/array.h index 996a912..5e7acdb 100644 --- a/version2/src/C/array.h +++ b/version2/src/C/array.h @@ -82,7 +82,7 @@ private: }; template -void System_arraycopy(Array *src, int32_t srcPos, Array *dst, int32_t dstPos, int32_t len) { +void System_arraycopy(Array *src, uint32_t srcPos, Array *dst, uint32_t dstPos, uint32_t len) { if (srcPos + len > src->length() || dstPos + len > dst->length()) ASSERT(0); -- 2.34.1