]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib505: tidy up slist pointer use
authorViktor Szakats <commit@vsz.me>
Mon, 1 Jun 2026 21:12:56 +0000 (23:12 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 1 Jun 2026 21:36:04 +0000 (23:36 +0200)
Bring code closer to `curl_slist_append()` man page and clarify variable
names.

Closes #21835

tests/libtest/lib505.c

index 8eaa12b154a4749edef79321c606a8d96a35386c..b618598507be75174cbf80a49260b9852ef824ed 100644 (file)
@@ -38,9 +38,8 @@ static CURLcode test_lib505(const char *URL)
   FILE *hd_src;
   int hd;
   curlx_struct_stat file_info;
-  struct curl_slist *hl;
-
-  struct curl_slist *headerlist = NULL;
+  struct curl_slist *headerlist;
+  struct curl_slist *temp;
 
   static const char *buf_1 = "RNFR 505";
   static const char *buf_2 = "RNTO 505-forreal";
@@ -92,24 +91,24 @@ static CURLcode test_lib505(const char *URL)
 
   /* build a list of commands to pass to libcurl */
 
-  hl = curl_slist_append(headerlist, buf_1);
-  if(!hl) {
+  headerlist = curl_slist_append(NULL, buf_1);
+  if(!headerlist) {
     curl_mfprintf(stderr, "curl_slist_append() failed\n");
     curl_easy_cleanup(curl);
     curl_global_cleanup();
     curlx_fclose(hd_src);
     return TEST_ERR_MAJOR_BAD;
   }
-  headerlist = curl_slist_append(hl, buf_2);
-  if(!headerlist) {
+  temp = curl_slist_append(headerlist, buf_2);
+  if(!temp) {
     curl_mfprintf(stderr, "curl_slist_append() failed\n");
-    curl_slist_free_all(hl);
+    curl_slist_free_all(headerlist);
     curl_easy_cleanup(curl);
     curl_global_cleanup();
     curlx_fclose(hd_src);
     return TEST_ERR_MAJOR_BAD;
   }
-  headerlist = hl;
+  headerlist = temp;
 
   /* enable uploading */
   test_setopt(curl, CURLOPT_UPLOAD, 1L);