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 <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-06-27 10:10:08 -05:00
parent 77a09c92c6
commit f01c6f814a
12 changed files with 33 additions and 36 deletions

View File

@ -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, /* Look for a filename in a pmpkg_t.backup list. If we find it,
* then we return the full backup entry. * 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; const alpm_list_t *lp;
if(file == NULL || backup == NULL) { if(file == NULL || backup_list == NULL) {
return NULL; return NULL;
} }
/* run through the backup list and parse out the hash for our file */ /* 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; pmbackup_t *backup = lp->data;
if(strcmp(file, backup->name) == 0) { if(strcmp(file, backup->name) == 0) {

View File

@ -24,7 +24,7 @@
#include "alpm.h" #include "alpm.h"
int _alpm_split_backup(const char *string, pmbackup_t **backup); 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); void _alpm_backup_free(pmbackup_t *backup);
pmbackup_t *_alpm_backup_dup(const pmbackup_t *backup); pmbackup_t *_alpm_backup_dup(const pmbackup_t *backup);

View File

@ -262,7 +262,7 @@ int _alpm_check_diskspace(pmhandle_t *handle)
alpm_list_t *mount_points, *i; alpm_list_t *mount_points, *i;
alpm_mountpoint_t *root_mp; alpm_mountpoint_t *root_mp;
size_t replaces = 0, current = 0, numtargs; size_t replaces = 0, current = 0, numtargs;
int abort = 0; int error = 0;
alpm_list_t *targ; alpm_list_t *targ;
pmtrans_t *trans = handle->trans; pmtrans_t *trans = handle->trans;
@ -323,7 +323,7 @@ int _alpm_check_diskspace(pmhandle_t *handle)
if(data->used && data->read_only) { if(data->used && data->read_only) {
_alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"), _alpm_log(handle, PM_LOG_ERROR, _("Partition %s is mounted read only\n"),
data->mount_dir); data->mount_dir);
abort = 1; error = 1;
} else if(data->used & USED_INSTALL) { } else if(data->used & USED_INSTALL) {
/* cushion is roughly min(5% capacity, 20MiB) */ /* cushion is roughly min(5% capacity, 20MiB) */
long fivepc = ((long)data->fsp.f_blocks / 20) + 1; 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"), _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, data->mount_dir, data->max_blocks_needed + cushion,
(unsigned long)data->fsp.f_bfree); (unsigned long)data->fsp.f_bfree);
abort = 1; error = 1;
} }
} }
} }
@ -349,7 +349,7 @@ int _alpm_check_diskspace(pmhandle_t *handle)
} }
FREELIST(mount_points); FREELIST(mount_points);
if(abort) { if(error) {
RET_ERR(handle, PM_ERR_DISK_SPACE, -1); RET_ERR(handle, PM_ERR_DISK_SPACE, -1);
} }

View File

@ -137,12 +137,12 @@ static int curl_gethost(const char *url, char *buffer)
return 0; 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]; struct timeval tv[2];
memset(&tv, 0, sizeof(tv)); 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 utimes(path, tv);
} }
return 0; return 0;

View File

