mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wu Fengguang <fengguang.wu@intel.com>
Cc: mtosatti@redhat.com, gregkh@suse.de,
	broonie@opensource.wolfsonmicro.com, johannes@sipsolutions.net,
	avi@qumranet.com, fengguang.wu@intel.com, andi@firstfloor.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] devmem: cleanup unxlate_dev_mem_ptr() calls
Date: Fri, 11 Sep 2009 17:05:00 -0700	[thread overview]
Message-ID: <20090911170500.8db04cb7.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090911023200.767391440@intel.com>

On Fri, 11 Sep 2009 10:23:36 +0800
Wu Fengguang <fengguang.wu@intel.com> wrote:

> No behavior change.
> 
> CC: Marcelo Tosatti <mtosatti@redhat.com>
> CC: Greg Kroah-Hartman <gregkh@suse.de>
> CC: Mark Brown <broonie@opensource.wolfsonmicro.com>
> CC: Johannes Berg <johannes@sipsolutions.net>
> CC: Avi Kivity <avi@qumranet.com>
> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> ---
>  drivers/char/mem.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> --- linux-mm.orig/drivers/char/mem.c	2009-09-10 21:59:39.000000000 +0800
> +++ linux-mm/drivers/char/mem.c	2009-09-10 22:00:12.000000000 +0800
> @@ -131,6 +131,7 @@ static ssize_t read_mem(struct file * fi
>  			size_t count, loff_t *ppos)
>  {
>  	unsigned long p = *ppos;
> +	unsigned long ret;
>  	ssize_t read, sz;
>  	char *ptr;
>  
> @@ -169,12 +170,10 @@ static ssize_t read_mem(struct file * fi
>  		if (!ptr)
>  			return -EFAULT;
>  
> -		if (copy_to_user(buf, ptr, sz)) {
> -			unxlate_dev_mem_ptr(p, ptr);
> -			return -EFAULT;
> -		}
> -
> +		ret = copy_to_user(buf, ptr, sz);
>  		unxlate_dev_mem_ptr(p, ptr);
> +		if (ret)
> +			return -EFAULT;
>  
>  		buf += sz;
>  		p += sz;

- local var `ret' didn't need function-wide scope.  I think it's
  better to reduce its scope if poss.

- conventionally the identifier `ret' refers to "the value which this
  function will return".  Ditto `retval' and `rc'.

  But that's not what `ret' does here so let's call it something
  else?  `remaining' is rather verbose and formal, but accurate.


--- a/drivers/char/mem.c~dev-mem-cleanup-unxlate_dev_mem_ptr-calls-fix
+++ a/drivers/char/mem.c
@@ -131,7 +131,6 @@ static ssize_t read_mem(struct file * fi
 			size_t count, loff_t *ppos)
 {
 	unsigned long p = *ppos;
-	unsigned long ret;
 	ssize_t read, sz;
 	char *ptr;
 
@@ -156,6 +155,8 @@ static ssize_t read_mem(struct file * fi
 #endif
 
 	while (count > 0) {
+		unsigned long remaining;
+
 		sz = size_inside_page(p, count);
 
 		if (!range_is_allowed(p >> PAGE_SHIFT, count))
@@ -170,9 +171,9 @@ static ssize_t read_mem(struct file * fi
 		if (!ptr)
 			return -EFAULT;
 
-		ret = copy_to_user(buf, ptr, sz);
+		remaining = copy_to_user(buf, ptr, sz);
 		unxlate_dev_mem_ptr(p, ptr);
-		if (ret)
+		if (remaining)
 			return -EFAULT;
 
 		buf += sz;
_


  reply	other threads:[~2009-09-12  0:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-11  2:23 [PATCH 0/3] /dev/mem cleanups and bug fix Wu Fengguang
2009-09-11  2:23 ` [PATCH 1/3] devmem: remove redundant test on len Wu Fengguang
2009-09-12  0:00   ` Andrew Morton
2009-09-12 14:32     ` Wu Fengguang
2009-09-11  2:23 ` [PATCH 2/3] devmem: introduce size_inside_page() Wu Fengguang
2009-09-11 23:55   ` Andrew Morton
2009-09-12 14:41     ` Wu Fengguang
2009-09-11  2:23 ` [PATCH 3/3] devmem: cleanup unxlate_dev_mem_ptr() calls Wu Fengguang
2009-09-12  0:05   ` Andrew Morton [this message]
2009-09-12 14:57     ` Wu Fengguang
2009-09-11  7:44 ` [PATCH 0/3] /dev/mem cleanups and bug fix Andi Kleen

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=20090911170500.8db04cb7.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=avi@qumranet.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=fengguang.wu@intel.com \
    --cc=gregkh@suse.de \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /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

Powered by JetHome