Skip to content

Commit 057ed9d

Browse files
author
Requiem
committed
cross-platform adapter info check
1 parent 3c5850c commit 057ed9d

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/vmaware.hpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,6 @@ struct VM {
20472047
[[nodiscard]] static bool mac_address_check() {
20482048
// C-style array on purpose
20492049
u8 mac[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
2050-
20512050
#if (LINUX)
20522051
struct ifreq ifr;
20532052
struct ifconf ifc;
@@ -2058,7 +2057,7 @@ struct VM {
20582057

20592058
if (sock == -1) {
20602059
return false;
2061-
};
2060+
}
20622061

20632062
ifc.ifc_len = sizeof(buf);
20642063
ifc.ifc_buf = buf;
@@ -2087,28 +2086,18 @@ struct VM {
20872086

20882087
if (success) {
20892088
std::memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
2090-
} else {
2089+
}
2090+
else {
20912091
debug("MAC: ", "not successful");
20922092
}
20932093
#elif (WINDOWS)
2094-
#else
2095-
return false;
2096-
#endif
20972094
ULONG needed = 0;
20982095
if (GetIfTable(nullptr, &needed, /*order=*/FALSE) != ERROR_INSUFFICIENT_BUFFER) {
20992096
return false;
21002097
}
21012098

2102-
#if defined(_MSC_VER)
2103-
#define LIKELY(x) (x)
2104-
#define UNLIKELY(x) (x)
2105-
#else
2106-
#define LIKELY(x) __builtin_expect(!!(x), 1)
2107-
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
2108-
#endif
2109-
21102099
MIB_IFTABLE* table = (MIB_IFTABLE*)std::malloc(needed);
2111-
if (UNLIKELY(!table)) return false;
2100+
if (!table) return false;
21122101

21132102
if (GetIfTable(table, &needed, FALSE) != NO_ERROR) {
21142103
std::free(table);
@@ -2156,7 +2145,7 @@ struct VM {
21562145
constexpr uint32_t XEN = 0xE31600; // 00:16:E3
21572146
constexpr uint32_t PAR = 0x421C00; // 00:1C:42
21582147

2159-
if (LIKELY(prefix == VBOX)) {
2148+
if (prefix == VBOX) {
21602149
return core::add(brands::VBOX);
21612150
}
21622151
else if (prefix == VMW1 || prefix == VMW2
@@ -2171,6 +2160,9 @@ struct VM {
21712160
}
21722161

21732162
return false;
2163+
#else
2164+
return false;
2165+
#endif
21742166
}
21752167

21762168

0 commit comments

Comments
 (0)