mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Global: replaces %m for %s + strerror(errno)
Not portable
This reverts aabab6dff5
This commit is contained in:
@@ -14,7 +14,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result)
|
||||
FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
|
||||
if (sock_fd < 0)
|
||||
{
|
||||
FF_DEBUG("Failed to create netlink socket: %m");
|
||||
FF_DEBUG("Failed to create netlink socket: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Created netlink socket: fd=%d", sock_fd);
|
||||
@@ -30,7 +30,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result)
|
||||
};
|
||||
|
||||
if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
FF_DEBUG("Failed to bind socket: %m");
|
||||
FF_DEBUG("Failed to bind socket: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Successfully bound socket");
|
||||
@@ -97,7 +97,7 @@ bool ffNetifGetDefaultRouteImplV4(FFNetifDefaultRouteResult* result)
|
||||
(struct sockaddr*)&src_addr, &src_addr_len);
|
||||
|
||||
if (received < 0) {
|
||||
FF_DEBUG("Failed to receive netlink response: %m");
|
||||
FF_DEBUG("Failed to receive netlink response: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result)
|
||||
FF_AUTO_CLOSE_FD int sock_fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
|
||||
if (sock_fd < 0)
|
||||
{
|
||||
FF_DEBUG("Failed to create netlink socket: %m");
|
||||
FF_DEBUG("Failed to create netlink socket: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Created netlink socket: fd=%d", sock_fd);
|
||||
@@ -246,7 +246,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result)
|
||||
};
|
||||
|
||||
if (bind(sock_fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
FF_DEBUG("Failed to bind socket: %m");
|
||||
FF_DEBUG("Failed to bind socket: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
FF_DEBUG("Successfully bound socket");
|
||||
@@ -313,7 +313,7 @@ bool ffNetifGetDefaultRouteImplV6(FFNetifDefaultRouteResult* result)
|
||||
(struct sockaddr*)&src_addr, &src_addr_len);
|
||||
|
||||
if (received < 0) {
|
||||
FF_DEBUG("Failed to receive netlink response: %m");
|
||||
FF_DEBUG("Failed to receive netlink response: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
|
||||
TCP_FASTOPEN
|
||||
#endif
|
||||
, &flag, sizeof(flag)) != 0) {
|
||||
FF_DEBUG("Failed to set TCP_FASTOPEN option: %m");
|
||||
FF_DEBUG("Failed to set TCP_FASTOPEN option: %s", strerror(errno));
|
||||
return "setsockopt(TCP_FASTOPEN) failed";
|
||||
} else {
|
||||
#if __linux__ || __GNU__
|
||||
@@ -73,7 +73,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
|
||||
state->addr->ai_addrlen);
|
||||
#else
|
||||
if (fcntl(state->sockfd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %m");
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
|
||||
return "fcntl(F_SETFL) failed";
|
||||
}
|
||||
FF_DEBUG("Using connectx() to send %u bytes of data", state->command.length);
|
||||
@@ -90,7 +90,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
|
||||
.iov_len = state->command.length,
|
||||
}, 1, &sent, NULL) != 0) sent = 0;
|
||||
if (fcntl(state->sockfd, F_SETFL, 0) == -1) {
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %m");
|
||||
FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno));
|
||||
return "fcntl(F_SETFL) failed";
|
||||
}
|
||||
#endif
|
||||
@@ -108,7 +108,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
|
||||
#else
|
||||
"sendto()"
|
||||
#endif
|
||||
" %s (sent=%zd, %m)", errno == 0 ? "succeeded" : "was in progress", sent);
|
||||
" %s (sent=%zd, %s)", errno == 0 ? "succeeded" : "was in progress", sent, strerror(errno));
|
||||
freeaddrinfo(state->addr);
|
||||
state->addr = NULL;
|
||||
ffStrbufDestroy(&state->command);
|
||||
@@ -121,7 +121,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state)
|
||||
#else
|
||||
"sendto()"
|
||||
#endif
|
||||
" failed: %m");
|
||||
" failed: %s", strerror(errno));
|
||||
#ifdef __APPLE__
|
||||
return "connectx() failed";
|
||||
#else
|
||||
@@ -142,7 +142,7 @@ static const char* connectAndSend(FFNetworkingState* state)
|
||||
FF_DEBUG("Attempting connect() to server...");
|
||||
if(connect(state->sockfd, state->addr->ai_addr, state->addr->ai_addrlen) == -1)
|
||||
{
|
||||
FF_DEBUG("connect() failed: %m");
|
||||
FF_DEBUG("connect() failed: %s", strerror(errno));
|
||||
ret = "connect() failed";
|
||||
goto error;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ static const char* connectAndSend(FFNetworkingState* state)
|
||||
FF_DEBUG("Attempting to send %u bytes of data...", state->command.length);
|
||||
if(send(state->sockfd, state->command.chars, state->command.length, 0) < 0)
|
||||
{
|
||||
FF_DEBUG("send() failed: %m");
|
||||
FF_DEBUG("send() failed: %s", strerror(errno));
|
||||
ret = "send() failed";
|
||||
goto error;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
|
||||
state->sockfd = socket(state->addr->ai_family, state->addr->ai_socktype, state->addr->ai_protocol);
|
||||
if(state->sockfd == -1)
|
||||
{
|
||||
FF_DEBUG("socket() failed: %m");
|
||||
FF_DEBUG("socket() failed: %s", strerror(errno));
|
||||
ret = "socket() failed";
|
||||
goto error;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
|
||||
#ifdef TCP_NODELAY
|
||||
// Disable Nagle's algorithm to reduce small packet transmission delay
|
||||
if (setsockopt(state->sockfd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)) != 0) {
|
||||
FF_DEBUG("Failed to set TCP_NODELAY: %m");
|
||||
FF_DEBUG("Failed to set TCP_NODELAY: %s", strerror(errno));
|
||||
} else {
|
||||
FF_DEBUG("Successfully disabled Nagle's algorithm");
|
||||
}
|
||||
@@ -245,7 +245,7 @@ static const char* initNetworkingState(FFNetworkingState* state, const char* hos
|
||||
#ifdef TCP_QUICKACK
|
||||
// Set TCP_QUICKACK option to avoid delayed acknowledgments
|
||||
if (setsockopt(state->sockfd, IPPROTO_TCP, TCP_QUICKACK, &flag, sizeof(flag)) != 0) {
|
||||
FF_DEBUG("Failed to set TCP_QUICKACK: %m");
|
||||
FF_DEBUG("Failed to set TCP_QUICKACK: %s", strerror(errno));
|
||||
} else {
|
||||
FF_DEBUG("Successfully enabled TCP quick acknowledgment");
|
||||
}
|
||||
@@ -398,7 +398,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
}
|
||||
else if (pollRes == -1)
|
||||
{
|
||||
FF_DEBUG("poll() failed: %m");
|
||||
FF_DEBUG("poll() failed: %s", strerror(errno));
|
||||
close(state->sockfd);
|
||||
state->sockfd = -1;
|
||||
return "poll() failed";
|
||||
@@ -418,7 +418,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
|
||||
if (shutdown(state->sockfd, SHUT_WR) == -1)
|
||||
{
|
||||
FF_DEBUG("Failed to shutdown socket send: %m");
|
||||
FF_DEBUG("Failed to shutdown socket send: %s", strerror(errno));
|
||||
// Not a critical error, continue anyway
|
||||
}
|
||||
|
||||
@@ -439,7 +439,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
|
||||
if (received == 0) {
|
||||
FF_DEBUG("Connection closed (received=0)");
|
||||
} else {
|
||||
FF_DEBUG("Reception failed: %m");
|
||||
FF_DEBUG("Reception failed: %s", strerror(errno));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
|
||||
FF_AUTO_CLOSE_FD int fd = open("/dev/mem", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("Failed to open /dev/mem: %m");
|
||||
FF_DEBUG("Failed to open /dev/mem: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("/dev/mem opened successfully with fd=%d", fd);
|
||||
@@ -301,7 +301,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
// https://stackoverflow.com/questions/69372330/how-to-read-dev-mem-using-read
|
||||
void* p = mmap(NULL, sizeof(entryPoint), PROT_READ, MAP_SHARED, fd, entryAddress);
|
||||
if (p == MAP_FAILED) {
|
||||
FF_DEBUG("mmap failed: %m");
|
||||
FF_DEBUG("mmap failed: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
memcpy(&entryPoint, p, sizeof(entryPoint));
|
||||
@@ -322,7 +322,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
|
||||
FF_AUTO_CLOSE_FD int fd = open("/dev/smbios", O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("Failed to open /dev/smbios: %m");
|
||||
FF_DEBUG("Failed to open /dev/smbios: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("/dev/smbios opened successfully with fd=%d", fd);
|
||||
@@ -337,14 +337,14 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
FF_DEBUG("Got SMBIOS address from sysctl: 0x%lx", (unsigned long)addr);
|
||||
|
||||
if (pread(fd, &entryPoint, sizeof(entryPoint), addr) < 1) {
|
||||
FF_DEBUG("Failed to read SMBIOS entry point: %m");
|
||||
FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("Successfully read SMBIOS entry point");
|
||||
#else
|
||||
FF_DEBUG("Reading SMBIOS entry point from /dev/smbios");
|
||||
if (ffReadFDData(fd, sizeof(entryPoint), &entryPoint) < 1) {
|
||||
FF_DEBUG("Failed to read SMBIOS entry point: %m");
|
||||
FF_DEBUG("Failed to read SMBIOS entry point: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("Successfully read SMBIOS entry point");
|
||||
@@ -402,7 +402,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
void* p = mmap(NULL, tableLength, PROT_READ, MAP_SHARED, fd, tableAddress);
|
||||
if (p == MAP_FAILED)
|
||||
{
|
||||
FF_DEBUG("mmap failed: %m");
|
||||
FF_DEBUG("mmap failed: %s", strerror(errno));
|
||||
ffStrbufDestroy(&buffer); // free buffer and reset state
|
||||
return NULL;
|
||||
}
|
||||
@@ -431,7 +431,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
#endif
|
||||
, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
FF_DEBUG("Failed to open memory device: %m");
|
||||
FF_DEBUG("Failed to open memory device: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("Memory device opened successfully with fd=%d", fd);
|
||||
@@ -443,7 +443,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
// which is not available via EFIIOC_GET_TABLE.
|
||||
FF_AUTO_FREE uint8_t* smBiosBase = malloc(0x10000);
|
||||
if (pread(fd, smBiosBase, 0x10000, 0xF0000) != 0x10000) {
|
||||
FF_DEBUG("Failed to read SMBIOS memory region: %m");
|
||||
FF_DEBUG("Failed to read SMBIOS memory region: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
FF_DEBUG("Successfully read 0x10000 bytes from physical address 0xF0000");
|
||||
@@ -496,7 +496,7 @@ const FFSmbiosHeaderTable* ffGetSmbiosHeaderTable()
|
||||
FF_DEBUG("Successfully read SMBIOS table data: %u bytes", tableLength);
|
||||
}
|
||||
else {
|
||||
FF_DEBUG("Failed to read SMBIOS table data: %m");
|
||||
FF_DEBUG("Failed to read SMBIOS table data: %s", strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user