From: Michael Tremer Date: Thu, 9 Dec 2021 13:01:01 +0000 (+0000) Subject: Fix shadowing any local variables X-Git-Tag: 0.9.28~831 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23b9395887ec464084ca57c23fbe8c012f467700;p=pakfire.git Fix shadowing any local variables Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index 93690a641..bb6ab635f 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -862,7 +862,7 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* // Handle errors if (r < 0) { // Cleanup - for (unsigned int i = 0; envp[i]; i++) + for (i = 0; envp[i]; i++) free(envp[i]); return PyErr_NoMemory(); diff --git a/src/libpakfire/archive.c b/src/libpakfire/archive.c index c72f73206..65d397c2f 100644 --- a/src/libpakfire/archive.c +++ b/src/libpakfire/archive.c @@ -1398,7 +1398,7 @@ static int pakfire_archive_verify_file(struct pakfire_archive* archive, // Read the payload of the file and feed it into the validators for (;;) { - int r = archive_read_data_block(a, &buffer, &size, &offset); + r = archive_read_data_block(a, &buffer, &size, &offset); if (r == ARCHIVE_EOF) break; @@ -1645,7 +1645,7 @@ PAKFIRE_EXPORT int pakfire_archive_verify(struct pakfire_archive* archive, // Return previous result if this has already been called if (archive->verify == PAKFIRE_ARCHIVE_VERIFY_UNKNOWN) { // Verify all signatures - int r = pakfire_archive_verify_signatures(archive, keys); + r = pakfire_archive_verify_signatures(archive, keys); if (r) goto ERROR; @@ -2000,18 +2000,18 @@ PAKFIRE_EXPORT int pakfire_archive_make_package(struct pakfire_archive* archive, char* evr = pakfire_archive_get(archive, "package", "evr"); if (!evr) { - char* e = pakfire_archive_get(archive, "package", "epoch"); - char* v = pakfire_archive_get(archive, "package", "version"); - char* r = pakfire_archive_get(archive, "package", "release"); + char* epoch = pakfire_archive_get(archive, "package", "epoch"); + char* version = pakfire_archive_get(archive, "package", "version"); + char* release = pakfire_archive_get(archive, "package", "release"); - evr = pakfire_package_join_evr(e, v, r); + evr = pakfire_package_join_evr(epoch, version, release); - if (e) - free(e); - if (v) - free(v); - if (r) - free(r); + if (epoch) + free(epoch); + if (version) + free(version); + if (release) + free(release); } /* @@ -2160,9 +2160,11 @@ PAKFIRE_EXPORT int pakfire_archive_make_package(struct pakfire_archive* archive, }; for (const struct __relation* relation = relations; relation->type; relation++) { - char* relations = pakfire_archive_get(archive, "dependencies", relation->type); - if (relations) - pakfire_str2deps(archive->pakfire, pkg, relation->func, relations); + char* rels = pakfire_archive_get(archive, "dependencies", relation->type); + if (rels) { + pakfire_str2deps(archive->pakfire, pkg, relation->func, rels); + free(rels); + } } // Import filelist diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index cf564a127..b9ae91439 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -672,7 +672,7 @@ static int pakfire_build_makefile(struct pakfire* pakfire, const char* path, con // Run through all build stages for (const char** stage = stages; *stage; stage++) { - int r = pakfire_build_stage(pakfire, makefile, *stage, logging_callback, data); + r = pakfire_build_stage(pakfire, makefile, *stage, logging_callback, data); if (r) { // Drop to a shell for debugging if (flags & PAKFIRE_BUILD_INTERACTIVE) diff --git a/src/libpakfire/downloader.c b/src/libpakfire/downloader.c index efa0d17e6..d7bf0e2f0 100644 --- a/src/libpakfire/downloader.c +++ b/src/libpakfire/downloader.c @@ -721,7 +721,7 @@ static int pakfire_downloader_prepare_transfer(struct pakfire_downloader* downlo // Join path if we are using mirrors } else if (transfer->mirrors && !pakfire_mirrorlist_empty(transfer->mirrors)) { - int r = pakfire_transfer_select_mirror(downloader, transfer); + r = pakfire_transfer_select_mirror(downloader, transfer); if (r) return r; @@ -754,7 +754,7 @@ static int pakfire_downloader_prepare_transfer(struct pakfire_downloader* downlo // Open a temporary file to write the output to if (!transfer->f) { // Make path for the temporary file (must be on the same file system) - int r = pakfire_string_format(transfer->tempfile, "%s.XXXXXX", transfer->path); + r = pakfire_string_format(transfer->tempfile, "%s.XXXXXX", transfer->path); if (r < 0) return 1; diff --git a/src/libpakfire/execute.c b/src/libpakfire/execute.c index f0bfada32..f42a2abbd 100644 --- a/src/libpakfire/execute.c +++ b/src/libpakfire/execute.c @@ -210,8 +210,8 @@ static int pakfire_execute_logger(struct pakfire* pakfire, pakfire_execute_loggi if (r) ended = 1; - int fds = epoll_wait(epollfd, events, EPOLL_MAX_EVENTS, -1); - if (fds < 1) { + int num = epoll_wait(epollfd, events, EPOLL_MAX_EVENTS, -1); + if (num < 1) { ERROR(pakfire, "epoll_wait() failed: %m\n"); r = -errno; @@ -221,7 +221,7 @@ static int pakfire_execute_logger(struct pakfire* pakfire, pakfire_execute_loggi struct pakfire_execute_buffer* buffer; int priority; - for (int i = 0; i < fds; i++) { + for (int i = 0; i < num; i++) { int fd = events[i].data.fd; if (fd == stdout) { @@ -287,7 +287,7 @@ int pakfire_execute_capture_stdout_to_array(struct pakfire* pakfire, void* data, // Append everything from stdout to an array if (priority == LOG_INFO) { - unsigned int length = 0; + length = 0; // Create a copy of line char* message = strdup(line); diff --git a/src/libpakfire/filelist.c b/src/libpakfire/filelist.c index ad06b3d44..caad275d5 100644 --- a/src/libpakfire/filelist.c +++ b/src/libpakfire/filelist.c @@ -285,7 +285,7 @@ int pakfire_filelist_create_from_file(struct pakfire_filelist** list, struct pak char* line = strtok_r(data, "\n", &tok); while (line) { - int r = pakfire_filelist_parse_line(&file, pakfire, line, format); + r = pakfire_filelist_parse_line(&file, pakfire, line, format); if (r) goto ERROR; diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 38f70ec3e..04986af6e 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -1140,7 +1140,7 @@ PAKFIRE_EXPORT char* pakfire_package_dump(struct pakfire_package* pkg, int flags for (const struct relation* relation = relations; relation->name; relation++) { char** deps = relation->get(pkg); if (deps) { - const char* name = relation->name; + name = relation->name; size_t count = 0; // Count elements in the list @@ -1207,13 +1207,13 @@ static int pakfire_package_fetch_legacy_filelist(struct pakfire_package* pkg, st struct pakfire_repo* repo = pakfire_package_get_repo(pkg); Solvable* s = get_solvable(pkg); - Repo* r = pakfire_repo_get_repo(repo); + Repo* _repo = pakfire_repo_get_repo(repo); pakfire_repo_unref(repo); int found_marker = 0; Id id, *ids; - ids = r->idarraydata + s->provides; + ids = _repo->idarraydata + s->provides; while((id = *ids++) != 0) { const char* path = pakfire_dep2str(pkg->pakfire, id); diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 522c08903..794f0d45f 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -1204,8 +1204,8 @@ PAKFIRE_EXPORT int pakfire_list_keys(struct pakfire* pakfire, struct pakfire_key ERROR: if (*keys) { - for (struct pakfire_key** key = *keys; *key; key++) - pakfire_key_unref(*key); + for (struct pakfire_key** _key = *keys; *_key; _key++) + pakfire_key_unref(*_key); free(*keys); keys = NULL; } diff --git a/src/libpakfire/parser.c b/src/libpakfire/parser.c index 6ad92a1cc..0d4cab0fb 100644 --- a/src/libpakfire/parser.c +++ b/src/libpakfire/parser.c @@ -428,7 +428,7 @@ static int pakfire_parser_expand_commands(struct pakfire_parser* parser, char** while (1) { // Perform matching - int r = pcre2_jit_match(parser->regex_command, + r = pcre2_jit_match(parser->regex_command, (PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL); // End loop when we have expanded all variables @@ -521,7 +521,7 @@ static int pakfire_parser_expand_variables(struct pakfire_parser* parser, // Search for any variables while (1) { // Perform matching - int r = pcre2_jit_match(parser->regex_variable, + r = pcre2_jit_match(parser->regex_variable, (PCRE2_UCHAR*)*buffer, strlen(*buffer), 0, 0, match, NULL); // End loop when we have expanded all variables @@ -1010,10 +1010,10 @@ int pakfire_parser_create_package(struct pakfire_parser* parser, }; for (const struct relation* relation = relations; relation->type; relation++) { - char* relations = pakfire_parser_get(parser, namespace, relation->type); - if (relations) { - pakfire_str2deps(parser->pakfire, *pkg, relation->func, relations); - free(relations); + char* rels = pakfire_parser_get(parser, namespace, relation->type); + if (rels) { + pakfire_str2deps(parser->pakfire, *pkg, relation->func, rels); + free(rels); } } } diff --git a/src/libpakfire/problem.c b/src/libpakfire/problem.c index cb4f96d01..7c0a6a5c1 100644 --- a/src/libpakfire/problem.c +++ b/src/libpakfire/problem.c @@ -282,8 +282,8 @@ PAKFIRE_EXPORT int pakfire_problem_get_solutions(struct pakfire_problem* problem ERROR: if (*solutions) { - for (struct pakfire_solution** solution = *solutions; *solution; solution++) - pakfire_solution_unref(*solution); + for (struct pakfire_solution** _solution = *solutions; *_solution; _solution++) + pakfire_solution_unref(*_solution); free(*solutions); } diff --git a/src/libpakfire/progressbar.c b/src/libpakfire/progressbar.c index df9e47532..fcb184203 100644 --- a/src/libpakfire/progressbar.c +++ b/src/libpakfire/progressbar.c @@ -337,13 +337,13 @@ static int pakfire_progressbar_redraw(struct pakfire_progressbar* p) { pakfire_progressbar_update_terminal_size(SIGWINCH); unsigned int cols_left = terminal.cols - p->num_widgets - 2; - int i = 0; + unsigned int i = 0; // Create an array with the result of all print functions const char* elements[p->num_widgets]; // Reset all elements - for (unsigned int i = 0; i < p->num_widgets; i++) + for (i = 0; i < p->num_widgets; i++) elements[i] = NULL; // Process all non-expandable widgets in the first pass @@ -386,7 +386,7 @@ static int pakfire_progressbar_redraw(struct pakfire_progressbar* p) { fputs("\r", p->f); // Print all elements - for (unsigned int i = 0; i < p->num_widgets; i++) { + for (i = 0; i < p->num_widgets; i++) { // Skip anything that returned nothing if (!elements[i]) continue; diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index 551d48234..90e4911e1 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -1094,7 +1094,7 @@ PAKFIRE_EXPORT int pakfire_repo_scan(struct pakfire_repo* repo, int flags) { continue; } - const char* path = pakfire_file_get_abspath(file); + path = pakfire_file_get_abspath(file); // Scan the file r = pakfire_repo_scan_file(repo, path); diff --git a/src/libpakfire/request.c b/src/libpakfire/request.c index d335c5f63..724209116 100644 --- a/src/libpakfire/request.c +++ b/src/libpakfire/request.c @@ -221,8 +221,8 @@ static int pakfire_request_get_problems(struct pakfire_request* request, ERROR: if (*problems) { - for (struct pakfire_problem** problem = *problems; *problem; problem++) - free(*problem); + for (struct pakfire_problem** _problem = *problems; *_problem; _problem++) + free(*_problem); free(*problems); // Reset pointer diff --git a/src/libpakfire/solution.c b/src/libpakfire/solution.c index 93edfee57..3eb825bd2 100644 --- a/src/libpakfire/solution.c +++ b/src/libpakfire/solution.c @@ -136,31 +136,31 @@ static char* pakfire_solution_make_string(struct pakfire_solution* solution) { r = asprintf(&element, _("do not ask to %s"), pool_job2str(pool, how, what, 0)); } else if (p == SOLVER_SOLUTION_INFARCH) { - Solvable* s = pool->solvables + rp; + Solvable* solvable = pool->solvables + rp; - if (pool->installed && s->repo == pool->installed) + if (pool->installed && solvable->repo == pool->installed) r = asprintf(&element, _("keep %s despite the inferior architecture"), - pool_solvable2str(pool, s)); + pool_solvable2str(pool, solvable)); else r = asprintf(&element, _("install %s despite the inferior architecture"), - pool_solvable2str(pool, s)); + pool_solvable2str(pool, solvable)); } else if (p == SOLVER_SOLUTION_DISTUPGRADE) { - Solvable* s = pool->solvables + rp; + Solvable* solvable = pool->solvables + rp; - if (pool->installed && s->repo == pool->installed) - r = asprintf(&element, _("keep obsolete %s"), pool_solvable2str(pool, s)); + if (pool->installed && solvable->repo == pool->installed) + r = asprintf(&element, _("keep obsolete %s"), pool_solvable2str(pool, solvable)); else - r = asprintf(&element, _("install %s"), pool_solvable2str(pool, s)); + r = asprintf(&element, _("install %s"), pool_solvable2str(pool, solvable)); } else if (p == SOLVER_SOLUTION_BEST) { - Solvable* s = pool->solvables + rp; + Solvable* solvable = pool->solvables + rp; - if (pool->installed && s->repo == pool->installed) - r = asprintf(&element, _("keep old %s"), pool_solvable2str(pool, s)); + if (pool->installed && solvable->repo == pool->installed) + r = asprintf(&element, _("keep old %s"), pool_solvable2str(pool, solvable)); else r = asprintf(&element, _("install %s despite the old version"), - pool_solvable2str(pool, s)); + pool_solvable2str(pool, solvable)); } else if (p > 0 && rp == 0) r = asprintf(&element, _("allow deinstallation of %s"), diff --git a/src/libpakfire/ui.c b/src/libpakfire/ui.c index 96f43054b..e009e5493 100644 --- a/src/libpakfire/ui.c +++ b/src/libpakfire/ui.c @@ -197,8 +197,8 @@ int pakfire_ui_pick_solution(struct pakfire* pakfire, struct pakfire_request* re for (struct pakfire_solution** solution = solutions; *solution; solution++) { s = pakfire_solution_to_string(*solution); if (!s) { - for (struct pakfire_solution** solution = solutions; *solution; solution++) - pakfire_solution_unref(*solution); + for (struct pakfire_solution** _solution = solutions; *_solution; _solution++) + pakfire_solution_unref(*_solution); free(solutions); goto ERROR; } diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index a348c13b7..f7b4b8e59 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -902,17 +902,17 @@ int __pakfire_unhexlify(unsigned char* dst, const size_t l, const char* src) { const size_t length = strlen(src); for (unsigned int i = 0, j = 0; i < length && j < l; i += 2, j++) { - int h = parse_nibble(src[i]); - int l = parse_nibble(src[i+1]); + int high = parse_nibble(src[i]); + int low = parse_nibble(src[i+1]); // Check for invalid input - if (h < 0 || l < 0) { + if (high < 0 || low < 0) { errno = EINVAL; return 1; } // Store result - dst[j] = h << 4 | l; + dst[j] = high << 4 | low; } return 0;