]> granicus.if.org Git - procps-ng/commitdiff
library: fixed miscellaneous whitespace/comment issues
authorJim Warner <james.warner@comcast.net>
Thu, 21 Sep 2017 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sun, 1 Oct 2017 11:25:18 +0000 (22:25 +1100)
. ensure whitespace exists between the code & comments
[ changing txt slightly keeps right margin alignment ]

. strive for more consistency with some comment styles
[ don't use C '/*' style where C++ '//' style exists ]

. removed the instance of double space in 1 assignment
[ still striving for consistency in whitespace usage ]

. fixed comment relating to number of 'derived fields'
[ the <meminfo> api recently added one new such enum ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/diskstats.c
proc/meminfo.c
proc/pids.c
proc/slabinfo.c

index 8a56e945f275b5a5aba956570ccaca75f03938d5..9e21d9b85786a83ebe9453ccb3e2d656aa3d9063 100644 (file)
@@ -99,13 +99,13 @@ struct fetch_support {
 struct diskstats_info {
     int refcount;
     FILE *diskstats_fp;
-    time_t old_stamp;                  /* previous read seconds */
-    time_t new_stamp;                  /* current read seconds */
-    struct dev_node *nodes;            /* dev nodes anchor */
-    struct ext_support select_ext;     /* supports concurrent select/reap */
-    struct ext_support fetch_ext;      /* supports concurrent select/reap */
-    struct fetch_support fetch;        /* support for procps_diskstats_reap */
-    struct diskstats_result get_this;  /* used by procps_diskstats_get */
+    time_t old_stamp;                  // previous read seconds
+    time_t new_stamp;                  // current read seconds
+    struct dev_node *nodes;            // dev nodes anchor
+    struct ext_support select_ext;     // supports concurrent select/reap
+    struct ext_support fetch_ext;      // supports concurrent select/reap
+    struct fetch_support fetch;        // support for procps_diskstats_reap
+    struct diskstats_result get_this;  // used by procps_diskstats_get
 };
 
 
