From 2d975875eecad8ddc0c5fc5ec6d4582f9a706439 Mon Sep 17 00:00:00 2001 From: Oscar Shiang Date: Mon, 14 Sep 2020 10:33:28 +0800 Subject: [PATCH] Fix the size to be cleaned in prepare_inputs In dudect/constant.c, to do the test, we must first distribute all 100000 data into two classes, fixed and random class. If the one is distributed to 0, it means it belongs to random class and we should clean the relating input_data to 0. But in this Implementation, a single size of an element in input_data is `chunk_size` which means it is 16 byte. However, in dudect/constant.c, it only clean up an `uint16_t` size, which is 2 byte only. To fix this problem, I use memset to reset the whole element to 0. --- dudect/constant.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dudect/constant.c b/dudect/constant.c index 66b29001b..f511e41b6 100644 --- a/dudect/constant.c +++ b/dudect/constant.c @@ -42,7 +42,7 @@ void prepare_inputs(uint8_t *input_data, uint8_t *classes) for (size_t i = 0; i < number_measurements; i++) { classes[i] = randombit(); if (classes[i] == 0) - *(uint16_t *) (input_data + i * chunk_size) = 0x00; + memset(input_data + (size_t) i * chunk_size, 0, chunk_size); } for (size_t i = 0; i < NR_MEASURE; ++i) {