From f01c6f814a278a3d024d34fed0c219c8cb1e1e33 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 27 Jun 2011 10:10:08 -0500 Subject: Fix several -Wshadow warnings Only one of these looked like a real red flag, in find_requiredby(), but it doesn't hurt to fix several of them up anyway. Unfortunately, we can't turn this on universally due to things like the sync(), remove(), etc. builtins which we often use as variable names. Signed-off-by: Dan McGee --- lib/libalpm/backup.c | 6 +++--- lib/libalpm/backup.h | 2 +- lib/libalpm/diskspace.c | 8 ++++---- lib/libalpm/dload.c | 6 +++--- lib/libalpm/package.c | 6 +++--- lib/libalpm/util.c | 18 +++++++++--------- src/pacman/callback.c | 10 +++++----- src/pacman/sync.c | 4 +--- src/pacman/upgrade.c | 1 - src/pacman/util.c | 2 +- src/util/pactree.c | 4 ++-- src/util/testpkg.c | 2 +- 12 files changed, 33 insertions(+), 36 deletions(-) diff --git a/lib/libalpm/backup.c b/lib/libalpm/backup.c index 20fb8a80..dc0c5674 100644 --- a/lib/libalpm/backup.c +++ b/lib/libalpm/backup.c @@ -58,16 +58,16 @@ int _alpm_split_backup(const char *string, pmbackup_t **backup) /* Look for a filename in a pmpkg_t.backup list. If we find it, * then we return the full backup entry. */ -pmbackup_t *_alpm_needbackup(const char *file, const alpm_list_t *backup) +pmbackup_t *_alpm_needbackup(const char *file, const alpm_list_t *backup_list) { const alpm_list_t *lp; - if(file == NULL || backup == NULL) { + if(file == NULL || backup_list == NULL) { return NULL; } /* run through the backup list and parse out the hash for our file */ - for(lp = backup; lp; lp = lp->next) { + for(lp = backup_list; lp; lp = lp->next) { pmbackup_t *backup = lp->data; if(strcmp(file, backup->name) == 0) { diff --git a/lib/libalpm/backup.h b/lib/libalpm/backup.h index 2f632d4a..be8de97a 100644 --- a/lib/libalpm/backup.h +++ b/lib/libalpm/backup.h @@ -24,7 +24,7 @@ #include "alpm.h" int _alpm_split_backup(const char *string, pmbackup_t **backup); -pmbackup_t *_alpm_needbackup(const char *file, const alpm_list_t *backup); +pmbackup_t *_alpm_needbackup(const char *file, const alpm_list_t *backup_list); void _alpm_backup_free(pmbackup_t *backup); pmbackup_t *_alpm_backup_dup(const pmbackup_t *backup); diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 079e683e..51aa47f2 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -262,7 +262,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) alpm_list_t *mount_points, *i; alpm_mountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; - int abort = 0; + int error = 0; alpm_list_t *targ; pmtrans_t *trans = handle->trans; @@ -323,7 +323,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) if(data->used && data->read_only) { _alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"), data->mount_dir); - abort = 1; + error = 1; } else if(data->used & USED_INSTALL) { /* cushion is roughly min(5% capacity, 20MiB) */ long fivepc = ((long)data->fsp.f_blocks / 20) + 1; @@ -338,7 +338,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) _alpm_log(handle, PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free\n"), data->mount_dir, data->max_blocks_needed + cushion, (unsigned long)data->fsp.f_bfree); - abort = 1; + error = 1; } } } @@ -349,7 +349,7 @@ int _alpm_check_diskspace(pmhandle_t *handle) } FREELIST(mount_points); - if(abort) { + if(error) { RET_ERR(handle, PM_ERR_DISK_SPACE, -1); } diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index 33fb1cb8..c7903ff0 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -137,12 +137,12 @@ static int curl_gethost(const char *url, char *buffer) return 0; } -static int utimes_long(const char *path, long time) +static int utimes_long(const char *path, long seconds) { - if(time != -1) { + if(seconds != -1) { struct timeval tv[2]; memset(&tv, 0, sizeof(tv)); - tv[0].tv_sec = tv[1].tv_sec = time; + tv[0].tv_sec = tv[1].tv_sec = seconds; return utimes(path, tv); } return 0; diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index e99d5bd4..75ac94c7 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -379,9 +379,9 @@ static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs) for(i = _alpm_db_get_pkgcache(db); i; i = i->next) { pmpkg_t *cachepkg = i->data; - alpm_list_t *i; - for(i = alpm_pkg_get_depends(cachepkg); i; i = i->next) { - if(_alpm_depcmp(pkg, i->data)) { + alpm_list_t *j; + for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) { + if(_alpm_depcmp(pkg, j->data)) { const char *cachepkgname = cachepkg->name; if(alpm_list_find_str(*reqs, cachepkgname) == NULL) { *reqs = alpm_list_add(*reqs, strdup(cachepkgname)); diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 7bd45423..6fbe08ae 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -299,13 +299,13 @@ int _alpm_unpack(pmhandle_t *handle, const char *archive, const char *prefix, /* If specific files were requested, skip entries that don't match. */ if(list) { - char *prefix = strdup(entryname); + char *entry_prefix = strdup(entryname); char *p = strstr(prefix,"/"); if(p) { *(p+1) = '\0'; } - char *found = alpm_list_find_str(list, prefix); - free(prefix); + char *found = alpm_list_find_str(list, entry_prefix); + free(entry_prefix); if(!found) { if(archive_read_data_skip(_archive) != ARCHIVE_OK) { ret = 1; @@ -487,22 +487,22 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[]) } else { /* this code runs for the parent only (wait on the child) */ int status; - FILE *pipe; + FILE *pipe_file; close(pipefd[1]); - pipe = fdopen(pipefd[0], "r"); - if(pipe == NULL) { + pipe_file = fdopen(pipefd[0], "r"); + if(pipe_file == NULL) { close(pipefd[0]); retval = 1; } else { - while(!feof(pipe)) { + while(!feof(pipe_file)) { char line[PATH_MAX]; - if(fgets(line, PATH_MAX, pipe) == NULL) + if(fgets(line, PATH_MAX, pipe_file) == NULL) break; alpm_logaction(handle, "%s", line); EVENT(handle->trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL); } - fclose(pipe); + fclose(pipe_file); } while(waitpid(pid, &status, 0) == -1) { diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 66b14cdd..ffca8bec 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -623,14 +623,14 @@ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) /* if padwid is < 0, we need to trim the string so padwid = 0 */ if(padwid < 0) { int i = filenamelen - 3; - wchar_t *p = wcfname; + wchar_t *wcp = wcfname; /* grab the max number of char columns we can fill */ - while(i > 0 && wcwidth(*p) < i) { - i -= wcwidth(*p); - p++; + while(i > 0 && wcwidth(*wcp) < i) { + i -= wcwidth(*wcp); + wcp++; } /* then add the ellipsis and fill out any extra padding */ - wcscpy(p, L"..."); + wcscpy(wcp, L"..."); padwid = i; } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index f242c827..fa30b8da 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -443,7 +443,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) if(targets) { for(i = targets; i; i = alpm_list_next(i)) { - pmdb_t *db = NULL; int foundpkg = 0; char target[512]; /* TODO is this enough space? */ @@ -452,6 +451,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) strncpy(target, i->data, 512); pkgstr = strchr(target, '/'); if(pkgstr) { + pmdb_t *db = NULL; repo = target; *pkgstr = '\0'; ++pkgstr; @@ -767,7 +767,6 @@ static int sync_trans(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_PKG_INVALID_ARCH: for(i = data; i; i = alpm_list_next(i)) { char *pkg = alpm_list_getdata(i); @@ -835,7 +834,6 @@ static int sync_trans(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c index 6587671b..c1f72f6d 100644 --- a/src/pacman/upgrade.c +++ b/src/pacman/upgrade.c @@ -166,7 +166,6 @@ int pacman_upgrade(alpm_list_t *targets) pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), alpm_strerror(err)); switch(err) { - alpm_list_t *i; case PM_ERR_FILE_CONFLICTS: for(i = data; i; i = alpm_list_next(i)) { pmfileconflict_t *conflict = alpm_list_getdata(i); diff --git a/src/pacman/util.c b/src/pacman/util.c index 77a7e56c..75e67170 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -589,7 +589,7 @@ void list_display(const char *title, const alpm_list_t *list) printf("%s", str); cols += string_length(str); for(i = alpm_list_next(list); i; i = alpm_list_next(i)) { - const char *str = alpm_list_getdata(i); + str = alpm_list_getdata(i); int s = string_length(str); /* wrap only if we have enough usable column space */ if(maxcols > len && cols + s + 2 >= maxcols) { diff --git a/src/util/pactree.c b/src/util/pactree.c index 2f79b66d..5beaa5a7 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -120,7 +120,7 @@ static char *strtrim(char *str) return str; } -static int register_syncs(pmhandle_t *handle) { +static int register_syncs(void) { FILE *fp; char *ptr, *section = NULL; char line[LINE_MAX]; @@ -421,7 +421,7 @@ int main(int argc, char *argv[]) } if(searchsyncs) { - if(register_syncs(handle) != 0) { + if(register_syncs() != 0) { fprintf(stderr, "error: failed to register sync DBs\n"); ret = 1; goto finish; diff --git a/src/util/testpkg.c b/src/util/testpkg.c index c6f02e34..d4d058d8 100644 --- a/src/util/testpkg.c +++ b/src/util/testpkg.c @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1 || pkg == NULL) { - enum _pmerrno_t err = alpm_errno(handle); + err = alpm_errno(handle); switch(err) { case PM_ERR_PKG_OPEN: printf("Cannot open the given file.\n"); -- cgit v1.2.3-70-g09d2