Re: git: 61482760a0ca - main - bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 22 Mar 2023 21:46:39 UTC
On 3/22/23 12:44 PM, Jessica Clarke wrote:
> On 22 Mar 2023, at 19:35, John Baldwin <jhb@FreeBSD.org> wrote:
>>
>> The branch main has been updated by jhb:
>>
>> URL: https://cgit.FreeBSD.org/src/commit/?id=61482760a0ca198a9310d450133e9ac792b67955
>>
>> commit 61482760a0ca198a9310d450133e9ac792b67955
>> Author:     John Baldwin <jhb@FreeBSD.org>
>> AuthorDate: 2023-03-22 19:34:34 +0000
>> Commit:     John Baldwin <jhb@FreeBSD.org>
>> CommitDate: 2023-03-22 19:34:34 +0000
>>
>>     bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.
>>
>>     It is illegal (UB?) to pass a shorter array to a function argument
>>     that takes a fixed-length array.  Do a runtime check for names that
>>     are too long via strlen() instead.
> 
> So, without static in there (that very weird corner of the C grammar*),
> the size is meaningless. GCC just treats this as a convention that you
> meant the size to do something for the purposes of diagnostics, but not
> semantics, so this is in fact a known, and by design, false-positive.

Humm, ok.  I'd probably still rather pacify the warning rather than
silence the warning as it finds real bugs in other places.

-- 
John Baldwin