Message ID | 20191106121816.23802-1-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Headers | show |
On Wed, Nov 06, 2019 at 01:18:16PM +0100, Andreas Rheinhardt wrote: > Introduced in ed3c317d. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > fftools/ffmpeg_opt.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) will apply thx [...]
Am Mi., 6. Nov. 2019 um 13:18 Uhr schrieb Andreas Rheinhardt <andreas.rheinhardt@gmail.com>: > > Introduced in ed3c317d. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > fftools/ffmpeg_opt.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > index af9a9a6acb..f4ccf3f65e 100644 > --- a/fftools/ffmpeg_opt.c > +++ b/fftools/ffmpeg_opt.c > @@ -3008,9 +3008,10 @@ static int opt_old2new(void *optctx, const char *opt, const char *arg) > { > OptionsContext *o = optctx; > char *s = av_asprintf("%s:%c", opt + 1, *opt); > + int ret; Shouldn't the new declarations be above the call to av_asprintf()? Carl Eugen
On Wed, Nov 06, 2019 at 08:08:27PM +0100, Carl Eugen Hoyos wrote: > Am Mi., 6. Nov. 2019 um 13:18 Uhr schrieb Andreas Rheinhardt > <andreas.rheinhardt@gmail.com>: > > > > Introduced in ed3c317d. > > > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > > --- > > fftools/ffmpeg_opt.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c > > index af9a9a6acb..f4ccf3f65e 100644 > > --- a/fftools/ffmpeg_opt.c > > +++ b/fftools/ffmpeg_opt.c > > @@ -3008,9 +3008,10 @@ static int opt_old2new(void *optctx, const char *opt, const char *arg) > > { > > OptionsContext *o = optctx; > > char *s = av_asprintf("%s:%c", opt + 1, *opt); > > + int ret; > > Shouldn't the new declarations be above the call to av_asprintf()? will apply with that change thx [...]
Carl Eugen Hoyos: > Am Mi., 6. Nov. 2019 um 13:18 Uhr schrieb Andreas Rheinhardt > <andreas.rheinhardt@gmail.com>: >> >> Introduced in ed3c317d. >> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> >> --- >> fftools/ffmpeg_opt.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) >> >> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c >> index af9a9a6acb..f4ccf3f65e 100644 >> --- a/fftools/ffmpeg_opt.c >> +++ b/fftools/ffmpeg_opt.c >> @@ -3008,9 +3008,10 @@ static int opt_old2new(void *optctx, const char *opt, const char *arg) >> { >> OptionsContext *o = optctx; >> char *s = av_asprintf("%s:%c", opt + 1, *opt); >> + int ret; > > Shouldn't the new declarations be above the call to av_asprintf()? > > Carl Eugen It is completely legal to perform an initialization via function call in the middle of the declarations. I just reread the (relevant part of) the standard and here comes the relevant language-lawyer-stuff. The source of the ban on "mixed declarations and code" in C90 is the syntax of compound statements (square brackets are used to denote optional parts): compound-statement: { [declaration_list] [statement-list] } declaration-list declaration declaration-list declaration statement-list statement statement-list statement And the important parts of declaration are declarator = initializer and initializer assignment-expression ... The syntax of assignment-expression is this: assignment-expression: conditional-expression unary-expression assignment-operator assignment-expression Now the assignment-expression isn't what one might think: the "=" immediately following the declarator is already used and is therefore not part of it, so that the first form of assignment-expression is used. Now comes a series of types of expression that have two forms: One that one would expect from common usage and a passthrough form. E.g. here is the syntax for conditional-expression: conditional-expression: logical-OR-expression logical-OR-expression ? expression : conditional-expression Of course the first form is used here. Via passthrough every logical-OR-expression is a logical-AND-expression is an inclusive-OR-expression is an exclusive-OR-expression is an AND-expression is an equality-expression is a relational-expression is a shift-expression is an additive-expression is a multiplicative-expression is a cast-expression is a unary-expression is a postfix-expression. And postfix-expressions have a function-call form. - Andreas
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index af9a9a6acb..f4ccf3f65e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -3008,9 +3008,10 @@ static int opt_old2new(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; char *s = av_asprintf("%s:%c", opt + 1, *opt); + int ret; if (!s) return AVERROR(ENOMEM); - int ret = parse_option(o, s, arg, options); + ret = parse_option(o, s, arg, options); av_free(s); return ret; } @@ -3088,9 +3089,10 @@ static int opt_timecode(void *optctx, const char *opt, const char *arg) { OptionsContext *o = optctx; char *tcr = av_asprintf("timecode=%s", arg); + int ret; if (!tcr) return AVERROR(ENOMEM); - int ret = parse_option(o, "metadata:g", tcr, options); + ret = parse_option(o, "metadata:g", tcr, options); if (ret >= 0) ret = av_dict_set(&o->g->codec_opts, "gop_timecode", arg, 0); av_free(tcr);
Introduced in ed3c317d. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- fftools/ffmpeg_opt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)