From b94e8ecd1fec4426baab8c90e7fc0d5583acdbef Mon Sep 17 00:00:00 2001
From: Dan McGee <dan@archlinux.org>
Date: Tue, 28 Jun 2011 17:46:04 -0500
Subject: Fix a few warnings pointed out via clang scan-build

Some of these are legit (the backup hash NULL checks), while others are
either extemely unlikely or just impossible for the static code
analysis to prove, but are worth adding anyway because they have little
overhead.

Signed-off-by: Dan McGee <dan@archlinux.org>
---
 src/pacman/pacman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src')

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 9ed1c612..cd59c8d4 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -721,15 +721,18 @@ static void cl_to_log(int argc, char* argv[])
 {
 	size_t size = 0;
 	int i;
-	for(i = 0; i<argc; i++) {
+	for(i = 0; i < argc; i++) {
 		size += strlen(argv[i]) + 1;
 	}
+	if(!size) {
+		return;
+	}
 	char *cl_text = malloc(size);
 	if(!cl_text) {
 		return;
 	}
 	char *p = cl_text;
-	for(i = 0; i<argc-1; i++) {
+	for(i = 0; i < argc - 1; i++) {
 		strcpy(p, argv[i]);
 		p += strlen(argv[i]);
 		*p++ = ' ';
-- 
cgit v1.2.3-70-g09d2