Detect an error case and prevent printing an uninitialized variable

pm_process_usage can return an error, and leave procs[i]->usage
unitialized.  Detect the error case and print a warning.  Also
make the initialization of procs[i]->usage to 0 unconditional,
so nothing will be printed in the final procrank stats when an
error is detected.

Change-Id: I03f90ae6a5ebb201b6e9e43593cec225e1a8ded0
diff --git a/procrank/procrank.c b/procrank/procrank.c
index a522f6f..489eeb1 100644
--- a/procrank/procrank.c
+++ b/procrank/procrank.c
@@ -105,24 +105,30 @@
             exit(EXIT_FAILURE);
         }
         procs[i]->pid = pids[i];
+        pm_memusage_zero(&procs[i]->usage);
         error = pm_process_create(ker, pids[i], &proc);
-        if (!error) {
-            switch (ws) {
-            case WS_OFF:
-                pm_process_usage(proc, &procs[i]->usage);
-                break;
-            case WS_ONLY:
-                pm_process_workingset(proc, &procs[i]->usage, 0);
-                break;
-            case WS_RESET:
-                pm_process_workingset(proc, NULL, 1);
-                break;
-            }
-            pm_process_destroy(proc);
-        } else {
+        if (error) {
             fprintf(stderr, "warning: could not create process interface for %d\n", pids[i]);
-            pm_memusage_zero(&procs[i]->usage);
+            continue;
         }
+
+        switch (ws) {
+        case WS_OFF:
+            error = pm_process_usage(proc, &procs[i]->usage);
+            break;
+        case WS_ONLY:
+            error = pm_process_workingset(proc, &procs[i]->usage, 0);
+            break;
+        case WS_RESET:
+            error = pm_process_workingset(proc, NULL, 1);
+            break;
+        }
+
+        if (error) {
+            fprintf(stderr, "warning: could not read usage for %d\n", pids[i]);
+        }
+
+        pm_process_destroy(proc);
     }
 
     free(pids);