All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Muizelaar <muizelaar@rogers.com>
To: alsa-devel@lists.sourceforge.net
Subject: [PATCH] snd_info_entry_read/write cleanup
Date: Sun, 24 Aug 2003 20:59:15 -0400	[thread overview]
Message-ID: <3F495F63.8080402@rogers.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 87 bytes --]

The attached patch cleans up the usage of the size variable and removes 
size1.

-Jeff

[-- Attachment #2: size-cleanup.patch --]
[-- Type: text/plain, Size: 1991 bytes --]

Index: core/info.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/info.c,v
retrieving revision 1.39
diff -u -r1.39 info.c
--- core/info.c	18 Jul 2003 16:07:35 -0000	1.39
+++ core/info.c	25 Aug 2003 00:37:49 -0000
@@ -180,7 +180,7 @@
 	snd_info_private_data_t *data;
 	struct snd_info_entry *entry;
 	snd_info_buffer_t *buf;
-	long size = 0, size1;
+	long size = 0;
 
 	data = snd_magic_cast(snd_info_private_data_t, file->private_data, return -ENXIO);
 	snd_assert(data != NULL, return -ENXIO);
@@ -192,10 +192,7 @@
 			return -EIO;
 		if (file->f_pos >= (long)buf->size)
 			return 0;
-		size = buf->size < count ? buf->size : count;
-		size1 = buf->size - file->f_pos;
-		if (size1 < size)
-			size = size1;
+		size = min(count, buf->size - file->f_pos);
 		if (copy_to_user(buffer, buf->buffer + file->f_pos, size))
 			return -EFAULT;
 		file->f_pos += size;
@@ -205,8 +202,6 @@
 			return entry->c.ops->read(entry,
 						  data->file_private_data,
 						  file, buffer, count);
-		if (size > 0)
-			file->f_pos += size;
 		break;
 	}
 	return size;
@@ -218,7 +213,7 @@
 	snd_info_private_data_t *data;
 	struct snd_info_entry *entry;
 	snd_info_buffer_t *buf;
-	long size = 0, size1;
+	long size = 0;
 
 	data = snd_magic_cast(snd_info_private_data_t, file->private_data, return -ENXIO);
 	snd_assert(data != NULL, return -ENXIO);
@@ -232,10 +227,7 @@
 			return -EINVAL;
 		if (file->f_pos >= (long)buf->len)
 			return -ENOMEM;
-		size = buf->len < count ? buf->len : count;
-		size1 = buf->len - file->f_pos;
-		if (size1 < size)
-			size = size1;
+		size = min(count, buf->len - file->f_pos);
 		if (copy_from_user(buf->buffer + file->f_pos, buffer, size))
 			return -EFAULT;
 		if ((long)buf->size < file->f_pos + size)
@@ -247,8 +239,6 @@
 			return entry->c.ops->write(entry,
 						   data->file_private_data,
 						   file, buffer, count);
-		if (size > 0)
-			file->f_pos += size;
 		break;
 	}
 	return size;

                 reply	other threads:[~2003-08-25  0:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=3F495F63.8080402@rogers.com \
    --to=muizelaar@rogers.com \
    --cc=alsa-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.