compile errors
authorbdemsky <bdemsky@uci.edu>
Tue, 6 Mar 2018 11:14:15 +0000 (03:14 -0800)
committerbdemsky <bdemsky@uci.edu>
Tue, 6 Mar 2018 11:14:15 +0000 (03:14 -0800)
version2/src/C/CloudComm.cc
version2/src/C/Commit.cc
version2/src/C/Makefile
version2/src/C/SecureRandom.cc
version2/src/C/SlotBuffer.cc
version2/src/C/SlotIndexer.cc
version2/src/C/Table.cc
version2/src/C/Transaction.cc
version2/src/C/Transaction.h
version2/src/C/array.h

index dc2835507966b311950773da54347ce3921028eb..9055d8624c0e2708decad944755a829c94681438 100644 (file)
@@ -29,7 +29,6 @@ CloudComm::CloudComm() :
        salt(NULL),
        table(NULL),
        listeningPort(-1),
-       localServerThread(NULL),
        doEnd(false),
        timer(TimingSingleton_getInstance()),
        getslot(new Array<char>("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...");
        }
index f159f71608c59bf74f427234cab8af797fee8ddc..cb707e2fe67c0cf6db8f65b0a159667b494eedaf 100644 (file)
@@ -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());
index e4501305522151e6f6bb64de6116b7f5ee23dc26..495cc70c5141fe27f4d134a28dbd94a6348c7098 100644 (file)
@@ -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}
index 201de082956b22dd1c7c7236dfb4f51a07886ad7..84f40c3b197647e1393a94f7d629978e4a16d0c9 100644 (file)
@@ -1,5 +1,6 @@
 #include "SecureRandom.h"
 #include <stdlib.h>
+#include <bsd/stdlib.h>
 
 SecureRandom::SecureRandom() {
 }
index 248abd78017f03237e0f74cd8cf5bfc8403ad962..2ce4a66147b20a2091126ed83cf4d0dc38faeadd 100644 (file)
@@ -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<Slot *> *newarray = new Array<Slot *>(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;
        }
 
index c3633188f141cf20d1ec4c19b19a633c00df0ca1..b49ca454e749953f152d9ef85f0caf75933675b9 100644 (file)
@@ -18,7 +18,7 @@ SlotIndexer::SlotIndexer(Array<Slot *> *_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);
index d70a590890b170fac9417fc6ab049437304de286..dce3a8f1969e4e960419b080ffe8ec17595c523a 100644 (file)
@@ -420,7 +420,7 @@ TransactionStatus *Table::commitTransaction() {
                Hashset<int64_t> *arbitratorTriedAndFailed = new Hashset<int64_t>();
                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<int64_t> *incompleteTransactionArbitrator = new Hashset<int64_t>();
        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<Slot *> *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 &&
index 0c2bed3a37e46ae77f062626ecadcf0b6f473310..c7785c56e87967b221280f7f302784a4898cea91 100644 (file)
@@ -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();
index f7235d034ca38c54c2d47b455657f78f804de96f..d6453d6b475461f4b0354232112da429294b65b0 100644 (file)
@@ -19,7 +19,7 @@ private:
        int64_t arbitratorId;
        int64_t machineId;
        Pair<int64_t, int64_t> transactionId;
-       int nextPartToSend;
+       uint32_t nextPartToSend;
        bool flddidSendAPartToServer;
        TransactionStatus *transactionStatus;
        bool hadServerFailure;
index 996a9121887698359c2d0d024f0ab3f1055ebb07..5e7acdba21d7fbc75b50661da73f18127cbe97bb 100644 (file)
@@ -82,7 +82,7 @@ private:
 };
 
 template<typename type>
-void System_arraycopy(Array<type> *src, int32_t srcPos, Array<type> *dst, int32_t dstPos, int32_t len) {
+void System_arraycopy(Array<type> *src, uint32_t srcPos, Array<type> *dst, uint32_t dstPos, uint32_t len) {
        if (srcPos + len > src->length() ||
                        dstPos + len > dst->length())
                ASSERT(0);