Skip to content

Commit

Permalink
Minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Platone committed Dec 12, 2021
1 parent 23f7773 commit 7e21ec9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion dsp/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dsp/dsp.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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]"); \
Expand Down
20 changes: 10 additions & 10 deletions dsp/fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++) {
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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];
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vlbi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vlbi_server_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
{
Expand Down

0 comments on commit 7e21ec9

Please sign in to comment.