From 4de1d02e650af1d28467fb8df2cfa1840ed78884 Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Mon, 22 Aug 2016 16:58:49 -0400 Subject: [PATCH] bladeRF-fsk: Fixed 32-bit Windows build issue Narrowing conversion requires a sanity check and cast. --- host/utilities/bladeRF-fsk/c/src/phy.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/host/utilities/bladeRF-fsk/c/src/phy.c b/host/utilities/bladeRF-fsk/c/src/phy.c index b3392dbb..559f73de 100644 --- a/host/utilities/bladeRF-fsk/c/src/phy.c +++ b/host/utilities/bladeRF-fsk/c/src/phy.c @@ -735,6 +735,10 @@ void *phy_receive_frames(void *arg) CHECK_FRAME_TYPE, DECODE, COPY}; enum states state; //current state variable + /* corr_process() takes a size_t count. + * Ensure a cast from uint64_t to size_t is valid. */ + assert(NUM_SAMPLES_RX < SIZE_MAX); + //Allocate memory for buffer rx_buffer = malloc(MAX_LINK_FRAME_SIZE); if (rx_buffer == NULL){ @@ -804,7 +808,7 @@ void *phy_receive_frames(void *arg) //DEBUG_MSG("[PHY] RX: State = PREAMBLE_CORRELATE\n"); samples_index = corr_process(phy->rx->corr, &(phy->rx->pnorm_samples[samples_index]), - NUM_SAMPLES_RX-samples_index, 0); + (size_t) (NUM_SAMPLES_RX-samples_index), 0); if (samples_index != CORRELATOR_NO_RESULT){ DEBUG_MSG("[PHY] RX: Preamble matched @ index %lu\n", samples_index); preamble_detected = true;