Print this page
10113 fmd_adm_xprt_f should return void

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fm/fmstat/common/fmstat.c
          +++ new/usr/src/cmd/fm/fmstat/common/fmstat.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
       27 +/*
       28 + * Copyright (c) 2018, Joyent, Inc.
       29 + */
       30 +
  27   31  #include <fm/fmd_adm.h>
  28   32  
  29   33  #include <strings.h>
  30   34  #include <limits.h>
  31   35  #include <stdlib.h>
  32   36  #include <stdarg.h>
  33   37  #include <stdio.h>
  34   38  #include <errno.h>
  35   39  #include <poll.h>
  36   40  #include <locale.h>
↓ open down ↓ 329 lines elided ↑ open up ↑
 366  370          delta = u64delta(old->dtime.fmds_value.ui64,
 367  371              new->dtime.fmds_value.ui64);
 368  372  
 369  373          if (delta != 0)
 370  374                  mp->m_pct_b = ((double)delta / elapsed) * 100.0;
 371  375          else
 372  376                  mp->m_pct_b = 0.0;
 373  377  }
 374  378  
 375  379  /*ARGSUSED*/
 376      -static int
      380 +static void
 377  381  stat_one_xprt(id_t id, void *ignored)
 378  382  {
 379  383          fmd_adm_stats_t ams;
 380  384          struct modstats *mp;
 381  385  
 382  386          if (fmd_adm_xprt_stats(g_adm, id, &ams) != 0) {
 383  387                  warn("failed to retrieve statistics for transport %d", (int)id);
 384      -                return (0); /* continue on to the next transport */
      388 +                return;
 385  389          }
 386  390  
 387  391          for (mp = g_mods; mp != NULL; mp = mp->m_next) {
 388  392                  if (mp->m_id == id)
 389  393                          break;
 390  394          }
 391  395  
 392  396          if (mp == NULL && (mp = modstat_create(NULL, id)) == NULL) {
 393  397                  warn("failed to allocate memory for transport %d", (int)id);
 394  398                  (void) fmd_adm_stats_free(g_adm, &ams);
 395      -                return (0);
      399 +                return;
 396  400          }
 397  401  
 398  402          modstat_compute(mp, &ams);
 399  403  
 400  404          (void) printf("%3d %5s %7llu %7llu %7llu %7llu "
 401  405              "%4.1f %6.1f %3.0f %3.0f %s\n", (int)id,
 402  406              mp->m_new->state.fmds_value.str,
 403  407              u64delta(mp->m_old->prdequeued.fmds_value.ui64,
 404  408              mp->m_new->prdequeued.fmds_value.ui64),
 405  409              u64delta(mp->m_old->received.fmds_value.ui64,
 406  410              mp->m_new->received.fmds_value.ui64),
 407  411              u64delta(mp->m_old->discarded.fmds_value.ui64,
 408  412              mp->m_new->discarded.fmds_value.ui64),
 409  413              u64delta(mp->m_old->lost.fmds_value.ui64,
 410  414              mp->m_new->lost.fmds_value.ui64),
 411  415              mp->m_wait, mp->m_svc, mp->m_pct_w, mp->m_pct_b,
 412  416              mp->m_new->module.fmds_value.str);
 413  417  
 414  418          (void) fmd_adm_stats_free(g_adm, &ams);
 415      -        return (0);
 416  419  }
 417  420  
 418  421  static void
 419  422  stat_xprt(void)
 420  423  {
 421  424          (void) printf("%3s %5s %7s %7s %7s %7s %4s %6s %3s %3s %s\n",
 422  425              "id", "state", "ev_send", "ev_recv", "ev_drop", "ev_lost",
 423  426              "wait", "svc_t", "%w", "%b", "module");
 424  427  
 425  428          if (fmd_adm_xprt_iter(g_adm, stat_one_xprt, NULL) != 0)
 426  429                  die("failed to retrieve list of transports");
 427  430  }
 428  431  
 429      -static int
      432 +static void
 430  433  stat_one_xprt_auth(id_t id, void *arg)
 431  434  {
 432  435          const char *module = arg;
 433  436          fmd_adm_stats_t ams;
 434  437          struct modstats *mp;
 435  438  
 436  439          if (fmd_adm_xprt_stats(g_adm, id, &ams) != 0) {
 437  440                  warn("failed to retrieve statistics for transport %d", (int)id);
 438      -                return (0); /* continue on to the next transport */
      441 +                return;
 439  442          }
 440  443  
 441  444          for (mp = g_mods; mp != NULL; mp = mp->m_next) {
 442  445                  if (mp->m_id == id)
 443  446                          break;
 444  447          }
 445  448  
 446  449          if (mp == NULL && (mp = modstat_create(NULL, id)) == NULL) {
 447  450                  warn("failed to allocate memory for transport %d", (int)id);
 448  451                  (void) fmd_adm_stats_free(g_adm, &ams);
 449      -                return (0);
      452 +                return;
 450  453          }
 451  454  
 452  455          modstat_compute(mp, &ams);
 453  456  
 454  457          if (module == NULL ||
 455  458              strcmp(module, mp->m_new->module.fmds_value.str) == 0) {
 456  459                  (void) printf("%3d %5s %-18s  %s\n", (int)id,
 457  460                      mp->m_new->state.fmds_value.str,
 458  461                      mp->m_new->module.fmds_value.str,
 459  462                      mp->m_new->authority.fmds_value.str ?
 460  463                      mp->m_new->authority.fmds_value.str : "-");
 461  464          }
 462  465  
 463  466          (void) fmd_adm_stats_free(g_adm, &ams);
 464      -        return (0);
 465  467  }
 466  468  
 467  469  static void
 468  470  stat_xprt_auth(const char *module)
 469  471  {
 470  472          (void) printf("%3s %5s %-18s  %s\n",
 471  473              "id", "state", "module", "authority");
 472  474  
 473  475          if (fmd_adm_xprt_iter(g_adm, stat_one_xprt_auth, (void *)module) != 0)
 474  476                  die("failed to retrieve list of transports");
↓ open down ↓ 340 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX