--- /dev/null
+enable STRERROR
my %warnings_extended = (
'COPYRIGHTYEAR' => 'copyright year incorrect',
+ 'STRERROR', => 'strerror() detected',
);
my %warnings = (
'EXCLAMATIONSPACE' => 'Whitespace after exclamation mark in expression',
'EMPTYLINEBRACE' => 'Empty line before the open brace',
'EQUALSNULL' => 'if/while comparison with == NULL',
- 'NOTEQUALSZERO' => 'if/while comparison with != 0'
+ 'NOTEQUALSZERO', => 'if/while comparison with != 0',
);
sub readskiplist {
print " -i<n> Indent spaces. Default: 2\n";
print " -m<n> Maximum line length. Default: 79\n";
print "\nDetects and warns for these problems:\n";
- for(sort keys %warnings) {
- printf (" %-18s: %s\n", $_, $warnings{$_});
+ my @allw = keys %warnings;
+ push @allw, keys %warnings_extended;
+ for my $w (sort @allw) {
+ if($warnings{$w}) {
+ printf (" %-18s: %s\n", $w, $warnings{$w});
+ }
+ else {
+ printf (" %-18s: %s[*]\n", $w, $warnings_extended{$w});
+ }
}
+ print " [*] = disabled by default\n";
exit;
}
$line, length($1), $file, $ol,
"use of $2 is banned");
}
-
+ if($warnings{"STRERROR"}) {
+ # scan for use of banned strerror. This is not a BANNEDFUNC to
+ # allow for individual enable/disable of this warning.
+ if($l =~ /^(.*\W)(strerror)\s*\(/x) {
+ if($1 !~ /^ *\#/) {
+ # skip preprocessor lines
+ checkwarn("STRERROR",
+ $line, length($1), $file, $ol,
+ "use of $2 is banned");
+ }
+ }
+ }
# scan for use of snprintf for curl-internals reasons
if($l =~ /^(.*\W)(v?snprintf)\s*\(/x) {
checkwarn("SNPRINTF",
*cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST);
if(*cd == (iconv_t)-1) {
+ char buffer[STRERROR_LEN];
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST,
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
}
if(!data)
iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes)) {
+ char buffer[STRERROR_LEN];
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
#else
*cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK);
if(*cd == (iconv_t)-1) {
+ char buffer[STRERROR_LEN];
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK,
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
}
if(!data)
iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes)) {
+ char buffer[STRERROR_LEN];
failf(data,
"Curl_convert_from_network iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
#else
*cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_FOR_UTF8);
if(*cd == (iconv_t)-1) {
+ char buffer[STRERROR_LEN];
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_FOR_UTF8,
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
}
if(!data)
iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes)) {
+ char buffer[STRERROR_LEN];
failf(data,
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
- errno, strerror(errno));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return CURLE_CONV_FAILED;
}
if(output_ptr < input_ptr) {
max = buflen - 1;
*buf = '\0';
+ /* !checksrc! disable STRERROR 2 */
#if defined(WIN32) || defined(_WIN32_WCE)
#if defined(WIN32)
/* 'sys_nerr' is the maximum errno number, it is not widely portable */
#else
scopeidx = if_nametoindex(zoneid);
#endif
- if(!scopeidx)
+ if(!scopeidx) {
+ char buffer[STRERROR_LEN];
infof(data, "Invalid zoneid: %s; %s", zoneid,
- strerror(errno));
+ Curl_strerror(errno, buffer, sizeof(buffer)));
+ }
else
conn->scope_id = scopeidx;
}
static CURLcode gskit_status(struct Curl_easy *data, int rc,
const char *procname, CURLcode defcode)
{
+ char buffer[STRERROR_LEN];
/* Process GSKit status and map it to a CURLcode. */
switch(rc) {
case GSK_OK:
case ENOMEM:
return CURLE_OUT_OF_MEMORY;
default:
- failf(data, "%s I/O error: %s", procname, strerror(errno));
+ failf(data, "%s I/O error: %s", procname,
+ Curl_strerror(errno, buffer, sizeof(buffer)));
break;
}
break;
static CURLcode set_enum(struct Curl_easy *data, gsk_handle h,
GSK_ENUM_ID id, GSK_ENUM_VALUE value, bool unsupported_ok)
{
+ char buffer[STRERROR_LEN];
int rc = gsk_attribute_set_enum(h, id, value);
switch(rc) {
case GSK_OK:
return CURLE_OK;
case GSK_ERROR_IO:
- failf(data, "gsk_attribute_set_enum() I/O error: %s", strerror(errno));
+ failf(data, "gsk_attribute_set_enum() I/O error: %s",
+ Curl_strerror(errno, buffer, sizeof(buffer)));
break;
case GSK_ATTRIBUTE_INVALID_ID:
if(unsupported_ok)
static CURLcode set_buffer(struct Curl_easy *data, gsk_handle h,
GSK_BUF_ID id, const char *buffer, bool unsupported_ok)
{
+ char buffer[STRERROR_LEN];
int rc = gsk_attribute_set_buffer(h, id, buffer, 0);
switch(rc) {
case GSK_OK:
return CURLE_OK;
case GSK_ERROR_IO:
- failf(data, "gsk_attribute_set_buffer() I/O error: %s", strerror(errno));
+ failf(data, "gsk_attribute_set_buffer() I/O error: %s",
+ Curl_strerror(errno, buffer, sizeof(buffer)));
break;
case GSK_ATTRIBUTE_INVALID_ID:
if(unsupported_ok)
static CURLcode set_numeric(struct Curl_easy *data,
gsk_handle h, GSK_NUM_ID id, int value)
{
+ char buffer[STRERROR_LEN];
int rc = gsk_attribute_set_numeric_value(h, id, value);
switch(rc) {
return CURLE_OK;
case GSK_ERROR_IO:
failf(data, "gsk_attribute_set_numeric_value() I/O error: %s",
- strerror(errno));
+ Curl_strerror(errno, buffer, sizeof(buffer)));
break;
default:
failf(data, "gsk_attribute_set_numeric_value(): %s", gsk_strerror(rc));
static CURLcode set_callback(struct Curl_easy *data,
gsk_handle h, GSK_CALLBACK_ID id, void *info)
{
+ char buffer[STRERROR_LEN];
int rc = gsk_attribute_set_callback(h, id, info);
switch(rc) {
case GSK_OK:
return CURLE_OK;
case GSK_ERROR_IO:
- failf(data, "gsk_attribute_set_callback() I/O error: %s", strerror(errno));
+ failf(data, "gsk_attribute_set_callback() I/O error: %s",
+ Curl_strerror(errno, buffer, sizeof(buffer)));
break;
default:
failf(data, "gsk_attribute_set_callback(): %s", gsk_strerror(rc));
continue; /* Retry. */
}
if(errno != ETIME) {
- failf(data, "QsoWaitForIOCompletion() I/O error: %s", strerror(errno));
+ char buffer[STRERROR_LEN];
+ failf(data, "QsoWaitForIOCompletion() I/O error: %s",
+ Curl_strerror(errno, buffer, sizeof(buffer)));
cancel_async_handshake(conn, sockindex);
close_async_handshake(connssl);
return CURLE_SSL_CONNECT_ERROR;
nread = read(conn->sock[sockindex], buf, sizeof(buf));
if(nread < 0) {
- failf(data, "read: %s", strerror(errno));
+ char buffer[STRERROR_LEN];
+ failf(data, "read: %s", Curl_strerror(errno, buffer, sizeof(buffer)));
rc = -1;
}
infof(data, "sread: EAGAIN or EWOULDBLOCK");
}
else if(io_error) {
- failf(data, "reading from socket: %s", strerror(io_error));
+ char buffer[STRERROR_LEN];
+ failf(data, "reading from socket: %s",
+ Curl_strerror(io_error, buffer, sizeof(buffer)));
*err = CURLE_READ_ERROR;
return -1;
}
return -1;
}
else if(io_error) {
- failf(data, "writing to socket: %s", strerror(io_error));
+ char buffer[STRERROR_LEN];
+ failf(data, "writing to socket: %s",
+ Curl_strerror(io_error, buffer, sizeof(buffer)));
*err = CURLE_WRITE_ERROR;
return -1;
}
#include "multiif.h"
#include "strcase.h"
#include "x509asn1.h"
+#include "strerror.h"
#ifdef USE_SECTRANSP
nread = read(conn->sock[sockindex], buf, sizeof(buf));
if(nread < 0) {
- failf(data, "read: %s", strerror(errno));
+ char buffer[STRERROR_LEN];
+ failf(data, "read: %s",
+ Curl_strerror(errno, buffer, sizeof(buffer)));
rc = -1;
}