@ -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) { for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
pmpkg_t *cachepkg = i->data; pmpkg_t *cachepkg = i->data;
alpm_list_t *i; alpm_list_t *j;
for(i = alpm_pkg_get_depends(cachepkg); i; i = i->next) { for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
if(_alpm_depcmp(pkg, i->data)) { if(_alpm_depcmp(pkg, j->data)) {
const char *cachepkgname = cachepkg->name; const char *cachepkgname = cachepkg->name;
if(alpm_list_find_str(*reqs, cachepkgname) == NULL) { if(alpm_list_find_str(*reqs, cachepkgname) == NULL) {
*reqs = alpm_list_add(*reqs, strdup(cachepkgname)); *reqs = alpm_list_add(*reqs, strdup(cachepkgname));

View File

@ -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 specific files were requested, skip entries that don't match. */
if(list) { if(list) {
char *prefix = strdup(entryname); char *entry_prefix = strdup(entryname);
char *p = strstr(prefix,"/"); char *p = strstr(prefix,"/");
if(p) { if(p) {
*(p+1) = '\0'; *(p+1) = '\0';
} }
char *found = alpm_list_find_str(list, prefix); char *found = alpm_list_find_str(list, entry_prefix);
free(prefix); free(entry_prefix);
if(!found) { if(!found) {
if(archive_read_data_skip(_archive) != ARCHIVE_OK) { if(archive_read_data_skip(_archive) != ARCHIVE_OK) {
ret = 1; ret = 1;
@ -487,22 +487,22 @@ int _alpm_run_chroot(pmhandle_t *handle, const char *path, char *const argv[])
} else { } else {
/* this code runs for the parent only (wait on the child) */ /* this code runs for the parent only (wait on the child) */
int status; int status;
FILE *pipe; FILE *pipe_file;
close(pipefd[1]); close(pipefd[1]);
pipe = fdopen(pipefd[0], "r"); pipe_file = fdopen(pipefd[0], "r");
if(pipe == NULL) { if(pipe_file == NULL) {
close(pipefd[0]); close(pipefd[0]);
retval = 1; retval = 1;
} else { } else {
while(!feof(pipe)) { while(!feof(pipe_file)) {
char line[PATH_MAX]; char line[PATH_MAX];
if(fgets(line, PATH_MAX, pipe) == NULL) if(fgets(line, PATH_MAX, pipe_file) == NULL)
break; break;
alpm_logaction(handle, "%s", line); alpm_logaction(handle, "%s", line);
EVENT(handle->trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL); EVENT(handle->trans, PM_TRANS_EVT_SCRIPTLET_INFO, line, NULL);
} }
fclose(pipe); fclose(pipe_file);
} }
while(waitpid(pid, &status, 0) == -1) { while(waitpid(pid, &status, 0) == -1) {

View File

@ -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 is < 0, we need to trim the string so padwid = 0 */
if(padwid < 0) { if(padwid < 0) {
int i = filenamelen - 3; int i = filenamelen - 3;
wchar_t *p = wcfname; wchar_t *wcp = wcfname;
/* grab the max number of char columns we can fill */ /* grab the max number of char columns we can fill */
while(i > 0 && wcwidth(*p) < i) { while(i > 0 && wcwidth(*wcp) < i) {
i -= wcwidth(*p); i -= wcwidth(*wcp);
p++; wcp++;
} }
/* then add the ellipsis and fill out any extra padding */ /* then add the ellipsis and fill out any extra padding */
wcscpy(p, L"..."); wcscpy(wcp, L"...");
padwid = i; padwid = i;
} }

View File

@ -443,7 +443,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
if(targets) { if(targets) {
for(i = targets; i; i = alpm_list_next(i)) { for(i = targets; i; i = alpm_list_next(i)) {
pmdb_t *db = NULL;
int foundpkg = 0; int foundpkg = 0;
char target[512]; /* TODO is this enough space? */ 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); strncpy(target, i->data, 512);
pkgstr = strchr(target, '/'); pkgstr = strchr(target, '/');
if(pkgstr) { if(pkgstr) {
pmdb_t *db = NULL;
repo = target; repo = target;
*pkgstr = '\0'; *pkgstr = '\0';
++pkgstr; ++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"), pm_fprintf(stderr, PM_LOG_ERROR, _("failed to prepare transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
alpm_list_t *i;
case PM_ERR_PKG_INVALID_ARCH: case PM_ERR_PKG_INVALID_ARCH:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
char *pkg = alpm_list_getdata(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"), pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
alpm_list_t *i;
case PM_ERR_FILE_CONFLICTS: case PM_ERR_FILE_CONFLICTS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
pmfileconflict_t *conflict = alpm_list_getdata(i); pmfileconflict_t *conflict = alpm_list_getdata(i);

View File

@ -166,7 +166,6 @@ int pacman_upgrade(alpm_list_t *targets)
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"), pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
alpm_strerror(err)); alpm_strerror(err));
switch(err) { switch(err) {
alpm_list_t *i;
case PM_ERR_FILE_CONFLICTS: case PM_ERR_FILE_CONFLICTS:
for(i = data; i; i = alpm_list_next(i)) { for(i = data; i; i = alpm_list_next(i)) {
pmfileconflict_t *conflict = alpm_list_getdata(i); pmfileconflict_t *conflict = alpm_list_getdata(i);

View File

@ -589,7 +589,7 @@ void list_display(const char *title, const alpm_list_t *list)
printf("%s", str); printf("%s", str);
cols += string_length(str); cols += string_length(str);
for(i = alpm_list_next(list); i; i = alpm_list_next(i)) { 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); int s = string_length(str);
/* wrap only if we have enough usable column space */ /* wrap only if we have enough usable column space */
if(maxcols > len && cols + s + 2 >= maxcols) { if(maxcols > len && cols + s + 2 >= maxcols) {

View File

@ -120,7 +120,7 @@ static char *strtrim(char *str)
return str; return str;
} }
static int register_syncs(pmhandle_t *handle) { static int register_syncs(void) {
FILE *fp; FILE *fp;
char *ptr, *section = NULL; char *ptr, *section = NULL;
char line[LINE_MAX]; char line[LINE_MAX];
@ -421,7 +421,7 @@ int main(int argc, char *argv[])
} }
if(searchsyncs) { if(searchsyncs) {
if(register_syncs(handle) != 0) { if(register_syncs() != 0) {
fprintf(stderr, "error: failed to register sync DBs\n"); fprintf(stderr, "error: failed to register sync DBs\n");
ret = 1; ret = 1;
goto finish; goto finish;

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1 if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
|| pkg == NULL) { || pkg == NULL) {
enum _pmerrno_t err = alpm_errno(handle); err = alpm_errno(handle);
switch(err) { switch(err) {
case PM_ERR_PKG_OPEN: case PM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n"); printf("Cannot open the given file.\n");