[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 107/151: curl: use errorf() better
From: |
gnunet |
Subject: |
[gnurl] 107/151: curl: use errorf() better |
Date: |
Fri, 20 Dec 2019 14:26:56 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit c6deecd7e9ea7dd10de0934f8ec30952648aba2d
Author: Daniel Stenberg <address@hidden>
AuthorDate: Mon Dec 9 16:15:37 2019 +0100
curl: use errorf() better
Change series of error outputs to use errorf().
Only errors that are due to mistakes in command line option usage should
use helpf(), other types of errors in the tool should rather use
errorf().
Closes #4691
---
src/tool_main.c | 6 +++---
src/tool_msgs.c | 7 ++++---
src/tool_operate.c | 18 +++++++++---------
src/tool_paramhlp.c | 2 +-
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/tool_main.c b/src/tool_main.c
index 4803adbb3..06923c332 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -166,17 +166,17 @@ static CURLcode main_init(struct GlobalConfig *config)
config->first->global = config;
}
else {
- helpf(stderr, "error retrieving curl library information\n");
+ errorf(config, "error retrieving curl library information\n");
free(config->first);
}
}
else {
- helpf(stderr, "error initializing curl library\n");
+ errorf(config, "error initializing curl library\n");
free(config->first);
}
}
else {
- helpf(stderr, "error initializing curl\n");
+ errorf(config, "error initializing curl\n");
result = CURLE_FAILED_INIT;
}
diff --git a/src/tool_msgs.c b/src/tool_msgs.c
index c0e85aee6..48877b30d 100644
--- a/src/tool_msgs.c
+++ b/src/tool_msgs.c
@@ -105,9 +105,9 @@ void warnf(struct GlobalConfig *config, const char *fmt,
...)
va_end(ap);
}
/*
- * Emit help formatted message on given stream.
+ * Emit help formatted message on given stream. This is for errors with or
+ * related to command line arguments.
*/
-
void helpf(FILE *errors, const char *fmt, ...)
{
if(fmt) {
@@ -125,7 +125,8 @@ void helpf(FILE *errors, const char *fmt, ...)
}
/*
- * Emit error message on error stream if not muted.
+ * Emit error message on error stream if not muted. When errors are not tied
+ * to command line arguments, use helpf() for such errors.
*/
void errorf(struct GlobalConfig *config, const char *fmt, ...)
{
diff --git a/src/tool_operate.c b/src/tool_operate.c
index 4c9b07e39..bbd7fa49d 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -706,7 +706,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
httpgetfields = state->httpgetfields = strdup(config->postfields);
Curl_safefree(config->postfields);
if(!httpgetfields) {
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
result = CURLE_OUT_OF_MEMORY;
}
else if(SetHTTPrequest(config,
@@ -768,7 +768,7 @@ static CURLcode single_transfer(struct GlobalConfig *global,
if(urlnode->outfile && !state->outfiles) {
state->outfiles = strdup(urlnode->outfile);
if(!state->outfiles) {
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
result = CURLE_OUT_OF_MEMORY;
break;
}
@@ -796,12 +796,12 @@ static CURLcode single_transfer(struct GlobalConfig
*global,
if(inglob) {
result = glob_next_url(&state->uploadfile, inglob);
if(result == CURLE_OUT_OF_MEMORY)
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
}
else if(!state->up) {
state->uploadfile = strdup(infiles);
if(!state->uploadfile) {
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
result = CURLE_OUT_OF_MEMORY;
}
}
@@ -1030,7 +1030,7 @@ static CURLcode single_transfer(struct GlobalConfig
*global,
if(result)
break;
if(!*per->outfile && !config->content_disposition) {
- helpf(global->errors, "Remote file name has no length!\n");
+ errorf(global, "Remote file name has no length!\n");
result = CURLE_WRITE_ERROR;
break;
}
@@ -1087,7 +1087,7 @@ static CURLcode single_transfer(struct GlobalConfig
*global,
FILE *file = fopen(per->outfile, "ab");
#endif
if(!file) {
- helpf(global->errors, "Can't open '%s'!\n", per->outfile);
+ errorf(global, "Can't open '%s'!\n", per->outfile);
result = CURLE_WRITE_ERROR;
break;
}
@@ -2288,7 +2288,7 @@ static CURLcode transfer_per_config(struct GlobalConfig
*global,
config->cacert = strdup(env);
if(!config->cacert) {
curl_free(env);
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
return CURLE_OUT_OF_MEMORY;
}
}
@@ -2309,7 +2309,7 @@ static CURLcode transfer_per_config(struct GlobalConfig
*global,
config->cacert = strdup(env);
if(!config->cacert) {
curl_free(env);
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
return CURLE_OUT_OF_MEMORY;
}
}
@@ -2496,7 +2496,7 @@ CURLcode operate(struct GlobalConfig *global, int argc,
argv_item_t argv[])
#endif
}
else
- helpf(global->errors, "out of memory\n");
+ errorf(global, "out of memory\n");
}
}
diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c
index af47516b6..b7a8efbd2 100644
--- a/src/tool_paramhlp.c
+++ b/src/tool_paramhlp.c
@@ -606,7 +606,7 @@ CURLcode get_args(struct OperationConfig *config, const
size_t i)
if(!config->useragent) {
config->useragent = my_useragent();
if(!config->useragent) {
- helpf(config->global->errors, "out of memory\n");
+ errorf(config->global, "out of memory\n");
result = CURLE_OUT_OF_MEMORY;
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 85/151: configure: enable IPv6 support without `getaddrinfo`, (continued)
- [gnurl] 85/151: configure: enable IPv6 support without `getaddrinfo`, gnunet, 2019/12/20
- [gnurl] 87/151: CURLOPT_VERBOSE.3: see also ERRORBUFFER, gnunet, 2019/12/20
- [gnurl] 98/151: curl: make the etag load logic work without fseek, gnunet, 2019/12/20
- [gnurl] 103/151: winbuild: Define CARES_STATICLIB when WITH_CARES=static, gnunet, 2019/12/20
- [gnurl] 90/151: test342: make it return a 304 as the tag matches, gnunet, 2019/12/20
- [gnurl] 99/151: azure: add a vanilla macos build, gnunet, 2019/12/20
- [gnurl] 105/151: tests: fix permissions of ssh keys in WSL, gnunet, 2019/12/20
- [gnurl] 102/151: conn: always set bits.close with connclose(), gnunet, 2019/12/20
- [gnurl] 116/151: curl: improved cleanup in upload error path, gnunet, 2019/12/20
- [gnurl] 108/151: azure: add libssh2 and cmake macos builds, gnunet, 2019/12/20
- [gnurl] 107/151: curl: use errorf() better,
gnunet <=
- [gnurl] 114/151: travis: make torture use --shallow=40, gnunet, 2019/12/20
- [gnurl] 119/151: altsvc: make the save function ignore NULL filenames, gnunet, 2019/12/20
- [gnurl] 118/151: curl: fix memory leak in OOM in etags logic, gnunet, 2019/12/20
- [gnurl] 123/151: unit1609: fix mem-leak in OOM, gnunet, 2019/12/20
- [gnurl] 125/151: cirrus: Drop the FreeBSD 10.4 build, gnunet, 2019/12/20
- [gnurl] 96/151: docs: fix some typos, gnunet, 2019/12/20
- [gnurl] 94/151: lib: fix some loose ends for recently added CURLSSLOPT_NO_PARTIALCHAIN, gnunet, 2019/12/20
- [gnurl] 89/151: CMake: add support for building with the NSS vtls backend, gnunet, 2019/12/20
- [gnurl] 101/151: cirrus: enable clang sanitizers on freebsd 13, gnunet, 2019/12/20
- [gnurl] 110/151: RELEASE-NOTES: synced, gnunet, 2019/12/20