Skip to content

AP_HAL_SITL: avoid calling fcntl on -1 - #33170

Merged
peterbarker merged 1 commit into
ArduPilot:masterfrom
peterbarker:pr-claude/fcntl-on--1
Aug 7, 2026
Merged

AP_HAL_SITL: avoid calling fcntl on -1#33170
peterbarker merged 1 commit into
ArduPilot:masterfrom
peterbarker:pr-claude/fcntl-on--1

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Stops SITL calling fcntl on an invalid file descriptor. Shuts valgrind up about it.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

in-line the method to make setting non-blocking on _fd more proximate to where the thing is opened

@khancyr khancyr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

well, that is still wrong.
we should remove this.
only uart need it and it is already set on _uart_start_connection
socket shouldn't need it and calling it on begin is useless for them as they build the fd after.
Only left the _console that shouldn't set it either.
So we should remove this

Comment thread libraries/AP_HAL_SITL/UARTDriver.cpp Outdated
Comment on lines +204 to +208
// _fd may be -1 for device types that don't open an fd above
if (_fd != -1) {
unsigned v = fcntl(_fd, F_GETFL, 0);
fcntl(_fd, F_SETFL, v | O_NONBLOCK);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// _fd may be -1 for device types that don't open an fd above
if (_fd != -1) {
unsigned v = fcntl(_fd, F_GETFL, 0);
fcntl(_fd, F_SETFL, v | O_NONBLOCK);
}

remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed it.

in-line the method to make setting non-blocking on _fd more proximate to where the thing is opened

@khancyr khancyr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@peterbarker
peterbarker merged commit b65870f into ArduPilot:master Aug 7, 2026
53 checks passed
@github-project-automation github-project-automation Bot moved this from ReadyForDevCall to Done in Peter's ArduPilot 4.8 Queue Aug 7, 2026
@peterbarker
peterbarker deleted the pr-claude/fcntl-on--1 branch August 8, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants