Skip to content

Commit

Permalink
fix compile warning in gcc-linux
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Sep 8, 2016
1 parent 9d2d003 commit 12bc138
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Expand Up @@ -5,7 +5,7 @@ AlignEscapedNewlinesLeft: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortIfStatementsOnASingleLine: true
AlwaysBreakTemplateDeclarations: true
ColumnLimit: 140
ColumnLimit: 160
CommentPragmas: ''
IndentWidth: 4
MaxEmptyLinesToKeep: 2
Expand Down
6 changes: 3 additions & 3 deletions sample/sample_echo_svr.cpp
Expand Up @@ -83,17 +83,17 @@ static int app_handle_on_msg(atapp::app &app, const atapp::app::msg_t& msg, cons

static int app_handle_on_send_fail(atapp::app &app, atapp::app::app_id_t src_pd, atapp::app::app_id_t dst_pd,
const atbus::protocol::msg &m) {
WLOGERROR("send data from %llx to %llx failed", src_pd, dst_pd);
WLOGERROR("send data from 0x%llx to 0x%llx failed", static_cast<unsigned long long>(src_pd), static_cast<unsigned long long>(dst_pd));
return 0;
}

static int app_handle_on_connected(atapp::app &app, atbus::endpoint &ep, int status) {
WLOGINFO("app %llx connected, status: %d", ep.get_id(), status);
WLOGINFO("app 0x%llx connected, status: %d", static_cast<unsigned long long>(ep.get_id()), status);
return 0;
}

static int app_handle_on_disconnected(atapp::app &app, atbus::endpoint &ep, int status) {
WLOGINFO("app %llx disconnected, status: %d", ep.get_id(), status);
WLOGINFO("app 0x%llx disconnected, status: %d", static_cast<unsigned long long>(ep.get_id()), status);
return 0;
}

Expand Down
62 changes: 33 additions & 29 deletions src/atframe/atapp.cpp
Expand Up @@ -942,12 +942,12 @@ namespace atapp {
}

int app::command_handler_stop(util::cli::callback_param params) {
WLOGINFO("app node 0x%llx run stop command", get_id());
WLOGINFO("app node 0x%llx run stop command", static_cast<unsigned long long>(get_id()));
return stop();
}

int app::command_handler_reload(util::cli::callback_param params) {
WLOGINFO("app node 0x%llx run reload command", get_id());
WLOGINFO("app node 0x%llx run reload command", static_cast<unsigned long long>(get_id()));
return reload();
}

Expand All @@ -970,12 +970,12 @@ namespace atapp {
const atbus::protocol::msg *m) {
// call failed callback if it's message transfer
if (NULL == m) {
WLOGERROR("app 0x%llx receive a send failure without message", get_id());
WLOGERROR("app 0x%llx receive a send failure without message", static_cast<unsigned long long>(get_id()));
return -1;
}

WLOGERROR("app 0x%llx receive a send failure from 0x%llx, message cmd: %d, type: %d, ret: %d, sequence: %u", get_id(),
m->head.src_bus_id, static_cast<int>(m->head.cmd), m->head.type, m->head.ret, m->head.sequence);
WLOGERROR("app 0x%llx receive a send failure from 0x%llx, message cmd: %d, type: %d, ret: %d, sequence: %u", static_cast<unsigned long long>(get_id()),
static_cast<unsigned long long>(m->head.src_bus_id), static_cast<int>(m->head.cmd), m->head.type, m->head.ret, m->head.sequence);

if ((ATBUS_CMD_DATA_TRANSFORM_REQ == m->head.cmd || ATBUS_CMD_DATA_TRANSFORM_RSP == m->head.cmd) && evt_on_send_fail_) {
return evt_on_send_fail_(std::ref(*this), m->body.forward->from, m->body.forward->to, std::cref(*m));
Expand All @@ -992,36 +992,37 @@ namespace atapp {
const char* msg = UV_EOF == errcode ? "got EOF" : "reset by peer";
if (NULL != conn) {
if (NULL != ep) {
WLOGINFO("bus node 0x%llx endpoint 0x%llx connection %s closed: %s", n.get_id(), ep->get_id(),
conn->get_address().address.c_str(), msg);
WLOGINFO("bus node 0x%llx endpoint 0x%llx connection %s closed: %s", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), conn->get_address().address.c_str(), msg);
} else {
WLOGINFO("bus node 0x%llx connection %s closed: %s", n.get_id(), conn->get_address().address.c_str(), msg);
WLOGINFO("bus node 0x%llx connection %s closed: %s", static_cast<unsigned long long>(n.get_id()), conn->get_address().address.c_str(), msg);
}

} else {
if (NULL != ep) {
WLOGINFO("bus node 0x%llx endpoint 0x%llx closed: %s", n.get_id(), ep->get_id(), msg);
WLOGINFO("bus node 0x%llx endpoint 0x%llx closed: %s", static_cast<unsigned long long>(n.get_id()), static_cast<unsigned long long>(ep->get_id()), msg);
} else {
WLOGINFO("bus node 0x%llx closed: %s", n.get_id(), msg);
WLOGINFO("bus node 0x%llx closed: %s", static_cast<unsigned long long>(n.get_id()), msg);
}
}
return 0;
}

if (NULL != conn) {
if (NULL != ep) {
WLOGERROR("bus node 0x%llx endpoint 0x%llx connection %s error, status: %d, error code: %d", n.get_id(), ep->get_id(),
conn->get_address().address.c_str(), status, errcode);
WLOGERROR("bus node 0x%llx endpoint 0x%llx connection %s error, status: %d, error code: %d", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), conn->get_address().address.c_str(), status, errcode);
} else {
WLOGERROR("bus node 0x%llx connection %s error, status: %d, error code: %d", n.get_id(), conn->get_address().address.c_str(),
status, errcode);
WLOGERROR("bus node 0x%llx connection %s error, status: %d, error code: %d", static_cast<unsigned long long>(n.get_id()),
conn->get_address().address.c_str(), status, errcode);
}

} else {
if (NULL != ep) {
WLOGERROR("bus node 0x%llx endpoint 0x%llx error, status: %d, error code: %d", n.get_id(), ep->get_id(), status, errcode);
WLOGERROR("bus node 0x%llx endpoint 0x%llx error, status: %d, error code: %d", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), status, errcode);
} else {
WLOGERROR("bus node 0x%llx error, status: %d, error code: %d", n.get_id(), status, errcode);
WLOGERROR("bus node 0x%llx error, status: %d, error code: %d", static_cast<unsigned long long>(n.get_id()), status, errcode);
}
}

