HomeFreeBSD

libnv: Fix strict-aliasing violation with cookie

Description

libnv: Fix strict-aliasing violation with cookie

In rS323851, some casts were adjusted in calls to nvlist_next() and
nvlist_get_pararr() in order to make scan-build happy. I think these changes
just confused scan-build into not reporting the strict-aliasing violation.

For example, nvlist_xdescriptors() is causing nvlist_next() to write to its
local variable nvp of type nvpair_t * using the lvalue *cookiep of type
void *, which is not allowed. Given the APIs of nvlist_next(),
nvlist_get_parent() and nvlist_get_pararr(), one possible fix is to create a
local void *cookie in nvlist_xdescriptors() and other places, and to convert
the value to nvpair_t * when necessary. This patch implements that fix.

Reviewed by: oshogbo
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D12760

Details

Provenance
jillesAuthored on
Reviewer
oshogbo
Differential Revision
D12760: libnv: Fix strict-aliasing violation with cookie
Parents
rS325016: Partially revert r325011: restore Guid's default constructor
Branches
Unknown
Tags
Unknown