Skip to content

LwipClient - operator bool fix #208

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

Merged
merged 2 commits into from
Dec 20, 2023
Merged

Conversation

JAndrassy
Copy link
Contributor

@JAndrassy JAndrassy commented Dec 14, 2023

op bool should return false only for a 'null' client. a closed client may still have data to read. a Client returned from Server.available() should not fail on the usual bool test if it is closed but has data available.

in 'Arduino language' which doesn't use pointers or references, an empty Client with operator bool returning false is used instead of a NULL pointer.

Implementations of Client operator bool in other libraries:
the WiFiNINA library

WiFiClient::operator bool() {
  return _sock != 255;
}

the classic Ethernet library

virtual operator bool() { return _sockindex < MAX_SOCK_NUM; }

the MbedCore base class for WiFiClient and EthernetClient

  operator bool() {
    return sock != nullptr;
  }

op bool should return false only for a 'null' client. a closed client
may still have data to read.
a Client returned from Server.available() should not fail on usual bool
test if it has data available.
@JAndrassy JAndrassy changed the title LwipClient - op bool fix LwipClient - operator bool fix Dec 16, 2023
Copy link
Contributor

@aentinger aentinger left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@aentinger aentinger merged commit 6c6edcf into arduino:main Dec 20, 2023
@JAndrassy JAndrassy deleted the lwipclient_bool_fix branch December 20, 2023 08:52
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants