]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
servers: convert two macros to scoped static const strings
authorViktor Szakats <commit@vsz.me>
Thu, 24 Jul 2025 00:34:39 +0000 (02:34 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 29 Jul 2025 00:04:52 +0000 (02:04 +0200)
Closes #18067

tests/server/rtspd.c
tests/server/sws.c

index b6dd5ead1e0e5e04badfc45bd93b874692fc2245..d046fdf42060b67097de70cab0bd8da8979423d0 100644 (file)
@@ -716,19 +716,19 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req)
   default:
   case RCMD_NORMALREQ:
     break; /* continue with business as usual */
-  case RCMD_STREAM:
-#define STREAMTHIS "a string to stream 01234567890\n"
-    count = strlen(STREAMTHIS);
+  case RCMD_STREAM: {
+    static const char streamthis[] = "a string to stream 01234567890\n";
     for(;;) {
-      written = swrite(sock, STREAMTHIS, count);
+      written = swrite(sock, streamthis, sizeof(streamthis)-1);
       if(got_exit_signal)
         return -1;
-      if(written != (ssize_t)count) {
+      if(written != (ssize_t)(sizeof(streamthis)-1)) {
         logmsg("Stopped streaming");
         break;
       }
     }
     return -1;
+  }
   case RCMD_IDLE:
     /* Do nothing. Sit idle. Pretend it rains. */
     return 0;
index 4d43b38b1e15e27f8e3ce25e1f20c85393fd39a6..2ae4727ad6b8a780c4422b9de718cbaa4ed4ab2a 100644 (file)
@@ -959,19 +959,19 @@ static int sws_send_doc(curl_socket_t sock, struct sws_httprequest *req)
   default:
   case RCMD_NORMALREQ:
     break; /* continue with business as usual */
-  case RCMD_STREAM:
-#define STREAMTHIS "a string to stream 01234567890\n"
-    count = strlen(STREAMTHIS);
+  case RCMD_STREAM: {
+    static const char streamthis[] = "a string to stream 01234567890\n";
     for(;;) {
-      written = swrite(sock, STREAMTHIS, count);
+      written = swrite(sock, streamthis, sizeof(streamthis)-1);
       if(got_exit_signal)
         return -1;
-      if(written != (ssize_t)count) {
+      if(written != (ssize_t)(sizeof(streamthis)-1)) {
         logmsg("Stopped streaming");
         break;
       }
     }
     return -1;
+  }
   case RCMD_IDLE:
     /* Do nothing. Sit idle. Pretend it rains. */
     return 0;