lkml.org 
[lkml]   [2009]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH block#for-2.6.31 2/3] block: set rq->resid_len to blk_rq_bytes() on issue
On Sat, 16 May 2009 07:14:44 +0900, Tejun Heo <htejun@gmail.com> wrote:

> So, I could have written
>
> if (cmd->act_len >= rq->resid_len)
> rq->resid_len = 0;
> else
> rq->resid_len -= cmd->act_len
>
> Instead I wrote
>
> rq->resid_len -= min(cmd->act_len, rq->resid_len);
>
> It's just capping the amount to be subtracted so that resid_len
> doesn't underflow. What is so wrong or bad style about that?

Curse of the gifted, I guess. To use a subtraction instead of zero
this way looks like a pointless, even mischievous obfuscation to me.

Also, we probably want a stack_dump or a printk when actual length
exceeds the requested length, don't we? If it ever happens, we
might be overwriting some I/O buffer somewhere.

-- Pete


\
 
 \ /
  Last update: 2009-05-16 01:21    [W:0.051 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site