← Commit list

f1b1919bd0

Viktor Szakats
Viktor Szakats
2026-06-14
SUCCESS Duration: 258s

Subject

servers: drop single-use interim result variables

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

tests/server/mqttd.c+9 -10
@@ -416,10 +416,10 @@ static int publish(FILE *dump,
static char topic[MAX_TOPIC_LENGTH + 1];
-static int fixedheader(curl_socket_t fd,
- unsigned char *bytep,
- size_t *remaining_lengthp,
- size_t *remaining_length_bytesp)
+static bool fixedheader(curl_socket_t fd,
+ unsigned char *bytep,
+ size_t *remaining_lengthp,
+ size_t *remaining_length_bytesp)
{
/* get the fixed header */
unsigned char buffer[10];
@@ -429,7 +429,7 @@ static int fixedheader(curl_socket_t fd,
size_t i;
if(rc < 2) {
logmsg("READ %zd bytes [SHORT!]", rc);
- return 1; /* fail */
+ return FALSE; /* fail */
}
logmsg("READ %zd bytes", rc);
loghex(buffer, rc);
@@ -442,20 +442,19 @@ static int fixedheader(curl_socket_t fd,
rc = sread(fd, &buffer[i], 1);
if(rc != 1) {
logmsg("Remaining Length broken");
- return 1;
+ return FALSE;
}
}
*remaining_lengthp = decode_length(&buffer[1], i, remaining_length_bytesp);
logmsg("Remaining Length: %zu [%zu bytes]", *remaining_lengthp,
*remaining_length_bytesp);
- return 0;
+ return TRUE;
}
static curl_socket_t mqttit(curl_socket_t fd)
{
size_t buff_size = 10 * 1024;
unsigned char *buffer = NULL;
- ssize_t rc;
unsigned char byte;
unsigned short packet_id;
size_t payload_len;
@@ -500,10 +499,10 @@ static curl_socket_t mqttit(curl_socket_t fd)
const size_t client_id_offset = 12;
size_t start_usr;
size_t start_passwd;
+ ssize_t rc = 0;
/* get the fixed header */
- rc = fixedheader(fd, &byte, &remaining_length, &bytes);
- if(rc)
+ if(!fixedheader(fd, &byte, &remaining_length, &bytes))
break;
if(remaining_length >= buff_size) {
tests/server/rtspd.c+4 -10
@@ -547,7 +547,6 @@ static int rtspd_ProcessRequest(struct rtspd_httprequest *req)
/* store the entire request in a file */
static void rtspd_storerequest(const char *reqbuf, size_t totalsize)
{
- int res;
int error = 0;
char errbuf[STRERROR_LEN];
size_t written;
@@ -595,8 +594,7 @@ static void rtspd_storerequest(const char *reqbuf, size_t totalsize)
storerequest_cleanup:
- res = curlx_fclose(dump);
- if(res)
+ if(curlx_fclose(dump))
logmsg("Error closing file %s error (%d) %s", dumpfile,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
}
@@ -730,7 +728,6 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
size_t responsesize;
int error = 0;
char errbuf[STRERROR_LEN];
- int res;
static char weare[256];
char responsedump[256];
@@ -934,8 +931,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
req->rtp_buffersize = 0;
}
- res = curlx_fclose(dump);
- if(res)
+ if(curlx_fclose(dump))
logmsg("Error closing file %s error (%d) %s", responsedump,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
@@ -970,8 +966,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
quarters = num * 4;
while((quarters > 0) && !got_exit_signal) {
quarters--;
- res = curlx_wait_ms(250);
- if(res) {
+ if(curlx_wait_ms(250)) {
/* should not happen */
int sockerr = SOCKERRNO;
logmsg("curlx_wait_ms() failed with error (%d) %s",
@@ -1201,8 +1196,7 @@ static int test_rtspd(int argc, const char *argv[])
logmsg("Running %s version on port %d", ipv_inuse, (int)port);
/* start accepting connections */
- rc = listen(sock, 5);
- if(rc) {
+ if(listen(sock, 5)) {
sockerr = SOCKERRNO;
logmsg("listen() failed with error (%d) %s",
sockerr, curlx_strerror(sockerr, errbuf, sizeof(errbuf)));
tests/server/socksd.c+1 -4
@@ -213,7 +213,6 @@ static void socksd_getconfig(void)
static curl_socket_t socksconnect(unsigned short connectport,
const char *connectaddr)
{
- int rc;
srvr_sockaddr_union_t me;
curl_socket_t sock = socket(AF_INET, SOCK_STREAM, 0);
if(sock == CURL_SOCKET_BAD)
@@ -224,9 +223,7 @@ static curl_socket_t socksconnect(unsigned short connectport,
me.sa4.sin_addr.s_addr = INADDR_ANY;
curlx_inet_pton(AF_INET, connectaddr, &me.sa4.sin_addr);
- rc = connect(sock, &me.sa, sizeof(me.sa4));
-
- if(rc) {
+ if(connect(sock, &me.sa, sizeof(me.sa4))) {
char errbuf[STRERROR_LEN];
int sockerr = SOCKERRNO;
logmsg("Failed connecting to %s:%hu (%d) %s", connectaddr, connectport,
tests/server/sws.c+4 -10
@@ -742,7 +742,6 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
/* store the entire request in a file */
static void sws_storerequest(const char *reqbuf, size_t totalsize)
{
- int res;
int error = 0;
char errbuf[STRERROR_LEN];
size_t written;
@@ -791,8 +790,7 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize)
storerequest_cleanup:
- res = curlx_fclose(dump);
- if(res)
+ if(curlx_fclose(dump))
logmsg("Error closing file %s error (%d) %s", dumpfile,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
}
@@ -813,7 +811,6 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req)
size_t responsesize;
int error = 0;
char errbuf[STRERROR_LEN];
- int res;
static char weare[256];
char responsedump[256];
@@ -1007,8 +1004,7 @@ retry:
}
} while((count > 0) && !got_exit_signal);
- res = curlx_fclose(dump);
- if(res)
+ if(curlx_fclose(dump))
logmsg("Error closing file %s error (%d) %s", responsedump,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
@@ -1045,8 +1041,7 @@ retry:
quarters = num * 4;
while((quarters > 0) && !got_exit_signal) {
quarters--;
- res = curlx_wait_ms(250);
- if(res) {
+ if(curlx_wait_ms(250)) {
/* should not happen */
int sockerr = SOCKERRNO;
logmsg("curlx_wait_ms() failed with error (%d) %s",
@@ -2261,8 +2256,7 @@ static int test_sws(int argc, const char *argv[])
protocol_type, socket_type, location_str);
/* start accepting connections */
- rc = listen(sock, 50);
- if(rc) {
+ if(listen(sock, 50)) {
sockerr = SOCKERRNO;
logmsg("listen() failed with error (%d) %s",
sockerr, curlx_strerror(sockerr, errbuf, sizeof(errbuf)));
tests/server/util.c+8 -14
@@ -230,7 +230,6 @@ void set_advisor_read_lock(const char *filename)
FILE *lockfile;
int error = 0;
char errbuf[STRERROR_LEN];
- int res;
do {
lockfile = curlx_fopen(filename, "wb");
@@ -242,8 +241,7 @@ void set_advisor_read_lock(const char *filename)
return;
}
- res = curlx_fclose(lockfile);
- if(res)
+ if(curlx_fclose(lockfile))
logmsg("Error closing lock file %s error (%d) %s", filename,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
}
@@ -698,14 +696,13 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
/* socket server is not alive, now check if it was actually a socket. */
#ifdef _WIN32
/* Windows does not have lstat function. */
- rc = curlx_stat(unix_socket, &statbuf);
+ if(curlx_stat(unix_socket, &statbuf)) {
#else
- rc = lstat(unix_socket, &statbuf);
+ if(lstat(unix_socket, &statbuf)) {
#endif
- if(rc) {
logmsg("Error binding socket, failed to stat %s (%d) %s", unix_socket,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
- return rc;
+ return -1;
}
#ifdef S_IFSOCK
if((statbuf.st_mode & S_IFSOCK) != S_IFSOCK) {
@@ -714,11 +711,10 @@ int bind_unix_socket(curl_socket_t sock, const char *unix_socket,
}
#endif
/* dead socket, cleanup and retry bind */
- rc = unlink(unix_socket);
- if(rc) {
+ if(unlink(unix_socket)) {
logmsg("Error binding socket, failed to unlink %s: %d (%s)", unix_socket,
errno, curlx_strerror(errno, errbuf, sizeof(errbuf)));
- return rc;
+ return -1;
}
/* stale socket is gone, retry bind */
rc = bind(sock, (struct sockaddr *)sau, sizeof(struct sockaddr_un));
@@ -760,8 +756,7 @@ curl_socket_t sockdaemon(curl_socket_t sock,
logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s",
sockerr, curlx_strerror(sockerr, errbuf, sizeof(errbuf)));
if(maxretr) {
- rc = curlx_wait_ms(delay);
- if(rc) {
+ if(curlx_wait_ms(delay)) {
/* should not happen */
sockerr = SOCKERRNO;
logmsg("curlx_wait_ms() failed with error (%d) %s",
@@ -886,8 +881,7 @@ curl_socket_t sockdaemon(curl_socket_t sock,
}
/* start accepting connections */
- rc = listen(sock, 5);
- if(rc) {
+ if(listen(sock, 5)) {
sockerr = SOCKERRNO;
logmsg("listen(%ld, 5) failed with error (%d) %s", (long)sock,
sockerr, curlx_strerror(sockerr, errbuf, sizeof(errbuf)));