code cleanup;

pull/128/head
Bryan Biedenkapp 2 months ago
parent 66aa15ef53
commit 0d896f650d

@ -30,7 +30,16 @@ using namespace nxdn::channel;
using namespace p25::defines;
using namespace p25::lc::tsbk;
// ---------------------------------------------------------------------------
// Global Functions
// ---------------------------------------------------------------------------
namespace {
/**
* @brief Generate a pseudo-random number using xorshift32.
* @param state Reference to the current state of the random number generator.
* @returns uint32_t Pseudo-random number.
*/
uint32_t nextRand(uint32_t& state)
{
// Deterministic xorshift32 for reproducible fuzz vectors.
@ -40,12 +49,19 @@ uint32_t nextRand(uint32_t& state)
return state;
}
/**
* @brief Fill a buffer with pseudo-random data.
* @param buffer Pointer to the buffer to fill.
* @param len Length of the buffer in bytes.
* @param state Reference to the current state of the random number generator.
*/
void fillPseudoRandom(uint8_t* buffer, uint32_t len, uint32_t& state)
{
for (uint32_t i = 0U; i < len; ++i) {
buffer[i] = static_cast<uint8_t>(nextRand(state) & 0xFFU);
}
}
} // namespace
TEST_CASE("Parsers tolerate malformed inputs without throwing", "[robustness][fuzz][parser]")

@ -157,7 +157,7 @@ void buildDMRVoiceSyncPayload(uint8_t* payload)
dmr::Sync::addDMRAudioSync(payload, false);
}
}
} // namespace
// ---------------------------------------------------------------------------
// Class Declaration

@ -98,7 +98,7 @@ uint16_t reserveLoopbackPort()
return ntohs(address.sin_port);
}
}
} // namespace
// ---------------------------------------------------------------------------
// Class Declaration

@ -142,7 +142,7 @@ void buildP25RFFrame(const uint8_t* payload, uint8_t* frame)
::memcpy(frame + 2U, payload, p25::defines::P25_LDU_FRAME_LENGTH_BYTES);
}
}
} // namespace
// ---------------------------------------------------------------------------
// Class Declaration

Loading…
Cancel
Save

Powered by TurnKey Linux.