From: Ingo Weinhold Date: Sat, 30 Mar 2013 11:12:31 +0000 (+0000) Subject: Improve C89 compliance X-Git-Tag: BASE-SuSE-Code-12_3-Branch~72^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f063fd2aa8a13f1045b5638e9b0258a70f8cd368;p=thirdparty%2Flibsolv.git Improve C89 compliance Make sure variables are declared at the beginning of a block. --- diff --git a/examples/solv.c b/examples/solv.c index 7d3b0684..6bfacea0 100644 --- a/examples/solv.c +++ b/examples/solv.c @@ -797,8 +797,9 @@ curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsign if (file != cinfo->metalink && file != cinfo->mirrorlist) { unsigned char mlchksum[32]; + Id mlchksumtype; fp = curlfopen(cinfo, cinfo->metalink ? cinfo->metalink : cinfo->mirrorlist, 0, 0, 0, 0); - Id mlchksumtype = 0; + mlchksumtype = 0; if (!fp) return 0; if (cinfo->metalink) @@ -3169,10 +3170,11 @@ rerunsolver: Solvable *s; int j; FILE *fp; + Id type; p = trans->steps.elements[i]; s = pool_id2solvable(pool, p); - Id type = transaction_type(trans, p, SOLVER_TRANSACTION_RPM_ONLY); + type = transaction_type(trans, p, SOLVER_TRANSACTION_RPM_ONLY); switch(type) { case SOLVER_TRANSACTION_ERASE: diff --git a/ext/solv_xfopen.c b/ext/solv_xfopen.c index 6c6441c2..337b0150 100644 --- a/ext/solv_xfopen.c +++ b/ext/solv_xfopen.c @@ -32,14 +32,16 @@ static FILE *cookieopen(void *cookie, const char *mode, cclose ); #elif defined(HAVE_FOPENCOOKIE) - cookie_io_functions_t cio; - memset(&cio, 0, sizeof(cio)); - if (*mode == 'r') - cio.read = cread; - else if (*mode == 'w') - cio.write = cwrite; - cio.close = cclose; - return fopencookie(cookie, *mode == 'w' ? "w" : "r", cio); + { + cookie_io_functions_t cio; + memset(&cio, 0, sizeof(cio)); + if (*mode == 'r') + cio.read = cread; + else if (*mode == 'w') + cio.write = cwrite; + cio.close = cclose; + return fopencookie(cookie, *mode == 'w' ? "w" : "r", cio); + } #else # error Need to implement custom I/O #endif diff --git a/src/solver.c b/src/solver.c index e4c333c6..64b8376e 100644 --- a/src/solver.c +++ b/src/solver.c @@ -182,9 +182,10 @@ autouninstall(Solver *solv, Id *problem) { /* check if identical to feature rule */ Id p = solv->rules[v].p; + Rule *r; if (p <= 0) continue; - Rule *r = solv->rules + solv->featurerules + (p - solv->installed->start); + r = solv->rules + solv->featurerules + (p - solv->installed->start); if (!r->p) { /* update rule == feature rule */