public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Arjan van de Ven <arjanv@redhat.com>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org,
	jgarzik@pobox.com, jakub@redhat.com
Subject: Re: Add function attribute to copy_from_user to warn for unchecked results
Date: Tue, 16 Sep 2003 01:26:32 -0700	[thread overview]
Message-ID: <20030916012632.2fb67701.akpm@osdl.org> (raw)
In-Reply-To: <20030916100729.B19768@devserv.devel.redhat.com>

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()?  ;)

  reply	other threads:[~2003-09-16  8:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-16  8:07 Add function attribute to copy_from_user to warn for unchecked results Arjan van de Ven
2003-09-16  8:26 ` Andrew Morton [this message]
2003-09-16  9:07   ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030916012632.2fb67701.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=arjanv@redhat.com \
    --cc=jakub@redhat.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox