All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: vinod.koul@intel.com
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH TINYCOMPRESS 2/14 v2] compress: Change	compress_write() to take buffer as const void *
Date: Fri, 22 Feb 2013 15:57:35 +0000	[thread overview]
Message-ID: <20130222155735.GB21174@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <20130210000409.GB31139@opensource.wolfsonmicro.com>

The input buffer to compress_write() should be const, and is
better defined as void * so the caller doesn't have to cast.

---
 compress.c                          |    7 ++++---
 include/tinycompress/tinycompress.h |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/compress.c b/compress.c
index 01fb3f0..5429754 100644
--- a/compress.c
+++ b/compress.c
@@ -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;
diff --git a/include/tinycompress/tinycompress.h b/include/tinycompress/tinycompress.h
index b1fbc65..49c0ff2 100644
--- a/include/tinycompress/tinycompress.h
+++ b/include/tinycompress/tinycompress.h
@@ -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
-- 
1.7.2.5

      reply	other threads:[~2013-02-22 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10  0:04 [PATCH TINYCOMPRESS 2/14] compress: Change compress_write() to take buffer as const void * Richard Fitzgerald
2013-02-22 15:57 ` Richard Fitzgerald [this message]

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=20130222155735.GB21174@opensource.wolfsonmicro.com \
    --to=rf@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=vinod.koul@intel.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 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.