]> granicus.if.org Git - procps-ng/commitdiff
misc: adapt others to struct layout change, <PIDS> api
authorJim Warner <james.warner@comcast.net>
Thu, 23 Jun 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Tue, 28 Jun 2016 11:11:25 +0000 (21:11 +1000)
With the change to struct pids_fetch, we'll just trade
some dot ('.') code for some pointer to ('->') syntax.

Signed-off-by: Jim Warner <james.warner@comcast.net>
pmap.c
ps/display.c
top/top.c
w.c

diff --git a/pmap.c b/pmap.c
index 109be479f171878496c78c1090be1fa33a11ad90..3e7cf3c32442cc6479ef97378c99d8e2b7f5a38e 100644 (file)
--- a/pmap.c
+++ b/pmap.c
@@ -1164,7 +1164,7 @@ int main(int argc, char **argv)
        if (!(pids_fetch = procps_pids_select(info, pidlist, user_count, PROCPS_SELECT_PID)))
                xerrx(EXIT_FAILURE, _("library failed pids statistics"));
 
-       for (reap_count = 0; reap_count < pids_fetch->counts.total; reap_count++) {
+       for (reap_count = 0; reap_count < pids_fetch->counts->total; reap_count++) {
                ret |= one_proc(pids_fetch->stacks[reap_count]);
        }
 
index e3fbd53fdf84eb090fbb26f40f13a6fb933b6d37..4520cdea4ff22d37e80853114e4e637cc3ca899d 100644 (file)
@@ -297,7 +297,7 @@ static void simple_spew(void){
 
   switch(thread_flags & (TF_show_proc|TF_loose_tasks|TF_show_task)){
     case TF_show_proc:                   // normal non-thread output
-      for (i = 0; i < pidread->counts.total; i++) {
+      for (i = 0; i < pidread->counts->total; i++) {
         buf = pidread->stacks[i];
         if (want_this_proc(buf))
           show_one_proc(buf, proc_format_list);
@@ -305,7 +305,7 @@ static void simple_spew(void){
       break;
     case TF_show_task:                   // -L and -T options
     case TF_show_proc|TF_loose_tasks:    // H option
-      for (i = 0; i < pidread->counts.total; i++) {
+      for (i = 0; i < pidread->counts->total; i++) {
         buf = pidread->stacks[i];
         if (want_this_proc(buf))
           show_one_proc(buf, task_format_list);
@@ -313,16 +313,16 @@ static void simple_spew(void){
       break;
     case TF_show_proc|TF_show_task:      // m and -m options
       procps_pids_sort(Pids_info, pidread->stacks
-        , pidread->counts.total, PROCPS_PIDS_TIME_START, PROCPS_PIDS_ASCEND);
+        , pidread->counts->total, PROCPS_PIDS_TIME_START, PROCPS_PIDS_ASCEND);
       procps_pids_sort(Pids_info, pidread->stacks
-        , pidread->counts.total, PROCPS_PIDS_ID_TGID, PROCPS_PIDS_ASCEND);
-      for (i = 0; i < pidread->counts.total; i++) {
+        , pidread->counts->total, PROCPS_PIDS_ID_TGID, PROCPS_PIDS_ASCEND);
+      for (i = 0; i < pidread->counts->total; i++) {
         buf = pidread->stacks[i];
 next_proc:
         if (want_this_proc(buf)) {
           int self = rSv(ID_PID, s_int, buf);
           show_one_proc(buf, proc_format_list);
-          for (; i < pidread->counts.total; i++) {
+          for (; i < pidread->counts->total; i++) {
             buf = pidread->stacks[i];
             if (rSv(ID_TGID, s_int, buf) != self) goto next_proc;
             show_one_proc(buf, task_format_list);
@@ -448,12 +448,12 @@ static void fancy_spew(void){
     ? PROCPS_FETCH_THREADS_TOO : PROCPS_FETCH_TASKS_ONLY;
 
   pidread = procps_pids_reap(Pids_info, which);
-  if (!pidread || !pidread->counts.total) {
+  if (!pidread || !pidread->counts->total) {
     fprintf(stderr, _("fatal library error, reap\n"));
     exit(EXIT_FAILURE);
   }
-  processes = xcalloc(pidread->counts.total, sizeof(void*));
-  for (i = 0; i < pidread->counts.total; i++) {
+  processes = xcalloc(pidread->counts->total, sizeof(void*));
+  for (i = 0; i < pidread->counts->total; i++) {
     buf = pidread->stacks[i];
     value_this_proc_pcpu(buf);
     if (want_this_proc(buf))
index e5ac949adc5df22d59758786625ffd4243041aa1..6932022fce2a059db45fa243d5b801c3082e45b0 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -214,7 +214,7 @@ static struct procps_pidsinfo *Pids_ctx;
 static int Pids_itms_cur;                   // 'current' max (<= Fieldstab)
 static enum pids_item *Pids_itms;           // allocated as MAXTBL(Fieldstab)
 static struct pids_fetch *Pids_reap;        // for reap or select
-#define PIDSmaxt Pids_reap->counts.total    // just a little less wordy
+#define PIDSmaxt Pids_reap->counts->total   // just a little less wordy
         // pid stack results extractor macro, where e=our EU enum, t=type, s=stack
         // ( we'll exploit that <proc/pids.h> provided macro as much as possible )
         // ( but many functions use their own unique tailored version for access )
@@ -2190,7 +2190,7 @@ static void cpus_refresh (void) {
 static void procs_refresh (void) {
  #define nALIGN(n,m) (((n + m - 1) / m) * m)     // unconditionally align
  #define nALGN2(n,m) ((n + m - 1) & ~(m - 1))    // with power of 2 align
- #define n_reap  Pids_reap->counts.total
+ #define n_reap  Pids_reap->counts->total
    static double uptime_sav;
    static int n_alloc = -1;                      // size of windows stacks arrays
    double uptime_cur;
@@ -4681,8 +4681,8 @@ static void summary_show (void) {
    if (isROOM(View_STATES, 2)) {
       show_special(0, fmtmk(N_unq(STATE_line_1_fmt)
          , Thread_mode ? N_txt(WORD_threads_txt) : N_txt(WORD_process_txt)
-         , PIDSmaxt, Pids_reap->counts.running, Pids_reap->counts.sleeping
-         , Pids_reap->counts.stopped, Pids_reap->counts.zombied));
+         , PIDSmaxt, Pids_reap->counts->running, Pids_reap->counts->sleeping
+         , Pids_reap->counts->stopped, Pids_reap->counts->zombied));
       Msg_row += 1;
 
       cpus_refresh();
diff --git a/w.c b/w.c
index f9eafc6837d83d289f20fd7409aee0478efd54a2..610bcc445911ecc97fff3ffe4ac163c0e7418d77 100644 (file)
--- a/w.c
+++ b/w.c
@@ -389,7 +389,7 @@ static int find_best_proc(
     if ((reap = procps_pids_reap(info, PROCPS_FETCH_TASKS_ONLY)) == NULL)
         xerrx(EXIT_FAILURE,
               _("Unable to load process information"));
-    total_procs = reap->counts.total;
+    total_procs = reap->counts->total;
 
     for (i=0; i < total_procs; i++) {
         /* is this the login process? */