Imported Upstream version 7.59.0
[platform/upstream/curl.git] / tests / libtest / lib537.c
index 6d7c3e4..bdc2e62 100644 (file)
@@ -27,9 +27,7 @@
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
-#ifdef HAVE_LIMITS_H
 #include <limits.h>
-#endif
 
 #include "warnless.h"
 #include "memdebug.h"
@@ -87,7 +85,7 @@ static int fopen_works(void)
   for(i = 0; i < 3; i++) {
     fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT);
     if(fpa[i] == NULL) {
-      store_errmsg("fopen failed", ERRNO);
+      store_errmsg("fopen failed", errno);
       fprintf(stderr, "%s\n", msgbuff);
       ret = 0;
       break;
@@ -103,7 +101,7 @@ static int fopen_works(void)
 static int rlimit(int keep_open)
 {
   int *tmpfd;
-  int nitems, i;
+  rlim_t nitems, i;
   int *memchunk = NULL;
   char *fmt;
   struct rlimit rl;
@@ -123,7 +121,7 @@ static int rlimit(int keep_open)
   /* get initial open file limits */
 
   if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
-    store_errmsg("getrlimit() failed", ERRNO);
+    store_errmsg("getrlimit() failed", errno);
     fprintf(stderr, "%s\n", msgbuff);
     return -1;
   }
@@ -164,7 +162,7 @@ static int rlimit(int keep_open)
       rl.rlim_cur = OPEN_MAX;
       if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
         /* on failure don't abort just issue a warning */
-        store_errmsg("setrlimit() failed", ERRNO);
+        store_errmsg("setrlimit() failed", errno);
         fprintf(stderr, "%s\n", msgbuff);
         msgbuff[0] = '\0';
       }
@@ -175,7 +173,7 @@ static int rlimit(int keep_open)
     rl.rlim_cur = rl.rlim_max;
     if(setrlimit(RLIMIT_NOFILE, &rl) != 0) {
       /* on failure don't abort just issue a warning */
-      store_errmsg("setrlimit() failed", ERRNO);
+      store_errmsg("setrlimit() failed", errno);
       fprintf(stderr, "%s\n", msgbuff);
       msgbuff[0] = '\0';
     }
@@ -183,7 +181,7 @@ static int rlimit(int keep_open)
     /* get current open file limits */
 
     if(getrlimit(RLIMIT_NOFILE, &rl) != 0) {
-      store_errmsg("getrlimit() failed", ERRNO);
+      store_errmsg("getrlimit() failed", errno);
       fprintf(stderr, "%s\n", msgbuff);
       return -3;
     }
@@ -232,7 +230,7 @@ static int rlimit(int keep_open)
   if(nitems > 0x7fff)
     nitems = 0x40000;
   do {
-    num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
+    num_open.rlim_max = sizeof(*memchunk) * nitems;
     snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max);
     fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
     memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
@@ -242,7 +240,7 @@ static int rlimit(int keep_open)
     }
   } while(nitems && !memchunk);
   if(!memchunk) {
-    store_errmsg("memchunk, malloc() failed", ERRNO);
+    store_errmsg("memchunk, malloc() failed", errno);
     fprintf(stderr, "%s\n", msgbuff);
     return -4;
   }
@@ -297,7 +295,7 @@ static int rlimit(int keep_open)
     }
   } while(num_open.rlim_max && !fd);
   if(!fd) {
-    store_errmsg("fd, malloc() failed", ERRNO);
+    store_errmsg("fd, malloc() failed", errno);
     fprintf(stderr, "%s\n", msgbuff);
     free(memchunk);
     return -6;
@@ -320,7 +318,7 @@ static int rlimit(int keep_open)
   fd[0] = open(DEV_NULL, O_RDONLY);
   if(fd[0] < 0) {
     snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
-    store_errmsg(strbuff, ERRNO);
+    store_errmsg(strbuff, errno);
     fprintf(stderr, "%s\n", msgbuff);
     free(fd);
     fd = NULL;