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: [PATCH TINYCOMPRESS 5/14] compress: Take local copy of	compr_config structure
Date: Sun, 10 Feb 2013 00:09:44 +0000	[thread overview]
Message-ID: <20130210000944.GE31139@opensource.wolfsonmicro.com> (raw)

Take a copy of the compr_config structure passed by the client.
This allows the client to use a structure in temporary memory
and avoids the possibility that tinycompress can be broken by the
client changing the content of its compr_config.

diff --git a/compress.c b/compress.c
index c4f215c..871c19e 100644
--- a/compress.c
+++ b/compress.c
@@ -81,7 +81,7 @@ struct compress {
 	int fd;
 	unsigned int flags;
 	char error[COMPR_ERR_MAX];
-	struct compr_config *config;
+	struct compr_config config;
 	int running;
 };
 
@@ -209,7 +209,8 @@ struct compress *compress_open(unsigned int card, unsigned int device,
 	if (!compress || !config)
 		return &bad_compress;
 
-	compress->config = config;
+	/* take a local copy of config */
+	compress->config = *config;
 
 	snprintf(fn, sizeof(fn), "/dev/snd/comprC%uD%u", card, device);
 
@@ -319,7 +320,7 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
 			return oops(compress, errno, "cannot get avail");
 
 		/* we will write only when avail > fragment size */
-		if (avail.avail < compress->config->fragment_size) {
+		if (avail.avail < compress->config.fragment_size) {
 			/* nothing to write so wait for 10secs */
 			ret = poll(&fds, 1, 1000000);
 			if (ret < 0)
-- 
1.7.2.5

             reply	other threads:[~2013-02-10  0:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10  0:09 Richard Fitzgerald [this message]
2013-02-22 16:01 ` [PATCH TINYCOMPRESS 5/14] compress: Take local copy of compr_config structure Richard Fitzgerald

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=20130210000944.GE31139@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.