[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input
Stefano Sabatini
stefano.sabatini-lala
Wed Sep 19 10:36:32 CEST 2007
On date Wednesday 2007-09-19 09:18:51 +0200, Benoit Fouet encoded:
> Stefano Sabatini wrote:
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c (revision 10526)
> > +++ ffmpeg.c (working copy)
> > @@ -2494,21 +2494,38 @@
> > static void opt_recording_time(const char *arg)
> > {
> > recording_time = parse_date(arg, 1);
> > + if (recording_time == INT64_MIN) {
> > + fprintf(stderr, "Invalid duration specification: %s\n", arg);
> > + exit(1);
> > + }
> > }
> >
> > static void opt_start_time(const char *arg)
> > {
> > start_time = parse_date(arg, 1);
> > + if (start_time == INT64_MIN) {
> > + fprintf(stderr, "Invalid duration specification: %s\n", arg);
> > + exit(1);
> > + }
> > }
> >
> > static void opt_rec_timestamp(const char *arg)
> > {
> > - rec_timestamp = parse_date(arg, 0) / 1000000;
> > + int64_t rec_timestamp_us = parse_date(arg, 0);
> > + if (rec_timestamp_us == INT64_MIN) {
> > + fprintf(stderr, "Invalid date specification: %s\n", arg);
> > + exit(1);
> > + }
> > + rec_timestamp = rec_timestamp_us / 1000000;
> > }
> >
> > static void opt_input_ts_offset(const char *arg)
> > {
> > input_ts_offset = parse_date(arg, 1);
> > + if (input_ts_offset == INT64_MIN) {
> > + fprintf(stderr, "Invalid duration specification: %s\n", arg);
> > + exit(1);
> > + }
> > }
> >
>
> you could maybe add a function:
> static void foo(int64_t &ts, const char *arg, int duration)
> {
> *ts = parse_date(arg, duration);
> if (*ts == INT64_MIN) {
> fprintf(stderr, "....");
> exit(1);
> }
> }
>
> and use it in all those places.
Thanks Ben, nice suggestion.
> apart from that, i would say that the patch looks good, but wait for
> Michael's approval, of course...
Regards.
--
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-parse-date-return-int64min-if-unparsable-input-05.patch
Type: text/x-diff
Size: 5548 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070919/bacbd84e/attachment.patch>
More information about the ffmpeg-devel
mailing list