lkml.org 
[lkml]   [2019]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] tty/n_hdlc: fix sleep in !TASK_RUNNING state warning
From
Date


> On Jan 3, 2019, at 3:32 AM, Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:
>
> On 2019/01/03 18:09, Jiri Slaby wrote:
>> On 02. 01. 19, 16:04, Tetsuo Handa wrote:
>>> + if (wait_event_interruptible(tty->read_wait,
>>> + (ret = -EIO, test_bit(TTY_OTHER_CLOSED, &tty->flags)) ||
>>> + (ret = 0, tty_hung_up_p(file)) ||
>>> + (rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list)) != NULL ||
>>> + (ret = -EAGAIN, tty_io_nonblock(tty, file))))
>>> + return -EINTR;
>>
>> Oh, that looks really ugly. Could you move all this to a function
>> returning a bool and taking &ret and &rbuf as parameters?
>>
>
> OK. Something like this?


I agree with Jiri that placing all the conditional logic in a single expression is difficult to read.

But exchanging that many locals with a separate function defeats the original purpose of
simplifying code and this implementation changes the logic (write no
longer checks for line discipline changing under it during wait).

Converting to wait_event_interruptible where possible is a good goal but this instance
may be better left alone. The current structure mirrors the existing n_tty line discipline.


\
 
 \ /
  Last update: 2019-01-03 16:57    [W:0.063 / U:0.144 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site