Ticket #5150: programs_mythtranscode_replex_replex.c-check-save_read-count-in-replex_fill_buffers.patch

File programs_mythtranscode_replex_replex.c-check-save_read-count-in-replex_fill_buffers.patch, 1.4 KB (added by Erik Hovland <erik@…>, 16 years ago)

check save_read for errors and report

  • programs/mythtranscode/replex/replex.c

    replex_fill_buffers does something a little strange when checking save_read.
    
    From: Erik Hovland <erik@hovland.org>
    
    I am reworking it so it is readable.
    ---
    
     programs/mythtranscode/replex/replex.c |   13 ++++---------
     1 files changed, 4 insertions(+), 9 deletions(-)
    
    diff --git a/programs/mythtranscode/replex/replex.c b/programs/mythtranscode/replex/replex.c
    index dfea4e6..38f1789 100644
    a b int replex_fill_buffers(struct replex *rx, uint8_t *mbuf) 
    15691569       
    15701570#define MAX_TRIES 5
    15711571                while (count < rsize && tries < MAX_TRIES){
    1572                         if ((re = save_read(rx,buf+i,rsize-i)+i)<0)
     1572                        if ((re = save_read(rx,buf+i,rsize-i))<0)
    15731573                                perror("reading");
    15741574                        else
    1575                                 count += re;
     1575                                count += (re+i);
    15761576                        tries++;
    15771577                       
    15781578                        if (!rx->vpid || !(rx->apidn || rx->ac3n)){
    void init_replex(struct replex *rx) 
    18351835                avi_context *ac;
    18361836                uint8_t buf[AVI_S];
    18371837                int re=0;
    1838                 ssize_t read_count = 0;
    18391838               
    18401839                lseek(rx->fd_in, 0, SEEK_SET);
    18411840                ac = &rx->ac;
    18421841                memset(ac, 0, sizeof(avi_context));
    1843                 if ((read_count = save_read(rx, buf, 12)) != 12) {
    1844                         fprintf(stderr,
    1845                                 "Error reading in 12 bytes from replex. Read %d bytes\n",
    1846                                 read_count);
    1847                         exit(1);
    1848                 }
     1842                if (save_read(rx, buf, 12)<0)
     1843                        perror("reading");
    18491844               
    18501845                if (check_riff(ac, buf, 12) < 0){
    18511846                        fprintf(stderr, "Wrong RIFF header\n");