Skip to content

Commit

Permalink
Remove TLV fuzz operations that are not const
Browse files Browse the repository at this point in the history
  • Loading branch information
zcduthie committed Apr 24, 2024
1 parent db3ad52 commit 4149700
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 107 deletions.
29 changes: 0 additions & 29 deletions src/lib/core/TLVUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,35 +110,6 @@ static CHIP_ERROR Iterate(TLVReader & aReader, size_t aDepth, IterateHandler aHa
return retval;
}

/**
* (Mutably) Iterate through the TLV data referenced by @a aReader and invoke mutable @a aHandler
* for each visited TLV element in the context of @a aContext.
* The iteration is aborted if @a aHandler returns anything other than #CHIP_NO_ERROR
*
* @param[in] aReader A reference to the TLV reader containing the TLV
* data to iterate.
* @param[in] aHandler A mutable callback to invoke for the current TLV element
* being visited.
* @param[in,out] aContext An optional pointer to caller-provided context data.
*
* @retval #CHIP_END_OF_TLV On a successful iteration to the end of a TLV encoding,
* or to the end of a TLV container.
*
* @retval #CHIP_ERROR_INVALID_ARGUMENT If @a aHandler is NULL.
*
* @retval The last value returned by @a aHandler, if different than #CHIP_NO_ERROR
*
*/
CHIP_ERROR Iterate(TLVReader & aReader, IterateHandlerMutable aHandler, void * aContext)
{
const bool recurse = true;
CHIP_ERROR retval;

retval = Iterate(aReader, (IterateHandler) aHandler, aContext, recurse);

return retval;
}

/**
* Iterate through the TLV data referenced by @a aReader and invoke @a aHandler
* for each visited TLV element in the context of @a aContext.
Expand Down
4 changes: 0 additions & 4 deletions src/lib/core/TLVUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ namespace TLV {
namespace Utilities {

typedef CHIP_ERROR (*IterateHandler)(const TLVReader & aReader, size_t aDepth, void * aContext);
typedef CHIP_ERROR (*IterateHandlerMutable)(TLVReader & aReader, size_t aDepth, void * aContext);

extern CHIP_ERROR Iterate(TLVReader & aReader, IterateHandlerMutable aHandler, void * aContext);

extern CHIP_ERROR Iterate(const TLVReader & aReader, IterateHandler aHandler, void * aContext);
extern CHIP_ERROR Iterate(const TLVReader & aReader, IterateHandler aHandler, void * aContext, bool aRecurse);
Expand All @@ -54,7 +51,6 @@ extern CHIP_ERROR Find(const TLVReader & aReader, const Tag & aTag, TLVReader &

extern CHIP_ERROR Find(const TLVReader & aReader, IterateHandler aHandler, void * aContext, TLVReader & aResult);
extern CHIP_ERROR Find(const TLVReader & aReader, IterateHandler aHandler, void * aContext, TLVReader & aResult, bool aRecurse);

} // namespace Utilities

} // namespace TLV
Expand Down
78 changes: 4 additions & 74 deletions src/lib/core/tests/FuzzTlvReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,81 +9,11 @@ using namespace chip::TLV;

using chip::TLV::TLVReader;

static CHIP_ERROR FuzzIterator(TLVReader & aReader, size_t aDepth, void * aContext)
static CHIP_ERROR FuzzIterator(const TLVReader & aReader, size_t aDepth, void * aContext)
{
{
aReader.GetLength();
}
{
aReader.GetTag();
}
{
aReader.GetType();
}
{
size_t size;
aReader.CountRemainingInContainer(&size);
}
{
bool v;
aReader.Get(v);
}
{
int8_t v;
aReader.Get(v);
}
{
int16_t v;
aReader.Get(v);
}
{
int32_t v;
aReader.Get(v);
}
{
int64_t v;
aReader.Get(v);
}
{
uint8_t v;
aReader.Get(v);
}
{
uint16_t v;
aReader.Get(v);
}
{
uint32_t v;
aReader.Get(v);
}
{
uint64_t v;
aReader.Get(v);
}
{
double v;
aReader.Get(v);
}
{
float v;
aReader.Get(v);
}
{
chip::ByteSpan readerSpan;
aReader.Get(readerSpan);
}
{
chip::CharSpan readerSpan;
aReader.Get(readerSpan);
}
{
uint8_t bBuf[16];
aReader.GetBytes(bBuf, sizeof(bBuf));
}
{
char sBuf[16];
aReader.GetString(sBuf, sizeof(sBuf));
}
aReader.GetLength();
aReader.GetTag();
aReader.GetType();

return CHIP_NO_ERROR;
}
Expand Down

0 comments on commit 4149700

Please sign in to comment.