Skip to content

Commit

Permalink
fix #309: change return type of cFram::saveField() to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
dhineshkumarmcci committed Jul 13, 2021
1 parent 6c1db30 commit f9b2274
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Catena_Fram.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,19 @@ class cFram : public cPersistentStorage
char **argv
);

void saveField(
bool saveField(
cFramStorage::StandardKeys uKey,
const uint8_t *pValue,
size_t nValue
);

template <typename T>
void saveField(
bool saveField(
cFramStorage::StandardKeys uKey,
const T &field
)
{
this->saveField(uKey, (const uint8_t *)&field, sizeof(field));
return this->saveField(uKey, (const uint8_t *)&field, sizeof(field));
};

bool getField(
Expand Down
16 changes: 14 additions & 2 deletions src/lib/Catena_Fram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,23 +615,35 @@ McciCatena::cFram::writeItemData(
return fResult;
}

void McciCatena::cFram::saveField(
bool McciCatena::cFram::saveField(
cFramStorage::StandardKeys uKey,
const uint8_t *pValue,
size_t nValue
)
{
cFram::Cursor cursor(this, uKey);

bool fResult;

fResult = true;
if (! cursor.create())
{
gLog.printf(gLog.kError,
"%s: can't save uKey(0x%x) %u bytes\n",
__FUNCTION__, uKey, nValue
);
fResult = false;
}

if (! cursor.put(pValue, nValue))
{
gLog.printf(gLog.kError, "%s: can't put uKey(0xx) %u bytes\n",
__func__, uKey, nValue
);
fResult = false;
}

cursor.put(pValue, nValue);
return fResult;
}

bool McciCatena::cFram::getField(
Expand Down

0 comments on commit f9b2274

Please sign in to comment.