Index: src/backend/sys_cmd.c
===================================================================
--- src/backend/sys_cmd.c	(revision 2646)
+++ src/backend/sys_cmd.c	(working copy)
@@ -395,8 +395,8 @@
 {
 	char * p;
 	DIR *dp = NULL;
-	struct dirent entry;
-	struct dirent * res_p = NULL;
+	struct dirent *entry;
+	//struct dirent * res_p = NULL;
 	struct stat sbuf;
 	char buf[MAXPATHLEN];
 
@@ -407,28 +407,28 @@
 		return -1;
 	}
 
-	bzero(&entry, sizeof(entry));
-	readdir(dp);
-	while (res_p != NULL) {
-		if (strncmp(entry.d_name, SYS_SNAP_GPG, sizeof(SYS_SNAP_GPG)) != 0) {
-		    readdir(dp);
+	//bzero(&entry, sizeof(entry));
+	entry = readdir(dp);
+	while (entry != NULL) {
+		if (strncmp(entry->d_name, SYS_SNAP_GPG, sizeof(SYS_SNAP_GPG)) != 0) {
+		        entry = readdir(dp);
 			continue;
 		}
-		p = strstr(entry.d_name, SYS_SNAP_GPG_SUFFIX);
+		p = strstr(entry->d_name, SYS_SNAP_GPG_SUFFIX);
 		if (p != NULL) {
 			*p = '\0';
 		}
-		printf("%-18s", entry.d_name);
+		printf("%-18s", entry->d_name);
 		if (p != NULL) {
 			*p = '.';
 		}
-		snprintf(buf, sizeof(buf), "%s%s", ARRAY_DEBUG_BASE, entry.d_name);
+		snprintf(buf, sizeof(buf), "%s%s", ARRAY_DEBUG_BASE, entry->d_name);
 		stat(buf, &sbuf);		
 		printf("%-16lld", (long long int)sbuf.st_size);
 		ctime_r(&sbuf.st_mtime, buf);
 		buf[24] = '\0';	
 		printf("%-20s\n", buf+4);
-        readdir(dp);
+                entry = readdir(dp);
 	}
 
 	return 0;
@@ -496,8 +496,8 @@
 	int num;
 	char * p;
 	DIR *dp = NULL;
-	struct dirent entry;
-	struct dirent * res_p = NULL;
+	struct dirent *entry;
+	//struct dirent * res_p = NULL;
         char buf[MAXPATHLEN];
         char src[MAXPATHLEN];
 
@@ -507,18 +507,18 @@
 	}
 
 	num = 0;
-	bzero(&entry, sizeof(entry));
-    readdir(dp);
-	while (res_p != NULL) {
-		p = strstr(entry.d_name, SYS_SNAP_GPG_SUFFIX);
+	//bzero(&entry, sizeof(entry));
+        entry = readdir(dp);
+	while (entry != NULL) {
+		p = strstr(entry->d_name, SYS_SNAP_GPG_SUFFIX);
 		if (p == NULL) {
-            readdir(dp);
+                        entry = readdir(dp);
 			continue;
 		} else {
-			size_t len = strlen(entry.d_name);
+			size_t len = strlen(entry->d_name);
 			/* the suffix must be SYS_SNAP_GPG_SUFFIX */
-			if ((entry.d_name + len - sizeof(SYS_SNAP_GPG_SUFFIX) + 1) != p) {
-			    readdir(dp);
+			if ((entry->d_name + len - sizeof(SYS_SNAP_GPG_SUFFIX) + 1) != p) {
+			        entry = readdir(dp);
 				continue;
 			}
 		}
@@ -530,9 +530,9 @@
 			snprintf(buf, sizeof(buf), "mkdir -p %s%s", ARRAY_DEBUG_BASE, "sys_debug_all");
 			system(buf);
 		}
-		snprintf(buf, sizeof(buf), "cp -f %s%s %s%s", ARRAY_DEBUG_BASE, entry.d_name, ARRAY_DEBUG_BASE, "sys_debug_all");
+		snprintf(buf, sizeof(buf), "cp -f %s%s %s%s", ARRAY_DEBUG_BASE, entry->d_name, ARRAY_DEBUG_BASE, "sys_debug_all");
 		system(buf);
-		readdir(dp);
+		entry = readdir(dp);
 	}
 	closedir(dp);
 
@@ -831,7 +831,7 @@
 		reset_serial_num(fp->arraykey);
 		fp->flag = UL_INVALID;
 		snprintf(buf, sizeof(buf), "rm -rf %s", ARRAYLICENSE);
-		system(buf);	
+		system(buf);
         } else {
         	printf("Aborted by user\n");
 	}
