[FFmpeg-devel] [PATCH] xvid_rc: check that write() succeeded.

Michael Niedermayer michaelni at gmx.at
Sat Feb 4 05:14:27 CET 2012


On Sat, Feb 04, 2012 at 01:47:19AM +0000, Paul B Mahol wrote:
> On 2/4/12, Michael Niedermayer <michaelni at gmx.at> wrote:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavcodec/libxvid_rc.c |    5 ++++-
> >  1 files changed, 4 insertions(+), 1 deletions(-)
> >
> > diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
> > index 10a7c1c..10d6d0a 100644
> > --- a/libavcodec/libxvid_rc.c
> > +++ b/libavcodec/libxvid_rc.c
> > @@ -59,7 +59,10 @@ int ff_xvid_rate_control_init(MpegEncContext *s){
> >              rce->skip_count, (rce->i_tex_bits + rce->p_tex_bits +
> > rce->misc_bits+7)/8, (rce->header_bits+rce->mv_bits+7)/8);
> >
> >  //av_log(NULL, AV_LOG_ERROR, "%s\n", tmp);
> > -        write(fd, tmp, strlen(tmp));
> > +        if (write(fd, tmp, strlen(tmp)) == -1) {
> 
> write can return other values, so better check for anything < 0
> and return/report such value.

my local man page as well as 
http://pubs.opengroup.org/onlinepubs/007904975/functions/write.html
suggest that it has to return -1 on errors
a test against < 0 should be fine too of course as all non error
values are >= 0 so ill commit it with that change

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120204/df9de33c/attachment.asc>


More information about the ffmpeg-devel mailing list