arduino / arduino/ArduinoCore-renesas

lwipClient::write() returns 0 on failure instead of number of bytes written

Open
#511 0 comments 0 reactions 0 assignees Claimed by @andreagilardoni View on GitHub
topic: code type: imperfection
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

When `lwipClient::write()` encounters an error from `tcp_write()` or `tcp_output()`, it returns 0. In contrast, `Print::write()`, which it overrides, as well as `EthernetClient::write()` from the Ethernet library, both return the number of bytes written, which may or may not be 0.

This can be easily changed by returning `bytes_sent` instead of 0 in each return statement (e.g. [36a9775](https://github.com/iofarm/ArduinoCore-renesas/commit/36a97754dec70e9454a7240b911b720b6d9dff72)); however this assumes that an error from `tcp_write()` indicates that no bytes have been written to the `pcb` send buffer, and I don't know if that assumption is correct.

PR #234 appears to fix this issue.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at lwipClient::write() and compare its tcp_write() and tcp_output() error paths with Print::write() and EthernetClient::write(). Review PR #234 and verify whether tcp_write() failures can leave bytes in the pcb send buffer; done when the return values match the intended bytes-written contract.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.