lkml.org 
[lkml]   [2003]   [Sep]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Add function attribute to copy_from_user to warn for unchecked results
Arjan van de Ven <arjanv@redhat.com> wrote:
>
> Hi,
>
> gcc 3.4 (CVS) has a new function attribute (warn_unused_result) that
> will make gcc spit out a warning in the event that a "marked" function's
> result is ignored by the caller.

Nice.

> +/* warning: this function has no way to return -EFAULT on bad userspace access */
> static inline
> void set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
> {
> + int dummy;
> if (ufdset)
> - __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
> + dummy = __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
> }
>

Wouldn't it be neater to make this return the __copy_to_user() result? And
to mark it __must_check? And to fix the bug you just found in
sys_select()? ;)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.141 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site