[FFmpeg-devel] [PATCH] Make parse_date return INT64_MIN in case of unparsable input
Stefano Sabatini
stefano.sabatini-lala
Tue Sep 18 18:49:20 CEST 2007
On date Tuesday 2007-09-18 18:01:25 +0200, Diego Biurrun encoded:
> On Tue, Sep 18, 2007 at 05:50:37PM +0200, Stefano Sabatini wrote:
> >
> > New patch attached.
> >
> > --- libavformat/utils.c (revision 10526)
> > +++ libavformat/utils.c (working copy)
> > @@ -2621,17 +2621,19 @@
> > if (!q) {
> > /* parse datestr as S+ */
> > dt.tm_sec = strtol(p, (char **)&q, 10);
> > + if (q == p) {
> > + /* set q to NULL to signal that the parsing didn't occur sanely */
>
> Didn't succeed? What are you trying to say?
Mmh... maybe the comment could be clearer, so I'm changing it to:
/* set q to NULL to signal that the parsing didn't succeed */
> > --- 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);
> > + }
> > --- ffplay.c (revision 10526)
> > +++ ffplay.c (working copy)
> > @@ -2406,6 +2406,10 @@
> > static void opt_seek(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_debug(const char *arg)
>
> Smells like code duplication. No, I don't know a clever way to get
> around it offhand.
[...]
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-04.patch
Type: text/x-diff
Size: 5553 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070918/cf6b4ff5/attachment.patch>
More information about the ffmpeg-devel
mailing list