Global: replaces %m for %s + strerror(errno)

Not portable

This reverts aabab6dff5
This commit is contained in:
李通洲
2026-03-26 19:54:10 +08:00
parent 397822d0db
commit bf99aeda92
6 changed files with 39 additions and 39 deletions
+13 -13
View File
@@ -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;
}