From 7e21ec9fd53e83754160f1602fe7d8b06ac498f4 Mon Sep 17 00:00:00 2001 From: Ilia Platone Date: Sun, 12 Dec 2021 23:40:42 +0100 Subject: [PATCH] Minor bugfixes --- dsp/buffer.c | 1 - dsp/dsp.h.cmake | 2 +- dsp/fft.c | 20 ++++++++++---------- vlbi_server.cpp | 2 +- vlbi_server_json.cpp | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/dsp/buffer.c b/dsp/buffer.c index 6838057e..d4eefa6c 100755 --- a/dsp/buffer.c +++ b/dsp/buffer.c @@ -278,7 +278,6 @@ static void* dsp_buffer_median_th(void* arg) void dsp_buffer_median(dsp_stream_p in, int size, int median) { - pfunc; int y, d; dsp_stream_p stream = dsp_stream_copy(in); dsp_buffer_set(stream->buf, stream->len, 0); diff --git a/dsp/dsp.h.cmake b/dsp/dsp.h.cmake index 95fa8e6b..2f00a20c 100644 --- a/dsp/dsp.h.cmake +++ b/dsp/dsp.h.cmake @@ -76,7 +76,7 @@ struct timespec ts; \ time_t t = time(NULL); \ struct tm tm = *localtime(&t); \ clock_gettime(CLOCK_REALTIME, &ts); \ -sprintf(str, "[%04d-%02d-%02dT%02d:%02d:%02ld.%03ld ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec/1000000); \ +sprintf(str, "[%04d-%02d-%02dT%02d:%02d:%02d.%03ld ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec/1000000); \ switch(x) { \ case DSP_DEBUG_ERROR: \ sprintf(&str[strlen(str)], "ERRO]"); \ diff --git a/dsp/fft.c b/dsp/fft.c index 0e32be37..a5483cab 100755 --- a/dsp/fft.c +++ b/dsp/fft.c @@ -32,8 +32,8 @@ static void dsp_fourier_dft_phase(dsp_stream_p stream) static void dsp_fourier_2dsp(dsp_stream_p stream) { int x, y; - fftw_complex *dft = (fftw_complex*)malloc(sizeof(fftw_complex) * stream->len); - memcpy(dft, stream->dft.fftw, sizeof(fftw_complex) * stream->len); + fftw_complex *dft = (fftw_complex*)malloc(sizeof(fftw_complex) * (size_t)stream->len); + memcpy(dft, stream->dft.fftw, sizeof(fftw_complex) * (size_t)stream->len); y = 0; for(x = 0; x < stream->len; x++) { int *pos = dsp_stream_get_position(stream, x); @@ -52,9 +52,9 @@ static void dsp_fourier_2dsp(dsp_stream_p stream) static void dsp_fourier_2fftw(dsp_stream_p stream) { int x, y; - fftw_complex *dft = (fftw_complex*)malloc(sizeof(fftw_complex) * stream->len); + fftw_complex *dft = (fftw_complex*)malloc(sizeof(fftw_complex) * (size_t)stream->len); dsp_buffer_shift(stream); - memcpy(dft, stream->dft.fftw, sizeof(fftw_complex) * stream->len); + memcpy(dft, stream->dft.fftw, sizeof(fftw_complex) * (size_t)stream->len); dsp_buffer_set(stream->dft.buf, stream->len*2, 0); y = 0; for(x = 0; x < stream->len; x++) { @@ -71,7 +71,7 @@ static void dsp_fourier_2fftw(dsp_stream_p stream) double* dsp_fourier_complex_array_get_magnitude(dsp_complex in, int len) { int i; - double* out = (double*)malloc(sizeof(double) * len); + double* out = (double*)malloc(sizeof(double) * (size_t)len); for(i = 0; i < len; i++) { double real = in.complex[i].real; double imaginary = in.complex[i].imaginary; @@ -83,15 +83,15 @@ double* dsp_fourier_complex_array_get_magnitude(dsp_complex in, int len) double* dsp_fourier_complex_array_get_phase(dsp_complex in, int len) { int i; - double* out = (double*)malloc(sizeof(double) * len); + double* out = (double*)malloc(sizeof(double) * (size_t)len); for(i = 0; i < len; i++) { out [i] = 0; - if (in.complex[i].real != 0) { + if (in.complex[i].real != 0.0) { double real = in.complex[i].real; double imaginary = in.complex[i].imaginary; double mag = sqrt(pow(real, 2)+pow(imaginary, 2)); double rad = acos (imaginary / mag); - if(real < 0 && rad != 0) + if(real < 0 && rad != 0.0) rad = M_PI*2-rad; out [i] = rad; } @@ -103,7 +103,7 @@ dsp_complex dsp_fourier_phase_mag_array_get_complex(double* mag, double* phi, in { int i; dsp_complex out; - out.fftw = (fftw_complex*)malloc(sizeof(fftw_complex) * len); + out.fftw = (fftw_complex*)malloc(sizeof(fftw_complex) * (size_t)len); dsp_buffer_set(out.buf, len*2, 0); for(i = 0; i < len; i++) { double real = sin(phi[i])*mag[i]; @@ -128,7 +128,7 @@ void dsp_fourier_dft(dsp_stream_p stream, int exp) int d; if(exp < 1) return; - double* buf = (double*)malloc(sizeof(double) * stream->len); + double* buf = (double*)malloc(sizeof(double) * (size_t)stream->len); if(stream->phase == NULL) stream->phase = dsp_stream_copy(stream); if(stream->magnitude == NULL) diff --git a/vlbi_server.cpp b/vlbi_server.cpp index 9f878fa5..8b50dca4 100644 --- a/vlbi_server.cpp +++ b/vlbi_server.cpp @@ -432,7 +432,7 @@ void VLBI::Server::Parse() } else if(!strcmp(arg, "plot")) { - int flags; + int flags = 0; char *t = strtok(value, ","); char *name = t; if(name == nullptr) diff --git a/vlbi_server_json.cpp b/vlbi_server_json.cpp index d041cc61..fa319f8d 100644 --- a/vlbi_server_json.cpp +++ b/vlbi_server_json.cpp @@ -356,7 +356,7 @@ void JSONServer::Parse() char* model = nullptr; char* edit = nullptr; char* arg = nullptr; - for(int y = 0; y < v->u.object.length; y ++) + for(int y = 0; y < (int)v->u.object.length; y ++) { if(!strcmp(values[y].name, "name")) {