Skip to content
Closed
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ if(NOTE_C_BUILD_TESTS)
-Wall
-Wextra
-Wpedantic
-Wshadow
-Werror
-Og
-ggdb
Expand Down
50 changes: 25 additions & 25 deletions n_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,12 @@ const char * NoteBinaryStoreReceive(uint8_t *buffer, uint32_t bufLen,

// Check buffer overflow condition
if (available) {
const char *err = ERRSTR("unexpected data available", c_err);
NOTE_C_LOG_ERROR(err);
const char *errStr = ERRSTR("unexpected data available", c_err);
NOTE_C_LOG_ERROR(errStr);
// Queue a reset when a problem is detected, otherwise `note-c` will
// attempt to allocate memory to receive the response.
NoteResetRequired();
return err;
return errStr;
}

// _ChunkedReceive returns the raw bytes that came off the wire, which
Expand All @@ -451,12 +451,12 @@ const char * NoteBinaryStoreReceive(uint8_t *buffer, uint32_t bufLen,

// Ensure the decoded length matches the caller's expectations.
if (decodedLen != decLen) {
const char *err = ERRSTR("length mismatch after decoding", c_err);
NOTE_C_LOG_ERROR(err);
const char *errStr = ERRSTR("length mismatch after decoding", c_err);
NOTE_C_LOG_ERROR(errStr);
// Queue a reset when a problem is detected, otherwise `note-c` will
// attempt to allocate memory to receive the response.
NoteResetRequired();
return err;
return errStr;
}

// Put a hard marker at the end of the decoded portion of the buffer. This
Expand All @@ -468,9 +468,9 @@ const char * NoteBinaryStoreReceive(uint8_t *buffer, uint32_t bufLen,
char hashString[NOTE_MD5_HASH_STRING_SIZE] = {0};
NoteMD5HashString(buffer, decLen, hashString, NOTE_MD5_HASH_STRING_SIZE);
if (strncmp(hashString, status, NOTE_MD5_HASH_STRING_SIZE)) {
const char *err = ERRSTR("computed MD5 does not match received MD5", c_err);
NOTE_C_LOG_ERROR(err);
return err;
const char *errStr = ERRSTR("computed MD5 does not match received MD5", c_err);
NOTE_C_LOG_ERROR(errStr);
return errStr;
}

// Return `NULL` if success, else error string pointer
Expand Down Expand Up @@ -639,19 +639,19 @@ const char * NoteBinaryStoreTransmit(uint8_t *unencodedData, uint32_t unencodedL
_LockNote();

// Issue a "card.binary.put"
J *req = NoteNewRequest("card.binary.put");
if (req) {
JAddIntToObject(req, "cobs", encLen);
J *putReq = NoteNewRequest("card.binary.put");
if (putReq) {
JAddIntToObject(putReq, "cobs", encLen);
if (notecardOffset) {
JAddIntToObject(req, "offset", notecardOffset);
JAddIntToObject(putReq, "offset", notecardOffset);
}
JAddStringToObject(req, "status", hashString);
JAddStringToObject(putReq, "status", hashString);

// We already have the Notecard lock, so call
// _noteTransactionShouldLock with `lockNotecard` set to false so we
// don't try to lock again.
rsp = _noteTransactionShouldLock(req, false);
JDelete(req);
rsp = _noteTransactionShouldLock(putReq, false);
JDelete(putReq);
// Ensure the transaction doesn't return an error.
if (!rsp || NoteResponseError(rsp)) {
if (rsp) {
Expand Down Expand Up @@ -695,10 +695,10 @@ const char * NoteBinaryStoreTransmit(uint8_t *unencodedData, uint32_t unencodedL
// Issue a `"card.binary"` request.
rsp = NoteRequestResponse(NoteNewRequest("card.binary"));
if (!rsp) {
const char *err = ERRSTR("unable to validate request", c_err);
NOTE_C_LOG_ERROR(err);
const char *errStr = ERRSTR("unable to validate request", c_err);
NOTE_C_LOG_ERROR(errStr);
NoteBinaryCodecDecode(encodedData, encLen, encodedData, bufLen);
return err;
return errStr;
}

// Ensure the transaction doesn't return an error
Expand All @@ -712,17 +712,17 @@ const char * NoteBinaryStoreTransmit(uint8_t *unencodedData, uint32_t unencodedL
NOTE_C_LOG_WARN("retrying binary transmission...");
continue;
}
const char *err = ERRSTR("binary data invalid", c_bad);
NOTE_C_LOG_ERROR(err);
const char *errStr = ERRSTR("binary data invalid", c_bad);
NOTE_C_LOG_ERROR(errStr);
NoteBinaryCodecDecode(encodedData, encLen, encodedData, bufLen);
return err;
return errStr;
} else {
NOTE_C_LOG_ERROR(jErr);
JDelete(rsp);
const char *err = ERRSTR("unexpected error received during confirmation", c_bad);
NOTE_C_LOG_ERROR(err);
const char *errStr = ERRSTR("unexpected error received during confirmation", c_bad);
NOTE_C_LOG_ERROR(errStr);
NoteBinaryCodecDecode(encodedData, encLen, encodedData, bufLen);
return err;
return errStr;
}
}
JDelete(rsp);
Expand Down
6 changes: 3 additions & 3 deletions n_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ NOTE_C_STATIC const char * _i2cNoteQueryLength(uint32_t * available,

// If we've timed out, return an error
if (timeoutMs && _GetMs() - startMs >= timeoutMs) {
const char *err = ERRSTR("timeout: no response from Notecard {io}", c_iotimeout);
NOTE_C_LOG_ERROR(err);
return err;
const char *errStr = ERRSTR("timeout: no response from Notecard {io}", c_iotimeout);
NOTE_C_LOG_ERROR(errStr);
return errStr;
}
}
return NULL;
Expand Down
Loading