Messages in this thread | | | Subject | Re: [PATCH 2/4] um: os_set_fd_block: Return old blocking mode | From | Johannes Berg <> | Date | Tue, 04 Jan 2022 10:00:25 +0100 |
| |
On Sat, 2022-01-01 at 22:58 +0100, Richard Weinberger wrote: > This will be needed when we restore the old mode upon exit. > The function now returns < 0 in case of an error, 1 if O_NONBLOCK > was set, 0 otherwise. > > +++ b/arch/um/drivers/chan_user.c > @@ -257,7 +257,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out, > } > > err = os_set_fd_block(*fd_out, 0); > - if (err) { > + if (err < 0) { > printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd " > "non-blocking.\n"); > goto out_close;
This does 'return err' afterwards, which then changes the logic from 0 to 1, which seems wrong - especially given that it gets passed further elsewhere as a pid, which seems very questionable in the first place, but at least 1 would be valid pid unlike 0?
IOW, I think you need
- return err; + return 0;
a couple of lines later.
johannes
| |