From: stevenj Date: Fri, 30 Jul 2010 00:54:19 +0000 (-0400) Subject: stick to C89 and avoid mixed declarations and code; thanks to Benoit Scherrer for... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=70d0fa2f873b020f4124ecc93f6ebfbf619f3953;p=nlopt.git stick to C89 and avoid mixed declarations and code; thanks to Benoit Scherrer for the bug report (fails with MSVC) darcs-hash:20100730005419-c8de0-39dc04e5a2be81512bb3ca87c6fa397192e5bfd7.gz --- diff --git a/api/optimize.c b/api/optimize.c index e52216d..cfaa3c5 100644 --- a/api/optimize.c +++ b/api/optimize.c @@ -371,9 +371,9 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) case NLOPT_GD_MLSL: case NLOPT_GN_MLSL_LDS: case NLOPT_GD_MLSL_LDS: { - if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS; nlopt_opt local_opt = opt->local_opt; nlopt_result ret; + if (!finite_domain(n, lb, ub)) return NLOPT_INVALID_ARGS; if (!local_opt && (algorithm == NLOPT_G_MLSL || algorithm == NLOPT_G_MLSL_LDS)) return NLOPT_INVALID_ARGS; diff --git a/api/options.c b/api/options.c index d934f71..9dd9bb4 100644 --- a/api/options.c +++ b/api/options.c @@ -116,6 +116,7 @@ nlopt_opt NLOPT_STDCALL nlopt_copy(const nlopt_opt opt) nlopt_opt nopt = NULL; unsigned i; if (opt) { + nlopt_munge munge; nopt = (nlopt_opt) malloc(sizeof(struct nlopt_opt_s)); *nopt = *opt; nopt->lb = nopt->ub = nopt->xtol_abs = NULL; @@ -126,7 +127,7 @@ nlopt_opt NLOPT_STDCALL nlopt_copy(const nlopt_opt opt) nopt->work = NULL; opt->force_stop_child = NULL; - nlopt_munge munge = nopt->munge_on_copy; + munge = nopt->munge_on_copy; if (munge && nopt->f_data) if (!(nopt->f_data = munge(nopt->f_data))) goto oom;