summaryrefslogtreecommitdiff
path: root/src/pacman
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-07 13:01:13 -0500
committerDave Reisner <dreisner@archlinux.org>2012-04-08 22:28:45 -0400
commita8a1b093eb23450244418232c9e30c4be035fc0b (patch)
tree632a47273f1c4678984d66ecce0c41b6cb7ece1d /src/pacman
parentec91133e38cb7c486ec995d4183f30e84f3ca736 (diff)
Various tweaks to support building with excessive GCC warning flags
This fixes a bunch of small issues in order to enable a clean successful build with a crazy number of GCC warning flags. A lot of these changes are covered by -Wshadow, -Wformat-security, and -Wstrict-overflow=5. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman')
-rw-r--r--src/pacman/conf.c6
-rw-r--r--src/pacman/pacman.c9
-rw-r--r--src/pacman/sync.c4
-rw-r--r--src/pacman/util.c2
4 files changed, 11 insertions, 10 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 4c3d063b..2632d18f 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -202,14 +202,14 @@ static int download_with_xfercommand(const char *url, const char *localpath,
cleanup:
/* restore the old cwd if we have it */
if(cwdfd >= 0) {
- int ret;
+ int close_ret;
if(fchdir(cwdfd) != 0) {
pm_printf(ALPM_LOG_ERROR, _("could not restore working directory (%s)\n"),
strerror(errno));
}
do {
- ret = close(cwdfd);
- } while(ret == -1 && errno == EINTR);
+ close_ret = close(cwdfd);
+ } while(close_ret == -1 && errno == EINTR);
}
if(ret == -1) {
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 1e6797c9..73d5be94 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -808,12 +808,13 @@ int main(int argc, char *argv[])
/* we support reading targets from stdin if a cmdline parameter is '-' */
if(!isatty(fileno(stdin)) && alpm_list_find_str(pm_targets, "-")) {
- size_t current_size = PATH_MAX, i = 0;
+ size_t current_size = PATH_MAX;
char *line = malloc(current_size);
/* remove the '-' from the list */
pm_targets = alpm_list_remove_str(pm_targets, "-", NULL);
+ i = 0;
while((line[i] = (char)fgetc(stdin)) != EOF) {
if(isspace((unsigned char)line[i])) {
/* avoid adding zero length arg when multiple spaces separate args */
@@ -885,13 +886,13 @@ int main(int argc, char *argv[])
#endif
if(config->verbose > 0) {
- alpm_list_t *i;
+ alpm_list_t *j;
printf("Root : %s\n", alpm_option_get_root(config->handle));
printf("Conf File : %s\n", config->configfile);
printf("DB Path : %s\n", alpm_option_get_dbpath(config->handle));
printf("Cache Dirs: ");
- for(i = alpm_option_get_cachedirs(config->handle); i; i = alpm_list_next(i)) {
- printf("%s ", (const char *)i->data);
+ for(j = alpm_option_get_cachedirs(config->handle); j; j = alpm_list_next(j)) {
+ printf("%s ", (const char *)j->data);
}
printf("\n");
printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 5165dca1..9c17f45f 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -307,12 +307,12 @@ static int sync_cleancache(int level)
static int sync_synctree(int level, alpm_list_t *syncs)
{
alpm_list_t *i;
- int success = 0, ret;
+ unsigned int success = 0;
for(i = syncs; i; i = alpm_list_next(i)) {
alpm_db_t *db = i->data;
- ret = alpm_db_update((level < 2 ? 0 : 1), db);
+ int ret = alpm_db_update((level < 2 ? 0 : 1), db);
if(ret < 0) {
pm_printf(ALPM_LOG_ERROR, _("failed to update %s (%s)\n"),
alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle)));
diff --git a/src/pacman/util.c b/src/pacman/util.c
index f2ab163b..be8fc308 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -258,7 +258,7 @@ void indentprint(const char *str, unsigned short indent, unsigned short cols)
{
wchar_t *wcstr;
const wchar_t *p;
- int len, cidx;
+ size_t len, cidx;
if(!str) {
return;