This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new f294f62 cppcheck: fixes issues found for tests in proxy/http
f294f62 is described below
commit f294f6271414b3cca109049cc29b47cfde5c5d35
Author: Randall Meyer <[email protected]>
AuthorDate: Tue Apr 23 16:10:20 2019 +0800
cppcheck: fixes issues found for tests in proxy/http
---
proxy/http/test_socket_close.cc | 15 +++++----------
proxy/http/unit_tests/test_ForwardedConfig.cc | 6 +++---
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/proxy/http/test_socket_close.cc b/proxy/http/test_socket_close.cc
index 4be9c58..4600140 100644
--- a/proxy/http/test_socket_close.cc
+++ b/proxy/http/test_socket_close.cc
@@ -93,7 +93,7 @@ struct State {
int64_t nbytes_write; // number of bytes to write
intte_t nbytes_read; // number of bytes to read
- State() : state(STATE_IDLE), tasks_count(0) {}
+ State() : state(STATE_IDLE), tasks_count(0), nbytes_write(0), {}
};
struct Conn {
@@ -241,7 +241,6 @@ state_act(Conn *c)
void
state_act_task(Conn *c)
{
- int error;
char write_ch = 'T', read_ch;
int r;
@@ -332,7 +331,6 @@ int
do_connect(Conn *from, Conn *to)
{
assert(to->listen_s > 0);
- int error;
// create a non-blocking socket
if ((from->s = create_nonblocking_socket()) < 0) {
@@ -341,7 +339,7 @@ do_connect(Conn *from, Conn *to)
}
// connect
if (connect(from->s, (struct sockaddr *)&to->addr, sizeof(to->addr)) < 0) {
- error = -errno;
+ int error = -errno;
if (error != -EINPROGRESS) {
::close(from->s);
from->state.state = STATE_ERROR;
@@ -463,11 +461,8 @@ create_nonblocking_socket()
int
set_nonblocking_socket(int s)
{
- int error = 0;
- int on = 1;
-
if (fcntl(s, F_SETFL, O_NDELAY) < 0) {
- error = -errno;
+ int error = -errno;
::close(s);
cout << "fcntl F_SETFD O_NDELAY failed (" << error << ")" << endl;
return (error);
@@ -484,7 +479,7 @@ set_nonblocking_socket(int s)
int
do_shutdown(int s, Task_t task)
{
- int howto, error;
+ int howto;
switch (task) {
case TASK_SHUTDOWN_OUTPUT:
@@ -503,7 +498,7 @@ do_shutdown(int s, Task_t task)
break;
}
if (shutdown(s, howto) < 0) {
- error = -errno;
+ int error = -errno;
cout << "shutdown failed (" << error << ")" << endl;
return (error);
}
diff --git a/proxy/http/unit_tests/test_ForwardedConfig.cc
b/proxy/http/unit_tests/test_ForwardedConfig.cc
index 72b21d6..02f2ff7 100644
--- a/proxy/http/unit_tests/test_ForwardedConfig.cc
+++ b/proxy/http/unit_tests/test_ForwardedConfig.cc
@@ -36,7 +36,7 @@ using namespace HttpForwarded;
class OptionBitSetListInit : public OptionBitSet
{
public:
- OptionBitSetListInit(std::initializer_list<std::size_t> il)
+ explicit OptionBitSetListInit(std::initializer_list<std::size_t> il)
{
for (std::size_t i : il) {
this->set(i);
@@ -68,7 +68,7 @@ private:
std::string s;
public:
- XS(const char *in) : s{nextWs()}
+ explicit XS(const char *in) : s{nextWs()}
{
bool upper{true};
for (; *in; ++in) {
@@ -92,7 +92,7 @@ public:
};
void
-test(const char *spec, const char *reqErr, OptionBitSet bS)
+test(const char *spec, const char *reqErr, const OptionBitSet &bS)
{
ts::LocalBufferWriter<1024> error;