From f063fd2aa8a13f1045b5638e9b0258a70f8cd368 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 30 Mar 2013 11:12:31 +0000 Subject: [PATCH] Improve C89 compliance Make sure variables are declared at the beginning of a block. --- examples/solv.c | 6 ++++-- ext/solv_xfopen.c | 18 ++++++++++-------- src/solver.c | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/solv.c b/examples/solv.c index 7d3b068..6bfacea 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 6c6441c..337b015 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 e4c333c..64b8376 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 */ -- 2.7.4