summaryrefslogtreecommitdiff
path: root/mangle.c
diff options
context:
space:
mode:
authorplusun <tomsun.0.7@gmail.com>2018-08-06 07:27:54 +0000
committerplusun <tomsun.0.7@gmail.com>2018-08-06 07:27:54 +0000
commit441f9cf923d60d8992ba4118d33b9deb4c9b503e (patch)
treef598e59aae29f214c4726ba4d26ad10d0b7f3053 /mangle.c
parent98022490a8a44232f6c56f8aba7628d97875a0a4 (diff)
downloadhonggfuzz-441f9cf923d60d8992ba4118d33b9deb4c9b503e.tar.gz
refactor add/sub code
Diffstat (limited to 'mangle.c')
-rw-r--r--mangle.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/mangle.c b/mangle.c
index cfcb679a..6cad0681 100644
--- a/mangle.c
+++ b/mangle.c
@@ -854,18 +854,6 @@ static void mangle_AddSubPrintable(run_t* run) {
util_turnToPrintable((uint8_t *)&run->dynamicFile[off], varLen);
}
-static void addPrintable(uint8_t *byte) {
- *byte = ((*byte) - 32 + 1) % 95 + 32;
-}
-
-static void decPrintable(uint8_t *byte) {
- *byte = ((*byte) - 32 + 94) % 95 + 32;
-}
-
-static void negPrintable(uint8_t *byte) {
- *byte = 94 - ((*byte) - 32) + 32;
-}
-
static void mangle_IncByte(run_t* run) {
size_t off = util_rndGet(0, run->dynamicFileSz - 1);
run->dynamicFile[off] += (uint8_t)1UL;
@@ -873,7 +861,7 @@ static void mangle_IncByte(run_t* run) {
static void mangle_IncBytePrintable(run_t* run) {
size_t off = util_rndGet(0, run->dynamicFileSz - 1);
- addPrintable(&run->dynamicFile[off]);
+ run->dynamicFile[off] = (run->dynamicFile[off] - 32 + 1) % 95 + 32;
}
static void mangle_DecByte(run_t* run) {
@@ -883,7 +871,7 @@ static void mangle_DecByte(run_t* run) {
static void mangle_DecBytePrintable(run_t* run) {
size_t off = util_rndGet(0, run->dynamicFileSz - 1);
- decPrintable(&run->dynamicFile[off]);
+ run->dynamicFile[off] = (run->dynamicFile[off] - 32 + 94) % 95 + 32;
}
static void mangle_NegByte(run_t* run) {
@@ -893,7 +881,7 @@ static void mangle_NegByte(run_t* run) {
static void mangle_NegBytePrintable(run_t* run) {
size_t off = util_rndGet(0, run->dynamicFileSz - 1);
- negPrintable(&run->dynamicFile[off]);
+ run->dynamicFile[off] = 94 - (run->dynamicFile[off] - 32) + 32;
}
static void mangle_CloneByte(run_t* run) {