Skip to content

Commit

Permalink
tool: remove newlines from all helpf/notef/warnf/errorf calls
Browse files Browse the repository at this point in the history
Make voutf() always add one.

Closes #11226
  • Loading branch information
bagder committed Jun 1, 2023
1 parent 4efa0b5 commit 6d45b9c
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 116 deletions.
2 changes: 1 addition & 1 deletion src/tool_cb_hdr.c
Expand Up @@ -83,7 +83,7 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
#ifdef DEBUGBUILD
if(size * nmemb > (size_t)CURL_MAX_HTTP_HEADER) {
warnf(per->config->global, "Header data exceeds single call write "
"limit!\n");
"limit!");
return CURL_WRITEFUNC_ERROR;
}
#endif
Expand Down
18 changes: 9 additions & 9 deletions src/tool_cb_wrt.c
Expand Up @@ -62,14 +62,14 @@ bool tool_create_output_file(struct OutStruct *outs,
DEBUGASSERT(config);
global = config->global;
if(!fname || !*fname) {
warnf(global, "Remote filename has no length!\n");
warnf(global, "Remote filename has no length!");
return FALSE;
}

if(config->output_dir && outs->is_cd_filename) {
aname = aprintf("%s/%s", config->output_dir, fname);
if(!aname) {
errorf(global, "out of memory\n");
errorf(global, "out of memory");
return FALSE;
}
fname = aname;
Expand All @@ -95,12 +95,12 @@ bool tool_create_output_file(struct OutStruct *outs,
/* Guard against wraparound in new filename */
if(newlen < len) {
free(aname);
errorf(global, "overflow in filename generation\n");
errorf(global, "overflow in filename generation");
return FALSE;
}
newname = malloc(newlen);
if(!newname) {
errorf(global, "out of memory\n");
errorf(global, "out of memory");
free(aname);
return FALSE;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ bool tool_create_output_file(struct OutStruct *outs,
}

if(!file) {
warnf(global, "Failed to open the file %s: %s\n", fname,
warnf(global, "Failed to open the file %s: %s", fname,
strerror(errno));
free(aname);
return FALSE;
Expand Down Expand Up @@ -176,13 +176,13 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
if(config->show_headers) {
if(bytes > (size_t)CURL_MAX_HTTP_HEADER) {
warnf(config->global, "Header data size exceeds single call write "
"limit!\n");
"limit!");
return CURL_WRITEFUNC_ERROR;
}
}
else {
if(bytes > (size_t)CURL_MAX_WRITE_SIZE) {
warnf(config->global, "Data size exceeds single call write limit!\n");
warnf(config->global, "Data size exceeds single call write limit!");
return CURL_WRITEFUNC_ERROR;
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
check_fails = TRUE;
}
if(check_fails) {
warnf(config->global, "Invalid output struct data for write callback\n");
warnf(config->global, "Invalid output struct data for write callback");
return CURL_WRITEFUNC_ERROR;
}
}
Expand All @@ -225,7 +225,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
if(memchr(buffer, 0, bytes)) {
warnf(config->global, "Binary output can mess up your terminal. "
"Use \"--output -\" to tell curl to output it to your terminal "
"anyway, or consider \"--output <FILE>\" to save to a file.\n");
"anyway, or consider \"--output <FILE>\" to save to a file.");
config->synthetic_error = TRUE;
return CURL_WRITEFUNC_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tool_easysrc.c
Expand Up @@ -186,7 +186,7 @@ void dumpeasysrc(struct GlobalConfig *config)
else
out = stdout;
if(!out)
warnf(config, "Failed to open %s to write libcurl code!\n", o);
warnf(config, "Failed to open %s to write libcurl code!", o);
else {
int i;
const char *c;
Expand Down
18 changes: 9 additions & 9 deletions src/tool_filetime.c
Expand Up @@ -55,22 +55,22 @@ curl_off_t getfiletime(const char *filename, struct GlobalConfig *global)
| ((curl_off_t)ft.dwHighDateTime) << 32;

if(converted < CURL_OFF_T_C(116444736000000000)) {
warnf(global, "Failed to get filetime: underflow\n");
warnf(global, "Failed to get filetime: underflow");
}
else {
result = (converted - CURL_OFF_T_C(116444736000000000)) / 10000000;
}
}
else {
warnf(global, "Failed to get filetime: "
"GetFileTime failed: GetLastError %u\n",
"GetFileTime failed: GetLastError %u",
(unsigned int)GetLastError());
}
CloseHandle(hfile);
}
else if(GetLastError() != ERROR_FILE_NOT_FOUND) {
warnf(global, "Failed to get filetime: "
"CreateFile failed: GetLastError %u\n",
"CreateFile failed: GetLastError %u",
(unsigned int)GetLastError());
}
#else
Expand All @@ -79,7 +79,7 @@ curl_off_t getfiletime(const char *filename, struct GlobalConfig *global)
result = (curl_off_t)statbuf.st_mtime;
}
else if(errno != ENOENT) {
warnf(global, "Failed to get filetime: %s\n", strerror(errno));
warnf(global, "Failed to get filetime: %s", strerror(errno));
}
#endif
return result;
Expand All @@ -101,7 +101,7 @@ void setfiletime(curl_off_t filetime, const char *filename,
Windows FILETIME without overflow: 30827-12-31T23:59:59. */
if(filetime > CURL_OFF_T_C(910670515199)) {
warnf(global, "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on outfile: overflow\n", filetime);
" on outfile: overflow", filetime);
curlx_unicodefree(tchar_filename);
return;
}
Expand All @@ -119,14 +119,14 @@ void setfiletime(curl_off_t filetime, const char *filename,
ft.dwHighDateTime = (DWORD)(converted >> 32);
if(!SetFileTime(hfile, NULL, &ft, &ft)) {
warnf(global, "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on outfile: SetFileTime failed: GetLastError %u\n",
" on outfile: SetFileTime failed: GetLastError %u",
filetime, (unsigned int)GetLastError());
}
CloseHandle(hfile);
}
else {
warnf(global, "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on outfile: CreateFile failed: GetLastError %u\n",
" on outfile: CreateFile failed: GetLastError %u",
filetime, (unsigned int)GetLastError());
}

Expand All @@ -136,7 +136,7 @@ void setfiletime(curl_off_t filetime, const char *filename,
times[0].tv_usec = times[1].tv_usec = 0;
if(utimes(filename, times)) {
warnf(global, "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on '%s': %s\n", filetime, filename, strerror(errno));
" on '%s': %s", filetime, filename, strerror(errno));
}

#elif defined(HAVE_UTIME)
Expand All @@ -145,7 +145,7 @@ void setfiletime(curl_off_t filetime, const char *filename,
times.modtime = (time_t)filetime;
if(utime(filename, &times)) {
warnf(global, "Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on '%s': %s\n", filetime, filename, strerror(errno));
" on '%s': %s", filetime, filename, strerror(errno));
}
#endif
}
Expand Down
30 changes: 15 additions & 15 deletions src/tool_formparse.c
Expand Up @@ -202,7 +202,7 @@ size_t tool_mime_stdin_read(char *buffer,
if(ferror(stdin)) {
/* Show error only once. */
if(sip->config) {
warnf(sip->config, "stdin: %s\n", strerror(errno));
warnf(sip->config, "stdin: %s", strerror(errno));
sip->config = NULL;
}
return CURL_READFUNC_ABORT;
Expand Down Expand Up @@ -369,7 +369,7 @@ static char *get_param_word(struct OperationConfig *config, char **str,
++ptr;
}
if(trailing_data)
warnf(config->global, "Trailing data after quoted form parameter\n");
warnf(config->global, "Trailing data after quoted form parameter");
*str = ptr;
return word_begin + 1;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ static int read_field_headers(struct OperationConfig *config,
pos++;
if(!incomment) {
if(hdrlen == sizeof(hdrbuf) - 1) {
warnf(config->global, "File %s line %d: header too long (truncated)\n",
warnf(config->global, "File %s line %d: header too long (truncated)",
filename, lineno);
c = ' ';
}
Expand Down Expand Up @@ -506,7 +506,7 @@ static int get_param_part(struct OperationConfig *config, char endchar,

/* verify that this is a fine type specifier */
if(2 != sscanf(type, "%127[^/ ]/%127[^;, \n]", type_major, type_minor)) {
warnf(config->global, "Illegally formatted content-type field!\n");
warnf(config->global, "Illegally formatted content-type field!");
curl_slist_free_all(headers);
return -1; /* illegal content-type syntax! */
}
Expand Down Expand Up @@ -558,7 +558,7 @@ static int get_param_part(struct OperationConfig *config, char endchar,
*endpos = '\0';
fp = fopen(hdrfile, FOPEN_READTEXT);
if(!fp)
warnf(config->global, "Cannot read from %s: %s\n", hdrfile,
warnf(config->global, "Cannot read from %s: %s", hdrfile,
strerror(errno));
else {
int i = read_field_headers(config, hdrfile, fp, &headers);
Expand Down Expand Up @@ -620,7 +620,7 @@ static int get_param_part(struct OperationConfig *config, char endchar,
sep = *p;
*endpos = '\0';
if(*unknown)
warnf(config->global, "skip unknown form field: %s\n", unknown);
warnf(config->global, "skip unknown form field: %s", unknown);
}
}

Expand All @@ -631,25 +631,25 @@ static int get_param_part(struct OperationConfig *config, char endchar,
if(ptype)
*ptype = type;
else if(type)
warnf(config->global, "Field content type not allowed here: %s\n", type);
warnf(config->global, "Field content type not allowed here: %s", type);

if(pfilename)
*pfilename = filename;
else if(filename)
warnf(config->global,
"Field file name not allowed here: %s\n", filename);
"Field file name not allowed here: %s", filename);

if(pencoder)
*pencoder = encoder;
else if(encoder)
warnf(config->global,
"Field encoder not allowed here: %s\n", encoder);
"Field encoder not allowed here: %s", encoder);

if(pheaders)
*pheaders = headers;
else if(headers) {
warnf(config->global,
"Field headers not allowed here: %s\n", headers->data);
"Field headers not allowed here: %s", headers->data);
curl_slist_free_all(headers);
}

Expand Down Expand Up @@ -772,7 +772,7 @@ int formparse(struct OperationConfig *config,
else if(!name && !strcmp(contp, ")") && !literal_value) {
/* Ending a multipart. */
if(*mimecurrent == *mimeroot) {
warnf(config->global, "no multipart to terminate!\n");
warnf(config->global, "no multipart to terminate!");
goto fail;
}
*mimecurrent = (*mimecurrent)->parent;
Expand Down Expand Up @@ -818,7 +818,7 @@ int formparse(struct OperationConfig *config,
libcurl. */
if(part->size > 0) {
warnf(config->global,
"error while reading standard input\n");
"error while reading standard input");
goto fail;
}
Curl_safefree(part->data);
Expand Down Expand Up @@ -855,7 +855,7 @@ int formparse(struct OperationConfig *config,
libcurl. */
if(part->size > 0) {
warnf(config->global,
"error while reading standard input\n");
"error while reading standard input");
goto fail;
}
Curl_safefree(part->data);
Expand Down Expand Up @@ -888,15 +888,15 @@ int formparse(struct OperationConfig *config,
if(sep) {
*contp = (char) sep;
warnf(config->global,
"garbage at end of field specification: %s\n", contp);
"garbage at end of field specification: %s", contp);
}
}

/* Set part name. */
SET_TOOL_MIME_PTR(part, name);
}
else {
warnf(config->global, "Illegally formatted input field!\n");
warnf(config->global, "Illegally formatted input field!");
goto fail;
}
err = 0;
Expand Down

0 comments on commit 6d45b9c

Please sign in to comment.