Expand All @@ -1031,40 +1032,42 @@ namespace atapp {
int app::bus_evt_callback_on_reg(const atbus::node &n, const atbus::endpoint *ep, const atbus::connection *conn, int res) {
if (NULL != conn) {
if (NULL != ep) {
WLOGINFO("bus node 0x%llx endpoint 0x%llx connection %s registered, res: %d", n.get_id(), ep->get_id(),
conn->get_address().address.c_str(), res);
WLOGINFO("bus node 0x%llx endpoint 0x%llx connection %s registered, res: %d", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), conn->get_address().address.c_str(), res);
} else {
WLOGINFO("bus node 0x%llx connection %s registered, res: %d", n.get_id(), conn->get_address().address.c_str(), res);
WLOGINFO("bus node 0x%llx connection %s registered, res: %d", static_cast<unsigned long long>(n.get_id()), conn->get_address().address.c_str(), res);
}

} else {
if (NULL != ep) {
WLOGINFO("bus node 0x%llx endpoint 0x%llx registered, res: %d", n.get_id(), ep->get_id(), res);
WLOGINFO("bus node 0x%llx endpoint 0x%llx registered, res: %d", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), res);
} else {
WLOGINFO("bus node 0x%llx registered, res: %d", n.get_id(), res);
WLOGINFO("bus node 0x%llx registered, res: %d", static_cast<unsigned long long>(n.get_id()), res);
}
}

return 0;
}

int app::bus_evt_callback_on_shutdown(const atbus::node &n, int reason) {
WLOGINFO("bus node 0x%llx shutdown, reason: %d", n.get_id(), reason);
WLOGINFO("bus node 0x%llx shutdown, reason: %d", static_cast<unsigned long long>(n.get_id()), reason);
return stop();
}

int app::bus_evt_callback_on_available(const atbus::node &n, int res) {
WLOGINFO("bus node 0x%llx initialze done, res: %d", n.get_id(), res);
WLOGINFO("bus node 0x%llx initialze done, res: %d", static_cast<unsigned long long>(n.get_id()), res);
return res;
}

int app::bus_evt_callback_on_invalid_connection(const atbus::node &n, const atbus::connection *conn, int res) {
if (NULL == conn) {
WLOGERROR("bus node 0x%llx recv a invalid NULL connection , res: %d", n.get_id(), res);
WLOGERROR("bus node 0x%llx recv a invalid NULL connection , res: %d", static_cast<unsigned long long>(n.get_id()), res);
} else {
// already disconncted finished.
if (atbus::connection::state_t::DISCONNECTED != conn->get_status()) {
WLOGERROR("bus node 0x%llx make connection to %s done, res: %d", n.get_id(), conn->get_address().address.c_str(), res);
WLOGERROR("bus node 0x%llx make connection to %s done, res: %d", static_cast<unsigned long long>(n.get_id()),
conn->get_address().address.c_str(), res);
}
}
return 0;
Expand All @@ -1090,9 +1093,10 @@ namespace atapp {

int app::bus_evt_callback_on_add_endpoint(const atbus::node &n, atbus::endpoint *ep, int res) {
if (NULL == ep) {
WLOGERROR("bus node 0x%llx make connection to NULL, res: %d", n.get_id(), res);
WLOGERROR("bus node 0x%llx make connection to NULL, res: %d", static_cast<unsigned long long>(n.get_id()), res);
} else {
WLOGINFO("bus node 0x%llx make connection to 0x%llx done, res: %d", n.get_id(), ep->get_id(), res);
WLOGINFO("bus node 0x%llx make connection to 0x%llx done, res: %d", static_cast<unsigned long long>(n.get_id()),
static_cast<unsigned long long>(ep->get_id()), res);

if (evt_on_app_connected_) {
evt_on_app_connected_(std::ref(*this), std::ref(*ep), res);
Expand All @@ -1103,9 +1107,9 @@ namespace atapp {

int app::bus_evt_callback_on_remove_endpoint(const atbus::node &n, atbus::endpoint *ep, int res) {
if (NULL == ep) {
WLOGERROR("bus node 0x%llx release connection to NULL, res: %d", n.get_id(), res);
WLOGERROR("bus node 0x%llx release connection to NULL, res: %d", static_cast<unsigned long long>(n.get_id()), res);
} else {
WLOGINFO("bus node 0x%llx release connection to 0x%llx done, res: %d", n.get_id(), ep->get_id(), res);
WLOGINFO("bus node 0x%llx release connection to 0x%llx done, res: %d", static_cast<unsigned long long>(n.get_id()), static_cast<unsigned long long>(ep->get_id()), res);

if (evt_on_app_disconnected_) {
evt_on_app_disconnected_(std::ref(*this), std::ref(*ep), res);
Expand Down

0 comments on commit 12bc138

Please sign in to comment.