]> git.neil.brown.name Git - history.git/commitdiff
ALSA CVS update
authorJaroslav Kysela <perex@suse.cz>
Thu, 25 Sep 2003 16:17:47 +0000 (18:17 +0200)
committerJaroslav Kysela <perex@suse.cz>
Thu, 25 Sep 2003 16:17:47 +0000 (18:17 +0200)
D:2003/08/25 08:53:37
C:ALSA Core
A:Jaroslav Kysela <perex@suse.cz>
F:core/info.c:1.39->1.40
L:Jeff Muizelaar <muizelaar@rogers.com>
L:The attached patch cleans up the usage of the size variable and removes size1.

sound/core/info.c

index b3df8eace95915d53256ce3b8d5cf50568557e2e..25c2aab5054844ba31ea900003985f965e02ca4f 100644 (file)
@@ -180,7 +180,7 @@ static ssize_t snd_info_entry_read(struct file *file, char *buffer,
        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 @@ static ssize_t snd_info_entry_read(struct file *file, char *buffer,
                        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 @@ static ssize_t snd_info_entry_read(struct file *file, char *buffer,
                        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 @@ static ssize_t snd_info_entry_write(struct file *file, const char *buffer,
        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 @@ static ssize_t snd_info_entry_write(struct file *file, const char *buffer,
                        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 @@ static ssize_t snd_info_entry_write(struct file *file, const char *buffer,
                        return entry->c.ops->write(entry,
                                                   data->file_private_data,
                                                   file, buffer, count);
-               if (size > 0)
-                       file->f_pos += size;
                break;
        }
        return size;