Date: Fri, 17 May 2019 18:21:00 +0000
From: bugzilla-noreply@freebsd.org
To: bugs@FreeBSD.org
Subject: [Bug 237940] struct nvme_health_information_page{} @ /usr/include/dev/nvme/nvme.h has alignment issues.
Message-ID: <bug-237940-227-Pe1IZUL584@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-237940-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237940 Conrad Meyer <cem@freebsd.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cem@freebsd.org --- Comment #1 from Conrad Meyer <cem@freebsd.org> --- Yes, the temperature field is inherently misaligned. The __aligned(4) was added in r240671 as a hack for printing out the nvme_controller_data and nvme_namespace_data pages as 32-bit hex values with a naive cast -- avoiding a -Wcast-align warning. At the time, nvme_health_information_page wasn't used by nvmecontrol -- it was probably just added at the same time because it was also __packed. Today we mostly print the page using a specialized printer, print_log_health, rather than any uint32 cast hex hack. print_hex -> print_dwords still uses this hack for the log page data if -x flag is specified, but print functions take the raw void* buffer pointer rather than a structure pointer, so we can probably drop the __aligned attribute. Additionally, get_log_buffer() allocates the buffer using plain malloc() with the log page size. This implicitly provides 4-byte alignment because FreeBSD only supports 32-bit and 64-bit architectures, and the log page is >4 bytes in size, so any standard C compliant malloc must provide 4-byte alignment on any platform FreeBSD runs on. It might be more clear to use aligned_alloc() to provide that guarantee explicitly instead, but I don't feel strongly about it. Tl;dr: I think we can drop the __aligned(4) attribute now, and probably on the other structures as well. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-237940-227-Pe1IZUL584>
