]> granicus.if.org Git - procps-ng/commitdiff
library: ensure the consistent handling of 'noop' enum
authorJim Warner <james.warner@comcast.net>
Mon, 13 Jul 2015 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 15 Jul 2015 11:27:14 +0000 (21:27 +1000)
Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/slab.c

index 392c04165510b772d8650832c8ef127e874e4dcc..aae816450c446f2da87ad5ae079ea8fd24491c52 100644 (file)
@@ -392,7 +392,9 @@ PROCPS_EXPORT unsigned long procps_slabs_get (
         case PROCPS_SLABS_SIZE_ACTIVE:
             return info->stats.active_size;
         case PROCPS_SLABS_noop:
-            break;
+            return 0;
+        default:
+            return -EINVAL;
     }
     return 0;
 }
@@ -442,6 +444,9 @@ PROCPS_EXPORT int procps_slabs_getchain (
             case PROCPS_SLABS_SIZE_ACTIVE:
                 these->result = info->stats.active_size;
                 break;
+            case PROCPS_SLABS_noop:
+                these->result = 0;
+                break;
             default:
                 return -EINVAL;
         }
@@ -498,9 +503,9 @@ PROCPS_EXPORT unsigned long procps_slabnode_get (
             return info->nodes[nodeid].nr_active_slabs;
         case PROCPS_SLABNODE_USE:
             return info->nodes[nodeid].use;
-        case PROCPS_SLABNODE_NAME:
         case PROCPS_SLABNODE_noop:
             return 0;
+        //   PROCPS_SLABNODE_NAME also invalid in this context
         default:
             return -EINVAL;
     }
@@ -550,6 +555,7 @@ PROCPS_EXPORT int procps_slabnode_getchain (
                 these->result.str = info->nodes[nodeid].name;
                 break;
             case PROCPS_SLABNODE_noop:
+                these->result.num = 0;
                 break;
             default:
                 return -EINVAL;
@@ -805,7 +811,7 @@ PROCPS_EXPORT struct slabnode_chain **procps_slabnode_chains_sort (
 
     if (info == NULL || chains == NULL)
         return NULL;
-    if (sort < 0  || sort >= PROCPS_SLABNODE_noop)
+    if (sort < 0  || sort > PROCPS_SLABNODE_noop)
         return NULL;
     if (numchained > info->chained->depth)
         return NULL;