lkml.org 
[lkml]   [2009]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] dup2: Fix return value with oldfd == newfd and invalid fd


On Mon, 11 May 2009, Al Viro wrote:
>
> I'm not sure that it's a right fix, actually. Note that userland declaration
> of that sucker is int dup2(int, int); so should we really take unsigned int
> as arguments?

Hmm. They've been "unsigned int" for as long as our history goes back
(including BK), but yes, making them "int" would have hidden this issue as
well.

That said, I think we had reasons to do our fd's as unsigned, ie the whole
"compare against MAX" thing that doesn't take negative values into
account.

In fact, I think we should do more of those. Right now we literally depend
on things like "max_fds" being "unsigned int", and that the compiler then
turns all the

if (fd < fdt->max_fds)

tests silently into unsigned tests even when 'fd' is 'int'.

So I suspect we should probably make fs/file.c use _more_ "unsigned int"
rather than having less of them.

Linus


\
 
 \ /
  Last update: 2009-10-18 23:28    [W:0.050 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site