[FFmpeg-devel] [PATCH 06/13] sgidec: return meaningful error codes
Lou Logan
lou at lrcd.com
Sat Jul 27 00:36:54 CEST 2013
On Fri, 26 Jul 2013 22:26:48 +0000, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
> ---
> libavcodec/sgidec.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
> index c6e7508..7bb80a5 100644
> --- a/libavcodec/sgidec.c
> +++ b/libavcodec/sgidec.c
> @@ -41,7 +41,7 @@ typedef struct SgiState {
> * @param out_buf Points to one line after the output buffer.
> * @param out_end end of line in output buffer
> * @param pixelstride pixel stride of input buffer
> - * @return size of output in bytes, -1 if buffer overflows
> + * @return size of output in bytes, else error number.
nit: add "return"
@return size of output in bytes, else return error number.
> */
> static int expand_rle_row(SgiState *s, uint8_t *out_buf,
> uint8_t *out_end, int pixelstride)
> @@ -58,7 +58,8 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
> }
>
> /* Check for buffer overflow. */
> - if(out_buf + pixelstride * (count-1) >= out_end) return -1;
> + if (out_buf + pixelstride * (count - 1) >= out_end)
> + return AVERROR_INVALIDDATA;
>
> if (pixel & 0x80) {
> while (count--) {
> @@ -81,7 +82,7 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf,
> * Read a run length encoded SGI image.
> * @param out_buf output buffer
> * @param s the current image state
> - * @return 0 if no error, else return error number.
> + * @return 0 if no error, else return error code.
> */
> static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
> {
> @@ -115,7 +116,7 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
> * Read an uncompressed SGI image.
> * @param out_buf output buffer
> * @param s the current image state
> - * @return 0 if read success, otherwise return -1.
> + * @return 0 if read success, else error code.
Same as above.
I can't comment on the other stuff.
More information about the ffmpeg-devel
mailing list