You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The calloc function call in the fir_filter.c file uses the arguments in an incorrect order, causing a compilation error with the message:
error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=callc- transposed-args]
This error occurs because calloc expects the number of elements as the first argument and the size of each element as the second argument. However, the existing code has these reversed.
The arguments to calloc should be reordered to correctly reflect the expected signature of calloc(num_elements, element_size). The corrected line of code is:
This change ensures that the chunk_size (the number of elements) is passed as the first argument and the sizeof(struct complex_sample) (the size of each element) is passed as the second argument.
Steps to Reproduce:
Compile the affected file with a strict compiler that treats warnings as errors.
Observe the compilation error due to the transposed arguments in the calloc function.
The text was updated successfully, but these errors were encountered:
I have the same error. Applying this patch allows compilation to succeed. I am using Fedora 40.
[ 96%] Building C object host/utilities/bladeRF-fsk/c/CMakeFiles/bladeRF-fsk_test_fir_filter.dir/src/fir_filter.c.o
/home/dbezborodov/src/bladeRF/host/utilities/bladeRF-fsk/c/src/fir_filter.c: In function ‘main’:
/home/dbezborodov/src/bladeRF/host/utilities/bladeRF-fsk/c/src/fir_filter.c:227:28: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
227 | outbuf = calloc(sizeof(struct complex_sample), chunk_size);
| ^~~~~~
/home/dbezborodov/src/bladeRF/host/utilities/bladeRF-fsk/c/src/fir_filter.c:227:28: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors
make[2]: *** [host/utilities/bladeRF-fsk/c/CMakeFiles/bladeRF-fsk_test_fir_filter.dir/build.make:90: host/utilities/bladeRF-fsk/c/CMakeFiles/bladeRF-fsk_test_fir_filter.dir/src/fir_filter.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1553: host/utilities/bladeRF-fsk/c/CMakeFiles/bladeRF-fsk_test_fir_filter.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
The calloc function call in the fir_filter.c file uses the arguments in an incorrect order, causing a compilation error with the message:
error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=callc- transposed-args]
This error occurs because calloc expects the number of elements as the first argument and the size of each element as the second argument. However, the existing code has these reversed.
Affected File:
Proposed Fix
The arguments to calloc should be reordered to correctly reflect the expected signature of calloc(num_elements, element_size). The corrected line of code is:
outbuf = calloc(chunk_size, sizeof(struct complex_sample));
This change ensures that the chunk_size (the number of elements) is passed as the first argument and the sizeof(struct complex_sample) (the size of each element) is passed as the second argument.
Steps to Reproduce:
The text was updated successfully, but these errors were encountered: