From 31018eaea6da15c983fa1b6f1d658215b1ebd7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricard=20Wanderl=C3=B6f?= Date: Wed, 22 Apr 2020 12:00:09 +0200 Subject: [PATCH] Fix alignment warning when building with -Wcast-align When building with -Wcast-align, we get a warning because the alignment of st->substate is not known by kiss_fftr_alloc() so shift the data around so that we don't need to care about the alignment for st->substate. Signed-off-by: Ricard Wanderlof --- tools/kiss_fftr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/kiss_fftr.c b/tools/kiss_fftr.c index 5d74425..e37c96d 100644 --- a/tools/kiss_fftr.c +++ b/tools/kiss_fftr.c @@ -33,6 +33,8 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme nfft >>= 1; kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); + /* nfft kiss_fft_cpx'es for the tmpbuf; half as many for the + * super_twiddles */ memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 3 / 2); if (lenmem == NULL) { @@ -45,9 +47,9 @@ kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenme if (!st) return NULL; - st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */ - st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize); - st->super_twiddles = st->tmpbuf + nfft; + st->tmpbuf = (kiss_fft_cpx *) (st + 1); /*just beyond kiss_fftr_state struct */ + st->super_twiddles = st->tmpbuf + nfft; /*just beyond tmpbuf */ + st->substate = (kiss_fft_cfg) (st->tmpbuf + nfft * 3 / 2); /*just beyond super_twiddles */ kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize); for (i = 0; i < nfft/2; ++i) {