diff options
Diffstat (limited to 'tools/trasher.c')
-rw-r--r-- | tools/trasher.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/trasher.c b/tools/trasher.c index 35625e9a62..0b89cfed87 100644 --- a/tools/trasher.c +++ b/tools/trasher.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2007 Michael Niedermayer * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -30,6 +30,15 @@ static uint32_t ran(void) return state = state * 1664525 + 1013904223; } +static void checked_seek(FILE *stream, int64_t offset, int whence) +{ + offset = fseek(stream, offset, whence); + if (offset < 0) { + fprintf(stderr, "seek failed\n"); + exit(1); + } +} + int main(int argc, char **argv) { FILE *f; @@ -49,14 +58,14 @@ int main(int argc, char **argv) maxburst = atoi(argv[3]); state = atoi(argv[4]); - fseek(f, 0, SEEK_END); + checked_seek(f, 0, SEEK_END); length = ftell(f); - fseek(f, 0, SEEK_SET); + checked_seek(f, 0, SEEK_SET); while (count--) { int burst = 1 + ran() * (uint64_t) (abs(maxburst) - 1) / UINT32_MAX; int pos = ran() * (uint64_t) length / UINT32_MAX; - fseek(f, pos, SEEK_SET); + checked_seek(f, pos, SEEK_SET); if (maxburst < 0) burst = -maxburst; |