Ignore:
Timestamp:
01/10/16 22:36:06 (9 years ago)
Author:
r2d
Message:

removed some new gcc warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/trunk/mpcchap/mpcchap.c

    r429 r487  
    2323#include "iniparser.h"
    2424
     25#include <inttypes.h>
    2526#include <sys/stat.h>
    2627
     
    8384        char * tmp_buff;
    8485        dictionary * dict;
     86    mpc_status ret = MPC_STATUS_OK;
    8587
    8688        chap_pos = (demux->chap_pos >> 3) + si->header_position;
     
    9092        stat(mpc_file, &stbuf);
    9193        tmp_buff = malloc(stbuf.st_size - chap_pos - chap_size);
     94
    9295        in_file = fopen( mpc_file, "r+b" );
    9396        fseek(in_file, chap_pos + chap_size, SEEK_SET);
    94         fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
     97    if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) {
     98        ret = MPC_STATUS_FAIL;
     99        goto error_read_in_file;
     100    }
    95101        fseek(in_file, chap_pos, SEEK_SET);
    96102
     
    105111
    106112                if (chap_pos > si->samples - si->beg_silence)
    107                         fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",
    108                                 i + 1, chap_pos, si->samples - si->beg_silence);
     113            fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n",
     114                    i + 1, chap_pos, si->samples - si->beg_silence);
    109115
    110116                Init_Tags();
     
    142148
    143149        fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
    144         ftruncate(fileno(in_file), ftell(in_file));
    145 
    146         fclose(in_file);
    147         free(tmp_buff);
    148         iniparser_freedict(dict);
    149 
    150         return MPC_STATUS_OK;
     150    if (0 != ftruncate(fileno(in_file), ftell(in_file)))
     151        ret = MPC_STATUS_FAIL;
     152
     153    iniparser_freedict(dict);
     154error_read_in_file:
     155    fclose(in_file);
     156    free(tmp_buff);
     157
     158    return ret;
    151159}
    152160
     
    159167        int chap_pos, end_pos, chap_size, i;
    160168        char * tmp_buff;
     169    mpc_status ret = MPC_STATUS_OK;
    161170
    162171        if (0 == (cd = cf_parse(chap_file, &format))) {
     
    173182        in_file = fopen( mpc_file, "r+b" );
    174183        fseek(in_file, chap_pos + chap_size, SEEK_SET);
    175         fread(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
     184    if (1 != fread(tmp_buff, stbuf.st_size - chap_pos - chap_size, 1, in_file)) {
     185        ret = MPC_STATUS_FAIL;
     186        goto error_read_in_file;
     187    }
    176188        fseek(in_file, chap_pos, SEEK_SET);
    177189
     
    191203
    192204                if (chap_pos > si->samples - si->beg_silence)
    193                         fprintf(stderr, "warning : chapter %i starts @ %lli samples after the end of the stream (%lli)\n",
     205            fprintf(stderr, "warning : chapter %i starts @ %" PRId64 " samples after the end of the stream (%" PRId64 ")\n",
    194206                                i, chap_pos, si->samples - si->beg_silence);
    195207
     
    225237
    226238        fwrite(tmp_buff, 1, stbuf.st_size - chap_pos - chap_size, in_file);
    227         ftruncate(fileno(in_file), ftell(in_file));
    228 
     239    if (0 != ftruncate(fileno(in_file), ftell(in_file)))
     240        ret = MPC_STATUS_FAIL;
     241
     242error_read_in_file:
    229243        fclose(in_file);
    230244        free(tmp_buff);
    231245
    232         return MPC_STATUS_OK;
     246    return ret;
    233247}
    234248
     
    248262        for (i = 0; i < chap_nb; i++) {
    249263                chap = mpc_demux_chap(demux, i);
    250                 fprintf(out_file, "[%lli]\ngain=%i\npeak=%i\n", chap->sample, chap->gain, chap->peak);
     264        fprintf(out_file, "[%" PRId64 "]\ngain=%i\npeak=%i\n", chap->sample, chap->gain, chap->peak);
    251265                if (chap->tag_size > 0) {
    252266                        int item_count, j;
Note: See TracChangeset for help on using the changeset viewer.