Page MenuHomeFreeBSD

bluetooth: Don't use a non-string to initialize NG_HCI_BDADDR_ANY
ClosedPublic

Authored by jhb on Sun, Jan 25, 4:54 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 26, 12:42 AM
Unknown Object (File)
Sun, Jan 25, 10:53 PM
Unknown Object (File)
Sun, Jan 25, 6:57 PM
Unknown Object (File)
Sun, Jan 25, 4:52 PM
Unknown Object (File)
Sun, Jan 25, 12:20 PM

Details

Summary

Explicitly use an array of 6 zeroes instead of a C string containing
nul characters. GCC 15 warns about the truncation, but this is
cleaner regardless.

In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/bluetooth.h:51,

from usr.sbin/virtual_oss/virtual_bt_speaker/bt_speaker.c:45:

usr.sbin/virtual_oss/virtual_bt_speaker/bt_speaker.c: In function 'register_sdp':
usr.sbin/virtual_oss/virtual_bt_speaker/bt_speaker.c:96:13: error: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (7 chars into 6 available) [-Werror=unterminated-string-initialization]

96 |             NG_HCI_BDADDR_ANY, (const uint8_t *)&record, sizeof(record),
   |             ^~~~~~~~~~~~~~~~~

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This stack of 5 commits is enough to build amd64 world + GENERIC with GCC 15.

BTW, for the two that were nonstring related (such as this one), I'm surprised clang wasn't also warning about these?

LGTM.

In D54869#1254340, @jhb wrote:

BTW, for the two that were nonstring related (such as this one), I'm surprised clang wasn't also warning about these?

With clang 21 I did get quite a few nonstring warnings, but not on this one.

This revision was not accepted when it landed; it landed in state Needs Review.Tue, Jan 27, 6:41 PM
This revision was automatically updated to reflect the committed changes.