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

Return 0 space instead of -EINVAL when there are no readers #28

Merged
merged 2 commits into from
Aug 5, 2022

Conversation

klogg
Copy link
Contributor

@klogg klogg commented Nov 12, 2020

Actually no errors are suppressed here. Returning 0 is more correct in this case because -EINVAL would mean there is some invalid value passed on write, which is not true - write request itself is totally fine; returning 0 means no data was successfully written, which is true because there is no reader to consume.

NOTE: this is a split of #26

@klogg klogg mentioned this pull request Nov 12, 2020
@stappersg
Copy link
Collaborator

We are getting closer.

to be continued

@klogg
Copy link
Contributor Author

klogg commented Nov 13, 2020

We are getting closer.
to be continued

Didn't get this comment.

@klogg klogg closed this Nov 13, 2020
@klogg klogg reopened this Nov 13, 2020
@stappersg
Copy link
Collaborator

#30 and #31 do obsolete this pull request.

@klogg
Copy link
Contributor Author

klogg commented Jan 6, 2021

#30 and #31 do obsolete this pull request.

Disagree. You are still returning error which is incorrect in case of 'write'

@daniel-starke
Copy link

-ENODEV is also not allowed here. See torvalds/linux@6bfbfcf

@klogg
Copy link
Contributor Author

klogg commented Nov 8, 2021

Rebased to master.
@jbuchbinder this patch still valid.
@stappersg please see comment from @daniel-starke - changes introduced in #30 and #31 are incorrect from the Linux kernel POV.

@stappersg
Copy link
Collaborator

The torvalds/linux@6bfbfcf is https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6bfbfcfc58005ee12d37b56a5e722618ef6bee8f and says

The tty line disciplines don't expect tty_operations::write_room to return negative values.

Then seeing distinct return values, ENODEV and EINVAL, all being replaced by the same 0 feels wrong.

The

make everyone's write_room return >= 0

also expressed as tty line disciplines don't expect negative values would allow other values as just 0.

Anyway:

  • Comment has been seen
  • Further research is needed before nullification of an error code
  • That research isn't scheduled in a near future

@klogg
Copy link
Contributor Author

klogg commented Nov 22, 2021

Well, I do not think you need any research here, just following the best practice. It is pretty obvious that kernel drivers express different behavior here, as shown above. Moreover, any existing tty tool will break with negative on write - you can check yourself e.g. with socat.

@jbuchbinder
Copy link
Member

Merging to un-break the current behavior with other tools. If we're going to change the return values to be distinct for specific breaking error conditions, that's fine, we can change them to be positive return values. 0 for now, additional patches welcome.

@jbuchbinder jbuchbinder merged commit c17271a into freemed:master Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants