Closed jphickey closed 1 year ago
Describe the bug Cppcheck reports the following issue in app/bpcat.c:
app/bpcat.c:648:86: error: Subtracting pointers that point to different objects [comparePointers] status = bplib_send(desc, &msg_buffer, &msg_buffer.content[data_fill_sz] - (uint8_t *)&msg_buffer, ^ app/bpcat.c:75:14: note: Variable declared here. uint8_t content[BPCAT_DATA_MESSAGE_MAX_SIZE]; ^ app/bpcat.c:648:52: note: Address of variable taken here. status = bplib_send(desc, &msg_buffer, &msg_buffer.content[data_fill_sz] - (uint8_t *)&msg_buffer, ^ app/bpcat.c:554:25: note: Variable declared here. bpcat_msg_content_t msg_buffer; ^ app/bpcat.c:648:99: note: Address of variable taken here. status = bplib_send(desc, &msg_buffer, &msg_buffer.content[data_fill_sz] - (uint8_t *)&msg_buffer, ^ app/bpcat.c:648:86: note: Subtracting pointers that point to different objects status = bplib_send(desc, &msg_buffer, &msg_buffer.content[data_fill_sz] - (uint8_t *)&msg_buffer,
To Reproduce Execute cppcheck
Expected behavior Should pass cleanly
System observed on: Ubuntu 22.04
Additional context Both types should be uint8_t* however this code might be clearer by using offsetof() instead.
uint8_t*
offsetof()
Reporter Info Joseph Hickey, Vantage Systems, Inc.
Describe the bug Cppcheck reports the following issue in app/bpcat.c:
To Reproduce Execute cppcheck
Expected behavior Should pass cleanly
System observed on: Ubuntu 22.04
Additional context Both types should be
uint8_t*
however this code might be clearer by usingoffsetof()
instead.Reporter Info Joseph Hickey, Vantage Systems, Inc.