index 3fc3b36d7200a4b649a5bd56f719cf43d3a5129c..ea7bae2ad99e43a57c10e7732bf86cd52a70e77d 100644 (file)
@@ -495,7 +495,7 @@ static int meminfo_make_hash_failed (
     ENTRY e, *ep;
     size_t n;
 
-    // will also include those derived fields (more is better)
+    // will also include those derived fields (more is better)
     n = sizeof(struct meminfo_data) / sizeof(unsigned long);
     // we'll follow the hsearch recommendation of an extra 25%
     hcreate_r(n + (n / 4), &info->hashtab);
@@ -691,27 +691,27 @@ static struct stacks_extent *meminfo_stacks_alloc (
     if (maxstacks < 1)
         return NULL;
 
-    vect_size  = sizeof(void *) * maxstacks;                   // size of the addr vectors |
-    vect_size += sizeof(void *);                               // plus NULL addr delimiter |
-    head_size  = sizeof(struct meminfo_stack);                 // size of that head struct |
-    list_size  = sizeof(struct meminfo_result)*info->numitems; // any single results stack |
-    blob_size  = sizeof(struct stacks_extent);                 // the extent anchor itself |
-    blob_size += vect_size;                                    // plus room for addr vects |
-    blob_size += head_size * maxstacks;                        // plus room for head thing |
-    blob_size += list_size * maxstacks;                        // plus room for our stacks |
-
-    /* note: all of our memory is allocated in a single blob, facilitating a later free(). |
-             as a minimum, it is important that the result structures themselves always be |
-             contiguous for every stack since they are accessed through relative position. | */
+    vect_size  = sizeof(void *) * maxstacks;                    // size of the addr vectors |
+    vect_size += sizeof(void *);                                // plus NULL addr delimiter |
+    head_size  = sizeof(struct meminfo_stack);                  // size of that head struct |
+    list_size  = sizeof(struct meminfo_result)*info->numitems;  // any single results stack |
+    blob_size  = sizeof(struct stacks_extent);                  // the extent anchor itself |
+    blob_size += vect_size;                                     // plus room for addr vects |
+    blob_size += head_size * maxstacks;                         // plus room for head thing |
+    blob_size += list_size * maxstacks;                         // plus room for our stacks |
+
+    /* note: all of this memory is allocated in a single blob, facilitating a later free(). |
+             as a minimum, it is important that the result structures themselves always are |
+             contiguous within each stack since they're accessed through relative position. | */
     if (NULL == (p_blob = calloc(1, blob_size)))
         return NULL;
 
-    p_blob->next = info->extents;                              // push this extent onto... |
-    info->extents = p_blob;                                    // ...some existing extents |
-    p_vect = (void *)p_blob + sizeof(struct stacks_extent);    // prime our vector pointer |
-    p_blob->stacks = p_vect;                                   // set actual vectors start |
-    v_head = (void *)p_vect + vect_size;                       // prime head pointer start |
-    v_list = v_head + (head_size * maxstacks);                 // prime our stacks pointer |
+    p_blob->next = info->extents;                               // push this extent onto... |
+    info->extents = p_blob;                                     // ...some existing extents |
+    p_vect = (void *)p_blob + sizeof(struct stacks_extent);     // prime our vector pointer |
+    p_blob->stacks = p_vect;                                    // set actual vectors start |
+    v_head = (void *)p_vect + vect_size;                        // prime head pointer start |
+    v_list = v_head + (head_size * maxstacks);                  // prime our stacks pointer |
 
     for (i = 0; i < maxstacks; i++) {
         p_head = (struct meminfo_stack *)v_head;
index 96b948d6d34c0e429d7fff9511737bf942e69d0f..9f6c79bf6bceb7c10a52163ddd63381c9fbfea13 100644 (file)
@@ -510,7 +510,7 @@ static struct {
 
     /* please note,
      * this enum MUST be 1 greater than the highest value of any enum */
-enum pids_item PIDS_logical_end  = PIDS_WCHAN_NAME + 1;
+enum pids_item PIDS_logical_end = PIDS_WCHAN_NAME + 1;
 
 #undef setNAME
 #undef freNAME
index 44b78f221aa8242ba73772409bb32ef8ada4e911..3138334f1400ce70eddb0e6f33c9ec82a4e048a7 100644 (file)
 
 
 struct slabs_summ {
-    unsigned int  nr_objs;          /* number of objects, among all caches */
-    unsigned int  nr_active_objs;   /* number of active objects, among all caches */
-    unsigned int  nr_pages;         /* number of pages consumed by all objects */
-    unsigned int  nr_slabs;         /* number of slabs, among all caches */
-    unsigned int  nr_active_slabs;  /* number of active slabs, among all caches */
-    unsigned int  nr_caches;        /* number of caches */
-    unsigned int  nr_active_caches; /* number of active caches */
-    unsigned int  avg_obj_size;     /* average object size */
-    unsigned int  min_obj_size;     /* size of smallest object */
-    unsigned int  max_obj_size;     /* size of largest object */
-    unsigned long active_size;      /* size of all active objects */
-    unsigned long total_size;       /* size of all objects */
+    unsigned int  nr_objs;           // number of objects, among all caches
+    unsigned int  nr_active_objs;    // number of active objects, among all caches
+    unsigned int  nr_pages;          // number of pages consumed by all objects
+    unsigned int  nr_slabs;          // number of slabs, among all caches
+    unsigned int  nr_active_slabs;   // number of active slabs, among all caches
+    unsigned int  nr_caches;         // number of caches
+    unsigned int  nr_active_caches;  // number of active caches
+    unsigned int  avg_obj_size;      // average object size
+    unsigned int  min_obj_size;      // size of smallest object
+    unsigned int  max_obj_size;      // size of largest object
+    unsigned long active_size;       // size of all active objects
+    unsigned long total_size;        // size of all objects
 };
 
 struct slabs_node {
-    char name[SLABINFO_NAME_LEN];  /* name of this cache */
-    unsigned long cache_size;       /* size of entire cache */
-    unsigned int  nr_objs;          /* number of objects in this cache */
-    unsigned int  nr_active_objs;   /* number of active objects */
-    unsigned int  obj_size;         /* size of each object */
-    unsigned int  objs_per_slab;    /* number of objects per slab */
-    unsigned int  pages_per_slab;   /* number of pages per slab */
-    unsigned int  nr_slabs;         /* number of slabs in this cache */
-    unsigned int  nr_active_slabs;  /* number of active slabs */
-    unsigned int  use;              /* percent full: total / active */
+    char name[SLABINFO_NAME_LEN];    // name of this cache
+    unsigned long cache_size;        // size of entire cache
+    unsigned int  nr_objs;           // number of objects in this cache
+    unsigned int  nr_active_objs;    // number of active objects
+    unsigned int  obj_size;          // size of each object
+    unsigned int  objs_per_slab;     // number of objects per slab
+    unsigned int  pages_per_slab;    // number of pages per slab
+    unsigned int  nr_slabs;          // number of slabs in this cache
+    unsigned int  nr_active_slabs;   // number of active slabs
+    unsigned int  use;               // percent full: total / active
 };
 
 struct slabs_hist {
@@ -100,36 +100,36 @@ struct stacks_extent {
 };
 
 struct ext_support {
-    int numitems;                   // includes 'logical_end' delimiter
-    enum slabinfo_item *items;      // includes 'logical_end' delimiter
-    struct stacks_extent *extents;  // anchor for these extents
+    int numitems;                    // includes 'logical_end' delimiter
+    enum slabinfo_item *items;       // includes 'logical_end' delimiter
+    struct stacks_extent *extents;   // anchor for these extents
 #ifdef ENFORCE_LOGICAL
-    enum slabinfo_item lowest;      // range of allowable enums
+    enum slabinfo_item lowest;       // range of allowable enums
     enum slabinfo_item highest;
 #endif
     int dirty_stacks;
 };
 
 struct fetch_support {
-    struct slabinfo_stack **anchor; // fetch consolidated extents
-    int n_alloc;                    // number of above pointers allocated
-    int n_inuse;                    // number of above pointers occupied
-    int n_alloc_save;               // last known reap.stacks allocation
-    struct slabinfo_reap results;   // count + stacks for return to caller
+    struct slabinfo_stack **anchor;  // fetch consolidated extents
+    int n_alloc;                     // number of above pointers allocated
+    int n_inuse;                     // number of above pointers occupied
+    int n_alloc_save;                // last known reap.stacks allocation
+    struct slabinfo_reap results;    // count + stacks for return to caller
 };
 
 struct slabinfo_info {
     int refcount;
     FILE *slabinfo_fp;
-    int nodes_alloc;                   /* nodes alloc()ed */
-    int nodes_used;                    /* nodes using alloced memory */
-    struct slabs_node *nodes;          /* first slabnode of this list */
-    struct slabs_hist slabs;           /* new/old slabs_summ data */
-    struct ext_support select_ext;     /* supports concurrent select/reap */
-    struct ext_support fetch_ext;      /* supports concurrent select/reap */
-    struct fetch_support fetch;        /* support for procps_slabinfo_reap */
-    struct slabs_node nul_node;        /* used by slabinfo_get/select */
-    struct slabinfo_result get_this;   /* used by slabinfo_get */
+    int nodes_alloc;                 // nodes alloc()ed
+    int nodes_used;                  // nodes using alloced memory
+    struct slabs_node *nodes;        // first slabnode of this list
+    struct slabs_hist slabs;         // new/old slabs_summ data
+    struct ext_support select_ext;   // supports concurrent select/reap
+    struct ext_support fetch_ext;    // supports concurrent select/reap
+    struct fetch_support fetch;      // support for procps_slabinfo_reap
+    struct slabs_node nul_node;      // used by slabinfo_get/select
+    struct slabinfo_result get_this; // used by slabinfo_get
 };
 
 
@@ -657,27 +657,27 @@ static struct stacks_extent *slabinfo_stacks_alloc (
     if (maxstacks < 1)
         return NULL;
 
-    vect_size  = sizeof(void *) * maxstacks;                   // size of the addr vectors |
-    vect_size += sizeof(void *);                               // plus NULL addr delimiter |
-    head_size  = sizeof(struct slabinfo_stack);                // size of that head struct |
-    list_size  = sizeof(struct slabinfo_result)*this->numitems;// any single results stack |
-    blob_size  = sizeof(struct stacks_extent);                 // the extent anchor itself |
-    blob_size += vect_size;                                    // plus room for addr vects |
-    blob_size += head_size * maxstacks;                        // plus room for head thing |
-    blob_size += list_size * maxstacks;                        // plus room for our stacks |
-
-    /* note: all of our memory is allocated in a single blob, facilitating a later free(). |
-             as a minimum, it is important that the result structures themselves always be |
-             contiguous for every stack since they are accessed through relative position. | */
+    vect_size  = sizeof(void *) * maxstacks;                     // size of the addr vectors |
+    vect_size += sizeof(void *);                                 // plus NULL addr delimiter |
+    head_size  = sizeof(struct slabinfo_stack);                  // size of that head struct |
+    list_size  = sizeof(struct slabinfo_result)*this->numitems;  // any single results stack |
+    blob_size  = sizeof(struct stacks_extent);                   // the extent anchor itself |
+    blob_size += vect_size;                                      // plus room for addr vects |
+    blob_size += head_size * maxstacks;                          // plus room for head thing |
+    blob_size += list_size * maxstacks;                          // plus room for our stacks |
+
+    /* note: all of our memory is allocated in one single blob, facilitating a later free(). |
+             as a minimum, it is important that those result structures themselves always be |
+             contiguous within each stack since they are accessed through relative position. | */
     if (NULL == (p_blob = calloc(1, blob_size)))
         return NULL;
 
-    p_blob->next = this->extents;                              // push this extent onto... |
-    this->extents = p_blob;                                    // ...some existing extents |
-    p_vect = (void *)p_blob + sizeof(struct stacks_extent);    // prime our vector pointer |
-    p_blob->stacks = p_vect;                                   // set actual vectors start |
-    v_head = (void *)p_vect + vect_size;                       // prime head pointer start |
-    v_list = v_head + (head_size * maxstacks);                 // prime our stacks pointer |
+    p_blob->next = this->extents;                                // push this extent onto... |
+    this->extents = p_blob;                                      // ...some existing extents |
+    p_vect = (void *)p_blob + sizeof(struct stacks_extent);      // prime our vector pointer |
+    p_blob->stacks = p_vect;                                     // set actual vectors start |
+    v_head = (void *)p_vect + vect_size;                         // prime head pointer start |
+    v_list = v_head + (head_size * maxstacks);                   // prime our stacks pointer |
 
     for (i = 0; i < maxstacks; i++) {
         p_head = (struct slabinfo_stack *)v_head;