openocd icon indicating copy to clipboard operation
openocd copied to clipboard

Calloc warning/error

Open R055A opened this issue 1 year ago • 4 comments

There is a calloc warning/error returned from line 1476 in src/jtag/drivers/ulink.c:

tdo_buffer_start = calloc(sizeof(uint8_t), scan_size_bytes);

The error causes a warning message but this can and is treated as an error, as follows:

Error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument`

A suggested fix is:

tdo_buffer_start = calloc(scan_size_bytes, sizeof(uint8_t));

R055A avatar Jul 17 '24 08:07 R055A

That sounds like a problem in the upstream OpenOCD code, rather than anything that Raspberry Pi have modified?

lurch avatar Jul 18 '24 13:07 lurch

That sounds like a problem in the upstream OpenOCD code, rather than anything that Raspberry Pi have modified?

Hi @lurch

Thank you for the quick response.

I understand. I see it is already fixed a month ago here. However, not before the latest version was released in January 2023.

R055A avatar Jul 18 '24 14:07 R055A

Looks like this is still applicable to our latest sdk-2.0.0 branch https://github.com/raspberrypi/openocd/blob/sdk-2.0.0/src/jtag/drivers/ulink.c#L1476 . I dunno if it'll get merged or not (it seems unlikely we'd pull in a fix for a 3rd-party driver), but I guess you probably want to change the base-branch on your PR?

lurch avatar Aug 24 '24 13:08 lurch

Looks like this is still applicable to our latest sdk-2.0.0 branch https://github.com/raspberrypi/openocd/blob/sdk-2.0.0/src/jtag/drivers/ulink.c#L1476 . I dunno if it'll get merged or not (it seems unlikely we'd pull in a fix for a 3rd-party driver), but I guess you probably want to change the base-branch on your PR?

Base branch is changed. Thank you @lurch

R055A avatar Aug 26 '24 16:08 R055A

As a workaround for this,

export CFLAGS="-Wno-error=calloc-transposed-args"
./configure

flaviut avatar Dec 30 '24 20:12 flaviut