mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-06 21:24:43 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -25,7 +25,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
ffListClear(results);
|
||||
}
|
||||
|
||||
FF_AUTO_FREE char* line = NULL;
|
||||
FF_AUTO_FREE char* line = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
while (getline(&line, &len, file) != -1) {
|
||||
@@ -56,7 +56,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
}
|
||||
|
||||
FF_DEBUG("Found %u DNS servers in %s", results->length, path);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
@@ -64,10 +64,10 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
FF_DEBUG("Using SystemConfiguration framework for macOS");
|
||||
|
||||
// Create a reference to the dynamic store
|
||||
FF_CFTYPE_AUTO_RELEASE SCDynamicStoreRef store = SCDynamicStoreCreate(NULL, CFSTR("fastfetch"), NULL, NULL);
|
||||
FF_CFTYPE_AUTO_RELEASE SCDynamicStoreRef store = SCDynamicStoreCreate(nullptr, CFSTR("fastfetch"), nullptr, nullptr);
|
||||
if (store) {
|
||||
// Get the network global IPv4 and IPv6 configuration
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef key = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL, kSCDynamicStoreDomainState, kSCEntNetDNS);
|
||||
FF_CFTYPE_AUTO_RELEASE CFStringRef key = SCDynamicStoreKeyCreateNetworkGlobalEntity(nullptr, kSCDynamicStoreDomainState, kSCEntNetDNS);
|
||||
if (key) {
|
||||
FF_CFTYPE_AUTO_RELEASE CFDictionaryRef dict = SCDynamicStoreCopyValue(store, key);
|
||||
if (dict) {
|
||||
@@ -77,7 +77,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
if (dnsServers) {
|
||||
FF_STRBUF_AUTO_DESTROY buffer = ffStrbufCreate();
|
||||
for (CFIndex i = 0; i < CFArrayGetCount(dnsServers); i++) {
|
||||
if (ffCfStrGetString(CFArrayGetValueAtIndex(dnsServers, i), &buffer) == NULL) {
|
||||
if (ffCfStrGetString(CFArrayGetValueAtIndex(dnsServers, i), &buffer) == nullptr) {
|
||||
// Check if the address matches our filter
|
||||
if ((ffStrbufContainC(&buffer, ':') && !(options->showType & FF_DNS_TYPE_IPV6_BIT)) ||
|
||||
(ffStrbufContainC(&buffer, '.') && !(options->showType & FF_DNS_TYPE_IPV4_BIT))) {
|
||||
@@ -97,7 +97,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
|
||||
// If we didn't find any servers, try resolv.conf as fallback
|
||||
if (results->length > 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FF_DEBUG("No DNS servers found via SystemConfiguration, trying resolv.conf");
|
||||
|
||||
@@ -28,7 +28,7 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
ffListClear(results);
|
||||
}
|
||||
|
||||
FF_AUTO_FREE char* line = NULL;
|
||||
FF_AUTO_FREE char* line = nullptr;
|
||||
size_t len = 0;
|
||||
|
||||
while (getline(&line, &len, file) != -1) {
|
||||
@@ -59,14 +59,14 @@ static const char* detectDnsFromConf(const char* path, FFDNSOptions* options, FF
|
||||
}
|
||||
|
||||
FF_DEBUG("Found %u DNS servers in %s", results->length, path);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
FF_DEBUG("Starting DNS detection");
|
||||
|
||||
const char* error = detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT RESOLV_CONF, options, results);
|
||||
if (error != NULL) {
|
||||
if (error != nullptr) {
|
||||
FF_DEBUG("Error detecting DNS: %s", error);
|
||||
return error;
|
||||
}
|
||||
@@ -79,14 +79,14 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
if (ffStrbufEqualS(firstEntry, "127.0.0.53")) {
|
||||
FF_DEBUG("Detected systemd-resolved (127.0.0.53), checking actual DNS servers");
|
||||
// Managed by systemd-resolved
|
||||
if (detectDnsFromConf("/run/systemd/resolve/resolv.conf", options, results) == NULL) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf("/run/systemd/resolve/resolv.conf", options, results) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
} else if (ffStrbufEqualS(firstEntry, "127.0.0.1")) {
|
||||
FF_DEBUG("Detected possible NetworkManager (127.0.0.1), checking actual DNS servers");
|
||||
// Managed by NetworkManager
|
||||
if (detectDnsFromConf("/var/run/NetworkManager/resolv.conf", options, results) == NULL) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf("/var/run/NetworkManager/resolv.conf", options, results) == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,20 +97,20 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
|
||||
// Try resolvconf
|
||||
FF_DEBUG("Trying resolvconf configuration");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/run/resolvconf/resolv.conf", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try dnsmasq
|
||||
FF_DEBUG("Trying dnsmasq configuration");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/dnsmasq/resolv.conf", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/dnsmasq/resolv.conf", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try openresolv
|
||||
FF_DEBUG("Trying openresolv configuration");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf.openresolv", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/resolv.conf.openresolv", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
@@ -120,24 +120,24 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
|
||||
// FreeBSD and other BSDs may use resolvconf service
|
||||
FF_DEBUG("Trying BSD resolvconf configuration");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/resolvconf/resolv.conf", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/resolvconf/resolv.conf", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Some BSDs store DNS configuration here
|
||||
FF_DEBUG("Trying BSD nameserver configuration");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/nameserver", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/var/run/nameserver", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Try common BSD paths
|
||||
FF_DEBUG("Trying BSD common paths");
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/nameserver", options, results) == NULL && results->length > 0) {
|
||||
return NULL;
|
||||
if (detectDnsFromConf(FASTFETCH_TARGET_DIR_ROOT "/etc/nameserver", options, results) == nullptr && results->length > 0) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
FF_DEBUG("DNS detection completed with %u servers found", results->length);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <iphlpapi.h>
|
||||
|
||||
const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = NULL;
|
||||
IP_ADAPTER_ADDRESSES* FF_AUTO_FREE adapter_addresses = nullptr;
|
||||
|
||||
// Multiple attempts in case interfaces change while
|
||||
// we are in the middle of querying them.
|
||||
@@ -22,7 +22,7 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
? options->showType & FF_DNS_TYPE_IPV6_BIT ? AF_UNSPEC : AF_INET
|
||||
: AF_INET6,
|
||||
GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_FRIENDLY_NAME,
|
||||
NULL,
|
||||
nullptr,
|
||||
adapter_addresses,
|
||||
&adapter_addresses_buffer_size);
|
||||
|
||||
@@ -59,5 +59,5 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user