mirror of
https://github.com/curl/curl.git
synced 2026-08-13 09:00:57 +03:00
strerror: Preserve Windows error code in some functions
This is a follow-up toaf02162which removed (SET_)ERRNO macros. That commit was an earlier draft that I committed by mistake, which was then remedied bya5834e5ande909de6, and now this commit. With this commit there is now no difference between the current code and the changes that were approved in the final draft. Thanks-to: Max Dymond, Marcel Raad, Daniel Stenberg, Gisle Vanem Ref: https://github.com/curl/curl/pull/1589
This commit is contained in:
parent
e909de65b9
commit
c5e87fdb7a
6 changed files with 51 additions and 48 deletions
|
|
@ -42,7 +42,6 @@ int test(char *URL)
|
|||
int hd;
|
||||
struct_stat file_info;
|
||||
struct curl_slist *hl;
|
||||
int error;
|
||||
|
||||
struct curl_slist *headerlist=NULL;
|
||||
const char *buf_1 = "RNFR 505";
|
||||
|
|
@ -55,9 +54,8 @@ int test(char *URL)
|
|||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = errno;
|
||||
fprintf(stderr, "fopen failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||
return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */
|
||||
}
|
||||
|
|
@ -66,9 +64,8 @@ int test(char *URL)
|
|||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = errno;
|
||||
fprintf(stderr, "fstat() failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ int test(char *URL)
|
|||
CURL *curl = NULL;
|
||||
FILE *hd_src = NULL;
|
||||
int hd;
|
||||
int error;
|
||||
struct_stat file_info;
|
||||
CURLM *m = NULL;
|
||||
int running;
|
||||
|
|
@ -55,9 +54,8 @@ int test(char *URL)
|
|||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = errno;
|
||||
fprintf(stderr, "fopen failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
|
@ -66,9 +64,8 @@ int test(char *URL)
|
|||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = errno;
|
||||
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_FSTAT;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ int test(char *URL)
|
|||
FILE *hd_src;
|
||||
int hd;
|
||||
struct_stat file_info;
|
||||
int error;
|
||||
|
||||
if(!libtest_arg2) {
|
||||
fprintf(stderr, "Usage: <url> <file-to-upload>\n");
|
||||
|
|
@ -47,9 +46,8 @@ int test(char *URL)
|
|||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = errno;
|
||||
fprintf(stderr, "fopen failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "Error opening file: %s\n", libtest_arg2);
|
||||
return -2; /* if this happens things are major weird */
|
||||
}
|
||||
|
|
@ -58,9 +56,8 @@ int test(char *URL)
|
|||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = errno;
|
||||
fprintf(stderr, "fstat() failed with error: %d %s\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "ERROR: cannot open file %s\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_MAJOR_BAD;
|
||||
|
|
|
|||
|
|
@ -228,7 +228,6 @@ int test(char *URL)
|
|||
CURL *curl = NULL;
|
||||
FILE *hd_src = NULL;
|
||||
int hd;
|
||||
int error;
|
||||
struct_stat file_info;
|
||||
CURLM *m = NULL;
|
||||
struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
|
||||
|
|
@ -244,9 +243,8 @@ int test(char *URL)
|
|||
|
||||
hd_src = fopen(libtest_arg2, "rb");
|
||||
if(NULL == hd_src) {
|
||||
error = errno;
|
||||
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
|
@ -255,9 +253,8 @@ int test(char *URL)
|
|||
hd = fstat(fileno(hd_src), &file_info);
|
||||
if(hd == -1) {
|
||||
/* can't open file, bail out */
|
||||
error = errno;
|
||||
fprintf(stderr, "fstat() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "ERROR: cannot open file (%s)\n", libtest_arg2);
|
||||
fclose(hd_src);
|
||||
return TEST_ERR_FSTAT;
|
||||
|
|
|
|||
|
|
@ -44,15 +44,13 @@ int test(char *URL)
|
|||
int msgs_left;
|
||||
CURLMsg *msg;
|
||||
FILE *upload = NULL;
|
||||
int error;
|
||||
|
||||
start_test_timing();
|
||||
|
||||
upload = fopen(libtest_arg3, "rb");
|
||||
if(!upload) {
|
||||
error = errno;
|
||||
fprintf(stderr, "fopen() failed with error: %d (%s)\n",
|
||||
error, strerror(error));
|
||||
errno, strerror(errno));
|
||||
fprintf(stderr, "Error opening file: (%s)\n", libtest_arg3);
|
||||
return TEST_ERR_FOPEN;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue