Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions n_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void _noteSuspendTransactionDebug(void)
*/
NOTE_C_STATIC uint32_t _noteTransaction_calculateTimeoutMs(J *req, bool isReq)
{
uint32_t result = (CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000);
uint32_t result = (CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000UL);

// Interrogate the request
if (JContainsString(req, (isReq ? "req" : "cmd"), "note.add")) {
Expand All @@ -123,7 +123,7 @@ NOTE_C_STATIC uint32_t _noteTransaction_calculateTimeoutMs(J *req, bool isReq)
result = JGetInt(req, "milliseconds");
} else if (JIsPresent(req, "seconds")) {
NOTE_C_LOG_DEBUG("Using `seconds` parameter value for timeout.");
result = (JGetInt(req, "seconds") * 1000);
result = (JGetInt(req, "seconds") * 1000UL);
}
} else if (JContainsString(req, (isReq ? "req" : "cmd"), "web.")) {
NOTE_C_LOG_DEBUG("web.* request received.");
Expand All @@ -133,11 +133,11 @@ NOTE_C_STATIC uint32_t _noteTransaction_calculateTimeoutMs(J *req, bool isReq)
result = JGetInt(req, "milliseconds");
} else if (JIsPresent(req, "seconds")) {
NOTE_C_LOG_DEBUG("Using `seconds` parameter value for timeout.");
result = (JGetInt(req, "seconds") * 1000);
result = (JGetInt(req, "seconds") * 1000UL);
} else {
NOTE_C_LOG_DEBUG("No `milliseconds` or `seconds` parameter "
"provided. Defaulting to 90-second timeout.");
result = (90 * 1000);
result = (90UL * 1000UL);
}
}

Expand Down Expand Up @@ -319,7 +319,7 @@ J *NoteRequestResponseWithRetry(J *req, uint32_t timeoutSeconds)

// Calculate expiry time in milliseconds
uint32_t startMs = _GetMs();
uint32_t timeoutMs = timeoutSeconds * 1000;
uint32_t timeoutMs = timeoutSeconds * 1000UL;

while(true) {
// Execute the transaction
Expand Down Expand Up @@ -378,7 +378,7 @@ J *NoteRequestResponseWithRetry(J *req, uint32_t timeoutSeconds)
*/
char * NoteRequestResponseJSON(const char *reqJSON)
{
const uint32_t transactionTimeoutMs = (CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000);
const uint32_t transactionTimeoutMs = (CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000UL);
char *rspJSON = NULL;
char *allocatedJSON = NULL; // required to free the string if it is not newline-terminated
bool isCmdPipeline = false;
Expand Down Expand Up @@ -579,7 +579,7 @@ J *_noteTransactionShouldLock(J *req, bool lockNotecard)
const uint32_t id = JGetInt(req, "id");

// Ensure the Notecard is ready
if (!_TransactionStart(CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000)) {
if (!_TransactionStart(CARD_INTER_TRANSACTION_TIMEOUT_SEC * 1000UL)) {
_Free(json);
const char *errStr = ERRSTR("Notecard not ready (CTX/RTX) {io}", c_ioerr);
if (cmdFound) {
Expand Down
4 changes: 2 additions & 2 deletions test/src/_noteTransaction_calculateTimeoutMs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ SCENARIO("_noteTransaction_calculateTimeoutMs")
J *resp = NoteTransaction(req);

THEN("The timeout value is set to 90 seconds") {
CHECK(_noteJSONTransaction_fake.arg3_val == (90 * 1000));
CHECK(_noteJSONTransaction_fake.arg3_val == (90UL * 1000UL));
}

JDelete(resp);
Expand All @@ -394,7 +394,7 @@ SCENARIO("_noteTransaction_calculateTimeoutMs")
J *resp = NoteTransaction(req);

THEN("The timeout value is set to 90 seconds") {
CHECK(_noteJSONTransaction_fake.arg3_val == (90 * 1000));
CHECK(_noteJSONTransaction_fake.arg3_val == (90UL * 1000UL));
}

JDelete(resp);
Expand Down