Skip to content

Fix Argument Order in calloc Call in fir_filter.c #972

@goatmanic

Description

@goatmanic

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:

Path: bladeRF/host/utilities/bladeRF-fsk/c/src/fir_filter.c
Line: 227

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:

  1. Compile the affected file with a strict compiler that treats warnings as errors.
  2. Observe the compilation error due to the transposed arguments in the calloc function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions