mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-26 11:01:16 -03:00
kill CAST_INIT, use reinterpret_cast<> on sockaddr
Just use static_cast directly instead of inscrutible "shortcut" macro. It was not always used and doesn't seem to do much besides scramble things up; encountering CAST_INIT() in the code seems likely to lead to head scratching due to the transformation taking place. It was added to save folks typing the type twice, now with 100 columns available, let's roll that convenience macro back. sockaddr_dl: Perform reinterpret_cast<sockaddr_dl> conversion. The cast affected alignment and looks fishy to a compiler (but it's fine). Ditch C-style cast and communicate we're doing that on purpose.
This commit is contained in:
@@ -935,7 +935,7 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
|
||||
if (p->ifa_addr->sa_family == AF_LINK) {
|
||||
if (p->ifa_name && p->ifa_name[0] &&
|
||||
!strcmp((const char *)p->ifa_name, interface)) {
|
||||
const sockaddr_dl &sdl = *(sockaddr_dl *)p->ifa_addr;
|
||||
const sockaddr_dl &sdl = *reinterpret_cast<sockaddr_dl *>(p->ifa_addr);
|
||||
|
||||
size_t alen = sdl.sdl_alen;
|
||||
if (alen > MAC_ADDRESS_MAX_LEN) alen = MAC_ADDRESS_MAX_LEN;
|
||||
|
||||
Reference in New Issue
Block a user