]> git.alsa-project.org Git - tinycompress.git/commitdiff
compress: Change compress_write() to take buffer as const void *
authorRichard Fitzgerald <rf@opensource.wolfsonmicro.com>
Fri, 22 Feb 2013 15:57:35 +0000 (15:57 +0000)
committerVinod Koul <vinod.koul@intel.com>
Fri, 22 Feb 2013 18:08:12 +0000 (23:38 +0530)
The input buffer to compress_write() should be const, and is
better defined as void * so the caller doesn't have to cast.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
compress.c
include/tinycompress/tinycompress.h

index 01fb3f0fe9cf89a7ca7950690c1f89c7de49cdee..5429754be9a16ddae1494d2f8912c95dabfe80b7 100644 (file)
@@ -312,11 +312,12 @@ int compress_get_tstamp(struct compress *compress,
        return 0;
 }
 
-int compress_write(struct compress *compress, char *buf, unsigned int size)
+int compress_write(struct compress *compress, const void *buf, unsigned int size)
 {
        struct snd_compr_avail avail;
        struct pollfd fds;
        int to_write, written, total = 0, ret;
+       const char* cbuf = buf;
 
        if (!(compress->flags & COMPRESS_IN))
                return oops(compress, -EINVAL, "Invalid flag set");
@@ -355,12 +356,12 @@ int compress_write(struct compress *compress, char *buf, unsigned int size)
                        to_write =  avail.avail;
                else
                        to_write = size;
-               written = write(compress->fd, buf, to_write);
+               written = write(compress->fd, cbuf, to_write);
                if (written < 0)
                        return oops(compress, errno, "write failed!");
 
                size -= written;
-               buf += written;
+               cbuf += written;
                total += written;
        }
        return total;
index b1fbc65b057f018193e2355a39752b731cff374a..49c0ff2ff90a07586bceefbbad05d1a2923e3e7f 100644 (file)
@@ -126,7 +126,7 @@ int compress_get_tstamp(struct compress *compress,
  * @buf: pointer to data
  * @size: number of bytes to be written
  */
-int compress_write(struct compress *compress, char *buf, unsigned int size);
+int compress_write(struct compress *compress, const void *buf, unsigned int size);
 
 /*
  * compress_read: read data from the compress stream