mirror of
https://github.com/xiph/opus.git
synced 2025-05-17 00:48:29 +00:00
repacketizer_demo: check for read errors to fix compiler warnings
Actually check for read errors instead of just storing the return value in a variable that then never gets checked. Also fixes "conversion from 'size_t' to 'int', possible loss of data" compiler warnings on Windows with MSVC caused by storing the size_t returned by fread() into an int variable. Signed-off-by: Mark Harris <mark.hsj@gmail.com>
This commit is contained in:
parent
907a52315d
commit
f7e67d429f
1 changed files with 37 additions and 7 deletions
|
@ -119,7 +119,19 @@ int main(int argc, char *argv[])
|
||||||
for (i=0;i<nb_packets;i++)
|
for (i=0;i<nb_packets;i++)
|
||||||
{
|
{
|
||||||
unsigned char ch[4];
|
unsigned char ch[4];
|
||||||
err = fread(ch, 1, 4, fin);
|
if (fread(ch, 1, 4, fin)!=4)
|
||||||
|
{
|
||||||
|
if (feof(fin))
|
||||||
|
{
|
||||||
|
eof = 1;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error reading payload length.\n");
|
||||||
|
fclose(fin);
|
||||||
|
fclose(fout);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
len[i] = char_to_int(ch);
|
len[i] = char_to_int(ch);
|
||||||
/*fprintf(stderr, "in len = %d\n", len[i]);*/
|
/*fprintf(stderr, "in len = %d\n", len[i]);*/
|
||||||
if (len[i]>1500 || len[i]<0)
|
if (len[i]>1500 || len[i]<0)
|
||||||
|
@ -135,12 +147,30 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
err = fread(ch, 1, 4, fin);
|
if (fread(ch, 1, 4, fin)!=4)
|
||||||
rng[i] = char_to_int(ch);
|
{
|
||||||
err = fread(packets[i], 1, len[i], fin);
|
|
||||||
if (feof(fin))
|
if (feof(fin))
|
||||||
{
|
{
|
||||||
eof = 1;
|
eof = 1;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error reading.\n");
|
||||||
|
fclose(fin);
|
||||||
|
fclose(fout);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rng[i] = char_to_int(ch);
|
||||||
|
if (fread(packets[i], len[i], 1, fin)!=1) {
|
||||||
|
if (feof(fin))
|
||||||
|
{
|
||||||
|
eof = 1;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error reading packet of %u bytes.\n", len[i]);
|
||||||
|
fclose(fin);
|
||||||
|
fclose(fout);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
err = opus_repacketizer_cat(rp, packets[i], len[i]);
|
err = opus_repacketizer_cat(rp, packets[i], len[i]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue