Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netusb: Fix coverity ID178334 and add TCP retry count in debug #4641

Merged
merged 2 commits into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ static void tcp_retry_expired(struct k_timer *timer)
net_pkt_set_queued(pkt, true);

if (net_tcp_send_pkt(pkt) < 0 && !is_6lo_technology(pkt)) {
NET_DBG("[%p] pkt %p send failed", tcp, pkt);
NET_DBG("retry %u: [%p] pkt %p send failed",
tcp->retry_timeout_shift, tcp, pkt);
net_pkt_unref(pkt);
} else {
NET_DBG("[%p] sent pkt %p", tcp, pkt);
NET_DBG("retry %u: [%p] sent pkt %p",
tcp->retry_timeout_shift, tcp, pkt);
if (IS_ENABLED(CONFIG_NET_STATISTICS_TCP) &&
!is_6lo_technology(pkt)) {
net_stats_update_tcp_seg_rexmit();
Expand Down
43 changes: 18 additions & 25 deletions subsys/usb/class/netusb/function_ecm.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,41 +233,34 @@ int ecm_send(struct net_pkt *pkt)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message is missing

Fixes #4637
Coverity-CID: 178334

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Coverity and bug ID

u8_t send_buf[CONFIG_CDC_ECM_BULK_EP_MPS];
int remaining = sizeof(send_buf);
struct net_buf *frag;

net_hexdump_frags("<", pkt);

if (!pkt->frags) {
remaining = append_bytes(send_buf, sizeof(send_buf),
net_pkt_ll(pkt),
net_pkt_ll_reserve(pkt),
remaining);
if (remaining < 0) {
return remaining;
}
} else {
struct net_buf *frag;
return -ENODATA;
}

remaining = append_bytes(send_buf, sizeof(send_buf),
net_pkt_ll(pkt),
net_pkt_ll_reserve(pkt) +
pkt->frags->len,
remaining);
if (remaining < 0) {
return remaining;
}

for (frag = pkt->frags->frags; frag; frag = frag->frags) {
#if VERBOSE_DEBUG
SYS_LOG_DBG("Fragment %p len %u, remaining %u",
frag, frag->len, remaining);
#endif
remaining = append_bytes(send_buf, sizeof(send_buf),
net_pkt_ll(pkt),
net_pkt_ll_reserve(pkt) +
pkt->frags->len,
frag->data, frag->len,
remaining);
if (remaining < 0) {
return remaining;
}

for (frag = pkt->frags->frags; frag; frag = frag->frags) {
#if VERBOSE_DEBUG
SYS_LOG_DBG("Fragment %p len %u, remaining %u",
frag, frag->len, remaining);
#endif
remaining = append_bytes(send_buf, sizeof(send_buf),
frag->data, frag->len,
remaining);
if (remaining < 0) {
return remaining;
}
}
}

if (remaining > 0 && remaining < sizeof(send_buf)) {
Expand Down