From a8a1b093eb23450244418232c9e30c4be035fc0b Mon Sep 17 00:00:00 2001
From: Dan McGee <dan@archlinux.org>
Date: Sat, 7 Apr 2012 13:01:13 -0500
Subject: 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>
---
 lib/libalpm/util.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

(limited to 'lib/libalpm/util.c')

diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 22e9e359..a392c773 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -621,7 +621,9 @@ int _alpm_ldconfig(alpm_handle_t *handle)
 	if(access(line, F_OK) == 0) {
 		snprintf(line, PATH_MAX, "%ssbin/ldconfig", handle->root);
 		if(access(line, X_OK) == 0) {
-			char *argv[] = { "ldconfig", NULL };
+			char arg0[32];
+			char *argv[] = { arg0, NULL };
+			strcpy(arg0, "ldconfig");
 			return _alpm_run_chroot(handle, "/sbin/ldconfig", argv);
 		}
 	}
@@ -676,7 +678,8 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle)
 {
 	struct stat buf;
 	alpm_list_t *i;
-	char *cachedir, *tmpdir;
+	char *cachedir;
+	const char *tmpdir;
 
 	/* Loop through the cache dirs until we find a usable directory */
 	for(i = handle->cachedirs; i; i = i->next) {
@@ -995,13 +998,13 @@ int _alpm_archive_fgets(struct archive *a, struct archive_read_buffer *b)
 			}
 			if(needed > b->line_size) {
 				/* need to realloc + copy data to fit total length */
-				char *new;
-				CALLOC(new, needed, sizeof(char), b->ret = -ENOMEM; goto cleanup);
-				memcpy(new, b->line, b->line_size);
+				char *new_line;
+				CALLOC(new_line, needed, sizeof(char), b->ret = -ENOMEM; goto cleanup);
+				memcpy(new_line, b->line, b->line_size);
 				b->line_size = needed;
-				b->line_offset = new + (b->line_offset - b->line);
+				b->line_offset = new_line + (b->line_offset - b->line);
 				free(b->line);
-				b->line = new;
+				b->line = new_line;
 			}
 		}
 
-- 
cgit v1.2.3-2-g168b