* [PATCH - TINYCOMPRESS 1/4] compress: Extend limit on error messages
@ 2013-01-25 10:43 Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 2/4] compress: Return error when failing to allocate compress struct Charles Keepax
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-25 10:43 UTC (permalink / raw)
To: patch, vinod.koul; +Cc: alsa-devel, patches, Charles Keepax
32 characters is a very short size for the error message, extend this
to 128 characters to prevent clipping on the majority of messages.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
diff --git a/compress.c b/compress.c
index faef982..05e54ae 100644
--- a/compress.c
+++ b/compress.c
@@ -75,7 +75,7 @@
#include "sound/compress_offload.h"
#include "tinycompress/tinycompress.h"
-#define COMPR_ERR_MAX 32
+#define COMPR_ERR_MAX 128
struct compress {
int fd;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH - TINYCOMPRESS 2/4] compress: Return error when failing to allocate compress struct
2013-01-25 10:43 [PATCH - TINYCOMPRESS 1/4] compress: Extend limit on error messages Charles Keepax
@ 2013-01-25 10:43 ` Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 3/4] compress: Return error messages correctly from compress_open Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages Charles Keepax
2 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-25 10:43 UTC (permalink / raw)
To: patch, vinod.koul; +Cc: alsa-devel, patches, Charles Keepax
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
diff --git a/compress.c b/compress.c
index 05e54ae..51455fc 100644
--- a/compress.c
+++ b/compress.c
@@ -207,8 +207,10 @@ struct compress *compress_open(unsigned int card, unsigned int device,
int rc;
compress = calloc(1, sizeof(struct compress));
- if (!compress || !config)
+ if (!compress || !config) {
+ oops(&bad_compress, errno, "cannot allocate compress object");
return &bad_compress;
+ }
compress->config = config;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH - TINYCOMPRESS 3/4] compress: Return error messages correctly from compress_open
2013-01-25 10:43 [PATCH - TINYCOMPRESS 1/4] compress: Extend limit on error messages Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 2/4] compress: Return error when failing to allocate compress struct Charles Keepax
@ 2013-01-25 10:43 ` Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages Charles Keepax
2 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2013-01-25 10:43 UTC (permalink / raw)
To: patch, vinod.koul; +Cc: alsa-devel, patches, Charles Keepax
The allocated compress object will be freed and bad_compress will be
returned, so error messages written to the allocated compress struct
will be lost. This patch writes error messages to bad_compress for error
paths in compress_open, ensuring that error messages are returned
correctly.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
diff --git a/compress.c b/compress.c
index 51455fc..c575acd 100644
--- a/compress.c
+++ b/compress.c
@@ -218,18 +218,18 @@ struct compress *compress_open(unsigned int card, unsigned int device,
compress->flags = flags;
if (!((flags & COMPRESS_OUT) || (flags & COMPRESS_IN))) {
- oops(compress, -EINVAL, "can't deduce device direction from given flags\n");
+ oops(&bad_compress, -EINVAL, "can't deduce device direction from given flags\n");
goto input_fail;
}
if (flags & COMPRESS_OUT) {
/* this should be removed once we have capture tested */
- oops(compress, -EINVAL, "this version doesnt support capture\n");
+ oops(&bad_compress, -EINVAL, "this version doesnt support capture\n");
goto input_fail;
}
compress->fd = open(fn, O_WRONLY);
if (compress->fd < 0) {
- oops(compress, errno, "cannot open device '%s'", fn);
+ oops(&bad_compress, errno, "cannot open device '%s'", fn);
goto input_fail;
}
#if 0
@@ -237,14 +237,14 @@ struct compress *compress_open(unsigned int card, unsigned int device,
* and treat in no support case
*/
if (_is_codec_supported(compress, config) == false) {
- oops(compress, errno, "codec not supported\n");
+ oops(&bad_compress, errno, "codec not supported\n");
goto codec_fail;
}
#endif
fill_compress_params(config, ¶ms);
if (ioctl(compress->fd, SNDRV_COMPRESS_SET_PARAMS, ¶ms)) {
- oops(compress, errno, "cannot set device");
+ oops(&bad_compress, errno, "cannot set device");
goto codec_fail;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages
2013-01-25 10:43 [PATCH - TINYCOMPRESS 1/4] compress: Extend limit on error messages Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 2/4] compress: Return error when failing to allocate compress struct Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 3/4] compress: Return error messages correctly from compress_open Charles Keepax
@ 2013-01-25 10:43 ` Charles Keepax
2013-01-28 6:13 ` Vinod Koul
2 siblings, 1 reply; 5+ messages in thread
From: Charles Keepax @ 2013-01-25 10:43 UTC (permalink / raw)
To: patch, vinod.koul; +Cc: alsa-devel, patches, Charles Keepax
In the oops function text is appended onto the end of the supplied error
message, so newlines appear in the middle of error messages. This patch
removes all newlines from supplied error messages.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
diff --git a/compress.c b/compress.c
index c575acd..19d618a 100644
--- a/compress.c
+++ b/compress.c
@@ -144,22 +144,22 @@ static bool _is_codec_supported(struct compress *compress, struct compr_config *
}
if (config->fragment_size < caps.min_fragment_size) {
- oops(compress, -EINVAL, "requested fragment size %d is below min supported %d\n",
+ oops(compress, -EINVAL, "requested fragment size %d is below min supported %d",
config->fragment_size, caps.min_fragment_size);
return false;
}
if (config->fragment_size > caps.max_fragment_size) {
- oops(compress, -EINVAL, "requested fragment size %d is above max supported %d\n",
+ oops(compress, -EINVAL, "requested fragment size %d is above max supported %d",
config->fragment_size, caps.max_fragment_size);
return false;
}
if (config->fragments < caps.min_fragments) {
- oops(compress, -EINVAL, "requested fragments %d are below min supported %d\n",
+ oops(compress, -EINVAL, "requested fragments %d are below min supported %d",
config->fragments, caps.min_fragments);
return false;
}
if (config->fragments > caps.max_fragments) {
- oops(compress, -EINVAL, "requested fragments %d are above max supported %d\n",
+ oops(compress, -EINVAL, "requested fragments %d are above max supported %d",
config->fragments, caps.max_fragments);
return false;
}
@@ -218,12 +218,12 @@ struct compress *compress_open(unsigned int card, unsigned int device,
compress->flags = flags;
if (!((flags & COMPRESS_OUT) || (flags & COMPRESS_IN))) {
- oops(&bad_compress, -EINVAL, "can't deduce device direction from given flags\n");
+ oops(&bad_compress, -EINVAL, "can't deduce device direction from given flags");
goto input_fail;
}
if (flags & COMPRESS_OUT) {
/* this should be removed once we have capture tested */
- oops(&bad_compress, -EINVAL, "this version doesnt support capture\n");
+ oops(&bad_compress, -EINVAL, "this version doesnt support capture");
goto input_fail;
}
@@ -237,7 +237,7 @@ struct compress *compress_open(unsigned int card, unsigned int device,
* and treat in no support case
*/
if (_is_codec_supported(compress, config) == false) {
- oops(&bad_compress, errno, "codec not supported\n");
+ oops(&bad_compress, errno, "codec not supported");
goto codec_fail;
}
#endif
@@ -335,7 +335,7 @@ int compress_write(struct compress *compress, char *buf, unsigned int size)
to_write = size;
written = write(compress->fd, buf, to_write);
if (written < 0)
- return oops(compress, errno, "write failed!\n");
+ return oops(compress, errno, "write failed!");
size -= written;
buf += written;
@@ -354,7 +354,7 @@ int compress_start(struct compress *compress)
if (!is_compress_ready(compress))
return oops(compress, -ENODEV, "device not ready");
if (ioctl(compress->fd, SNDRV_COMPRESS_START))
- return oops(compress, errno, "cannot start the stream\n");
+ return oops(compress, errno, "cannot start the stream");
compress->running = 1;
return 0;
@@ -365,7 +365,7 @@ int compress_stop(struct compress *compress)
if (!is_compress_running(compress))
return oops(compress, -ENODEV, "device not ready");
if (ioctl(compress->fd, SNDRV_COMPRESS_STOP))
- return oops(compress, errno, "cannot stop the stream\n");
+ return oops(compress, errno, "cannot stop the stream");
return 0;
}
@@ -374,14 +374,14 @@ int compress_pause(struct compress *compress)
if (!is_compress_running(compress))
return oops(compress, -ENODEV, "device not ready");
if (ioctl(compress->fd, SNDRV_COMPRESS_PAUSE))
- return oops(compress, errno, "cannot pause the stream\n");
+ return oops(compress, errno, "cannot pause the stream");
return 0;
}
int compress_resume(struct compress *compress)
{
if (ioctl(compress->fd, SNDRV_COMPRESS_RESUME))
- return oops(compress, errno, "cannot pause the stream\n");
+ return oops(compress, errno, "cannot pause the stream");
return 0;
}
@@ -390,7 +390,7 @@ int compress_drain(struct compress *compress)
if (!is_compress_running(compress))
return oops(compress, -ENODEV, "device not ready");
if (ioctl(compress->fd, SNDRV_COMPRESS_DRAIN))
- return oops(compress, errno, "cannot drain the stream\n");
+ return oops(compress, errno, "cannot drain the stream");
return 0;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages Charles Keepax
@ 2013-01-28 6:13 ` Vinod Koul
0 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2013-01-28 6:13 UTC (permalink / raw)
To: Charles Keepax; +Cc: alsa-devel, patch, vinod.koul, patches
On Fri, Jan 25, 2013 at 10:43:14AM +0000, Charles Keepax wrote:
> In the oops function text is appended onto the end of the supplied error
> message, so newlines appear in the middle of error messages. This patch
> removes all newlines from supplied error messages.
>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Applied all 4, thanks.
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-01-28 6:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-25 10:43 [PATCH - TINYCOMPRESS 1/4] compress: Extend limit on error messages Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 2/4] compress: Return error when failing to allocate compress struct Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 3/4] compress: Return error messages correctly from compress_open Charles Keepax
2013-01-25 10:43 ` [PATCH - TINYCOMPRESS 4/4] compress: Do not put newlines on error messages Charles Keepax
2013-01-28 6:13 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).