mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -16,11 +16,11 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
|
||||
const char* ffDetectWifi(FFlist* result) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, NULL })) {
|
||||
if (ffProcessAppendStdOut(&buffer, (char* const[]) { FF_TERMUX_API_PATH, FF_TERMUX_API_PARAM, nullptr })) {
|
||||
return "Starting `" FF_TERMUX_API_PATH " " FF_TERMUX_API_PARAM "` failed";
|
||||
}
|
||||
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, NULL, NULL);
|
||||
yyjson_doc* FF_A_CLEANUP(wrapYyjsonFree) doc = yyjson_read_opts(buffer.chars, buffer.length, 0, nullptr, nullptr);
|
||||
if (!doc) {
|
||||
return "Failed to parse wifi connection info";
|
||||
}
|
||||
@@ -47,11 +47,11 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
ffStrbufAppendJsonVal(&item->inf.status, yyjson_obj_get(root, "supplicant_state"));
|
||||
if (!item->inf.status.length) {
|
||||
ffStrbufAppendS(&item->inf.status, "Unknown");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ffStrbufEqualS(&item->inf.status, "COMPLETED")) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
double rssi = yyjson_get_num(yyjson_obj_get(root, "rssi"));
|
||||
@@ -65,5 +65,5 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
item->conn.txRate = yyjson_get_num(yyjson_obj_get(root, "link_speed_mbps"));
|
||||
item->conn.channel = ffWifiFreqToChannel(item->conn.frequency);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -161,5 +161,5 @@ const char* ffDetectWifi(FFlist* result)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
return "socket() failed";
|
||||
}
|
||||
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) {
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) {
|
||||
if (!ffStrStartsWith(i->if_name, "wlan")) {
|
||||
continue;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
ireq.i_type = IEEE80211_IOC_AUTHMODE;
|
||||
ireq.i_data = NULL;
|
||||
ireq.i_data = nullptr;
|
||||
ireq.i_len = 0;
|
||||
if (ioctl(sock, SIOCG80211, &ireq) >= 0) {
|
||||
switch (ireq.i_val) {
|
||||
@@ -159,5 +159,5 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
if_freenameindex(infs);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static const struct nlattr* ffWifiNlAttrNext(const struct nlattr* attr, size_t*
|
||||
size_t alignedLen = NLA_ALIGN(attr->nla_len);
|
||||
if (alignedLen > *remaining) {
|
||||
*remaining = 0;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
*remaining -= alignedLen;
|
||||
@@ -131,7 +131,7 @@ static bool ffWifiNlGetFamilyId(FFWifiNlContext* ctx) {
|
||||
|
||||
uint8_t buffer[8192];
|
||||
while (true) {
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL);
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr);
|
||||
if (received < 0) {
|
||||
FF_DEBUG("Failed to receive nl80211 family reply: %s", strerror(errno));
|
||||
return false;
|
||||
@@ -502,7 +502,7 @@ static bool ffWifiFetchScanInfo(FFWifiNlContext* ctx, FFWifiResult* item, uint32
|
||||
|
||||
uint8_t buffer[1024 * 16];
|
||||
while (true) {
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL);
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr);
|
||||
if (received < 0) {
|
||||
FF_DEBUG("Failed to receive nl80211 scan reply: %s", strerror(errno));
|
||||
return false;
|
||||
@@ -617,7 +617,7 @@ static bool ffWifiFetchStationInfo(FFWifiNlContext* ctx, FFWifiResult* item, uin
|
||||
uint8_t buffer[8192];
|
||||
bool gotStation = false;
|
||||
while (true) {
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, NULL, NULL);
|
||||
ssize_t received = recvfrom(ctx->sockFd, buffer, sizeof(buffer), 0, nullptr, nullptr);
|
||||
if (received < 0) {
|
||||
FF_DEBUG("Failed to receive nl80211 station reply: %s", strerror(errno));
|
||||
return gotStation;
|
||||
@@ -690,7 +690,7 @@ static const char* detectWithNetlink(FFWifiNlContext* ctx, FFWifiResult* item, u
|
||||
}
|
||||
|
||||
FF_DEBUG("Netlink wifi detection completed");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -884,7 +884,7 @@ static const char* detectWithIoctl(FFWifiIcContext* ctx, FFWifiResult* item, cha
|
||||
}
|
||||
|
||||
FF_DEBUG("Ioctl wifi detection completed");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectWifi(FFlist* result) {
|
||||
@@ -903,7 +903,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) {
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) {
|
||||
FF_DEBUG("Checking interface: %s (index: %u)", i->if_name, i->if_index);
|
||||
ffStrbufSetF(&buffer, "/sys/class/net/%s/phy80211/", i->if_name);
|
||||
if (!ffPathExists(buffer.chars, FF_PATHTYPE_DIRECTORY)) {
|
||||
@@ -952,7 +952,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
flags[len] = '\0';
|
||||
|
||||
unsigned flagsVal = (unsigned) strtoul(flags, NULL, 16); // parse /sys flags as hexadecimal
|
||||
unsigned flagsVal = (unsigned) strtoul(flags, nullptr, 16); // parse /sys flags as hexadecimal
|
||||
if (flagsVal & IFF_UP) {
|
||||
ffStrbufSetStatic(&item->inf.status, "up");
|
||||
} else {
|
||||
@@ -972,5 +972,5 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
FF_DEBUG("Wifi detection completed, found %u wifi interfaces", result->length);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
return "socket() failed";
|
||||
}
|
||||
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) {
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) {
|
||||
if (!ffStrStartsWith(i->if_name, "iwm")) {
|
||||
continue;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
ireq.i_type = IEEE80211_IOC_AUTHMODE;
|
||||
ireq.i_data = NULL;
|
||||
ireq.i_data = nullptr;
|
||||
ireq.i_len = 0;
|
||||
if (ioctl(sock, SIOCG80211, &ireq) >= 0) {
|
||||
switch (ireq.i_val) {
|
||||
@@ -164,5 +164,5 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
if_freenameindex(infs);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
return "socket() failed";
|
||||
}
|
||||
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == NULL); ++i) {
|
||||
for (struct if_nameindex* i = infs; !(i->if_index == 0 && i->if_name == nullptr); ++i) {
|
||||
if (!ffStrStartsWith(i->if_name, "iwm")) {
|
||||
continue;
|
||||
}
|
||||
@@ -105,5 +105,5 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
}
|
||||
|
||||
if_freenameindex(infs);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -50,16 +50,16 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanGetNetworkBssList)
|
||||
|
||||
DWORD curVersion;
|
||||
HANDLE hClient = NULL;
|
||||
WLAN_INTERFACE_INFO_LIST* ifList = NULL;
|
||||
const char* error = NULL;
|
||||
HANDLE hClient = nullptr;
|
||||
WLAN_INTERFACE_INFO_LIST* ifList = nullptr;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (ffWlanOpenHandle(2, NULL, &curVersion, &hClient) != ERROR_SUCCESS) {
|
||||
if (ffWlanOpenHandle(2, nullptr, &curVersion, &hClient) != ERROR_SUCCESS) {
|
||||
error = "WlanOpenHandle() failed";
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (ffWlanEnumInterfaces(hClient, NULL, &ifList) != ERROR_SUCCESS) {
|
||||
if (ffWlanEnumInterfaces(hClient, nullptr, &ifList) != ERROR_SUCCESS) {
|
||||
error = "WlanEnumInterfaces() failed";
|
||||
goto exit;
|
||||
}
|
||||
@@ -87,14 +87,14 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
WLAN_CONNECTION_ATTRIBUTES* connInfo = NULL;
|
||||
WLAN_CONNECTION_ATTRIBUTES* connInfo = nullptr;
|
||||
DWORD bufSize = sizeof(*connInfo);
|
||||
WLAN_OPCODE_VALUE_TYPE opCode = wlan_opcode_value_type_query_only;
|
||||
|
||||
if (ffWlanQueryInterface(hClient,
|
||||
&ifInfo->InterfaceGuid,
|
||||
wlan_intf_opcode_current_connection,
|
||||
NULL,
|
||||
nullptr,
|
||||
&bufSize,
|
||||
(PVOID*) &connInfo,
|
||||
&opCode) != ERROR_SUCCESS) {
|
||||
@@ -200,13 +200,13 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
ffStrbufAppendS(&item->conn.security, "Insecure");
|
||||
}
|
||||
|
||||
WLAN_BSS_LIST* bssList = NULL;
|
||||
WLAN_BSS_LIST* bssList = nullptr;
|
||||
if (ffWlanGetNetworkBssList(hClient,
|
||||
&ifInfo->InterfaceGuid,
|
||||
&connInfo->wlanAssociationAttributes.dot11Ssid,
|
||||
connInfo->wlanAssociationAttributes.dot11BssType,
|
||||
connInfo->wlanSecurityAttributes.bSecurityEnabled,
|
||||
NULL,
|
||||
nullptr,
|
||||
&bssList) == ERROR_SUCCESS &&
|
||||
bssList->dwNumberOfItems > 0) {
|
||||
item->conn.frequency = (uint16_t) (bssList->wlanBssEntries[0].ulChCenterFrequency / 1000);
|
||||
@@ -220,7 +220,7 @@ const char* ffDetectWifi(FFlist* result) {
|
||||
if (ffWlanQueryInterface(hClient,
|
||||
&ifInfo->InterfaceGuid,
|
||||
wlan_intf_opcode_channel_number,
|
||||
NULL,
|
||||
nullptr,
|
||||
&bufSize,
|
||||
(PVOID*) &channelNumber,
|
||||
&opCode) == ERROR_SUCCESS) {
|
||||
@@ -234,7 +234,7 @@ exit:
|
||||
ffWlanFreeMemory(ifList);
|
||||
}
|
||||
if (hClient) {
|
||||
ffWlanCloseHandle(hClient, NULL);
|
||||
ffWlanCloseHandle(hClient, nullptr);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user