WindCharger: Fix sysvar/env shared variable bug.

This is from the ARRAY_SIZE macro not working (called on pointer).
And for a shared-sysvar function not returning properly.

b/20915900

Change-Id: Ic1834a3d226623db6d19be4a27ef2f4cdb809816
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 340c73e..599fdc7 100755
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -401,6 +401,7 @@
 	if (argc >= 2 && is_sysvar_shared(argv[1])) {
 		printf("ERR: %s is a sysvar-shared variable.\n"
 			"     Please use setvar/sysvar instead\n", argv[1]);
+		return 1;
 	}
 
 	return _do_setenv (flag, argc, argv);
diff --git a/common/cmd_sysvar.c b/common/cmd_sysvar.c
index 4eacbb5..503437e 100644
--- a/common/cmd_sysvar.c
+++ b/common/cmd_sysvar.c
@@ -20,10 +20,6 @@
   const char *uboot_name;
 };
 
-struct sysvar_uboot_map {
-  struct sysvar_uboot *map;
-};
-
 static const struct sysvar_uboot su_mappings[] = {
   {
     .sysvar_name = ACTIVATED_KERNEL_NAME_SV,
@@ -35,10 +31,6 @@
   },
 };
 
-static const struct sysvar_uboot_map su_map = {
-  .map = su_mappings,
-};
-
 // Some bit twiddling for erasing the correct sector on Atheros flash.  This
 // only erases multiples of 64kb.
 #define __SYSVAR_ERASE_SECTOR(x) (((x) >> 16) & 0xff)
@@ -693,9 +685,9 @@
 
 int is_sysvar_shared(const char *var) {
   int i;
-  for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
-    if (strcmp(var, su_map.map[i].uboot_name) == 0 ||
-        strcmp(var, su_map.map[i].sysvar_name) == 0) {
+  for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+    if (strcmp(var, su_mappings[i].uboot_name) == 0 ||
+        strcmp(var, su_mappings[i].sysvar_name) == 0) {
       return true;
     }
   }
@@ -704,9 +696,9 @@
 
 const char *get_uboot_name(const char *sysvar_name) {
   int i;
-  for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
-    if (strcmp(sysvar_name, su_map.map[i].uboot_name) == 0) {
-      return su_map.map[i].uboot_name;
+  for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+    if (strcmp(sysvar_name, su_mappings[i].uboot_name) == 0) {
+      return su_mappings[i].uboot_name;
     }
   }
   return NULL;
@@ -714,8 +706,8 @@
 
 void delete_uboot_vars(void) {
   int i;
-  for (i = 0; i < ARRAY_SIZE(su_map.map); ++i) {
-    setenv(su_map.map[i].sysvar_name, NULL);
-    setenv(su_map.map[i].uboot_name, NULL);
+  for (i = 0; i < ARRAY_SIZE(su_mappings); ++i) {
+    setenv(su_mappings[i].sysvar_name, NULL);
+    setenv(su_mappings[i].uboot_name, NULL);
   }
 }