Print this page
OS-1840 fmdump shall emit JSON (newlines, fflush)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/fm/fmdump/common/nvlrender.c
          +++ new/usr/src/cmd/fm/fmdump/common/nvlrender.c
↓ open down ↓ 70 lines elided ↑ open up ↑
  71   71          (void) fprintf(fp, "%s", fmristr);
  72   72          topo_hdl_strfree(thp, fmristr);
  73   73  
  74   74          return (1);
  75   75  }
  76   76  
  77   77  /*
  78   78   * Thin wrapper around libnvpair's inbuilt JSON routine.  Simply dumps the
  79   79   * entire log record nvlist without any reformatting.
  80   80   */
       81 +
       82 +/*ARGSUSED*/
  81   83  int
  82   84  fmdump_print_json(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  83   85  {
  84      -        nvlist_print_json(fp, rp->rec_nvl);
  85      -        fprintf(fp, "\n");
       86 +        if (nvlist_print_json(fp, rp->rec_nvl) || fprintf(fp, "\n") < 0 ||
       87 +            fflush(fp) != 0)
       88 +                return (-1);
  86   89  
  87   90          return (0);
  88   91  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX