Print this page
10130 smatch fixes for usr/src/cmd/fm


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2017, Joyent, Inc. All rights reserved.
  24  */
  25 
  26 #include <fmdump.h>
  27 #include <stdio.h>
  28 #include <strings.h>
  29 
  30 /*ARGSUSED*/
  31 static int
  32 flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  33 {
  34         char buf[32], str[32];
  35         char *class = NULL, *uuid = "-", *code = "-";
  36 
  37         static const struct {
  38                 const char *class;
  39                 const char *tag;
  40         } tags[] = {
  41                 { FM_LIST_SUSPECT_CLASS,        "Diagnosed" },
  42                 { FM_LIST_REPAIRED_CLASS,       "Repaired" },
  43                 { FM_LIST_RESOLVED_CLASS,       "Resolved" },


 166                 code = str;
 167         }
 168         if (class != NULL && strcmp(class, FM_LIST_RESOLVED_CLASS) == 0) {
 169                 (void) snprintf(str, sizeof (str), "%s %s", code, "Resolved");
 170                 code = str;
 171         }
 172         if (class != NULL && strcmp(class, FM_LIST_UPDATED_CLASS) == 0) {
 173                 (void) snprintf(str, sizeof (str), "%s %s", code, "Updated");
 174                 code = str;
 175         }
 176 
 177         fmdump_printf(fp, "%s\n", ffp->do_hdr);
 178         fmdump_printf(fp, "%-20s.%9.9llu %-32s %s\n",
 179             fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, uuid, code);
 180 
 181         if (rp->rec_nrefs != 0)
 182                 fmdump_printf(fp, "\n  %s\n", efp->do_hdr);
 183 
 184         for (i = 0; i < rp->rec_nrefs; i++) {
 185                 fmdump_printf(fp, "  ");
 186                 efp->do_func(lp, &rp->rec_xrefs[i], fp);
 187         }
 188 
 189         fmdump_printf(fp, "\n");
 190         if (pctl)
 191                 nvlist_prt(rp->rec_nvl, pctl);
 192         else
 193                 nvlist_print(fp, rp->rec_nvl);
 194         fmdump_printf(fp, "\n");
 195 
 196         return (0);
 197 }
 198 
 199 static int
 200 flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 201 {
 202         return (flt_verb23_cmn(lp, rp, fp, NULL));
 203 }
 204 
 205 
 206 static int




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2018, Joyent, Inc.
  24  */
  25 
  26 #include <fmdump.h>
  27 #include <stdio.h>
  28 #include <strings.h>
  29 
  30 /*ARGSUSED*/
  31 static int
  32 flt_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  33 {
  34         char buf[32], str[32];
  35         char *class = NULL, *uuid = "-", *code = "-";
  36 
  37         static const struct {
  38                 const char *class;
  39                 const char *tag;
  40         } tags[] = {
  41                 { FM_LIST_SUSPECT_CLASS,        "Diagnosed" },
  42                 { FM_LIST_REPAIRED_CLASS,       "Repaired" },
  43                 { FM_LIST_RESOLVED_CLASS,       "Resolved" },


 166                 code = str;
 167         }
 168         if (class != NULL && strcmp(class, FM_LIST_RESOLVED_CLASS) == 0) {
 169                 (void) snprintf(str, sizeof (str), "%s %s", code, "Resolved");
 170                 code = str;
 171         }
 172         if (class != NULL && strcmp(class, FM_LIST_UPDATED_CLASS) == 0) {
 173                 (void) snprintf(str, sizeof (str), "%s %s", code, "Updated");
 174                 code = str;
 175         }
 176 
 177         fmdump_printf(fp, "%s\n", ffp->do_hdr);
 178         fmdump_printf(fp, "%-20s.%9.9llu %-32s %s\n",
 179             fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, uuid, code);
 180 
 181         if (rp->rec_nrefs != 0)
 182                 fmdump_printf(fp, "\n  %s\n", efp->do_hdr);
 183 
 184         for (i = 0; i < rp->rec_nrefs; i++) {
 185                 fmdump_printf(fp, "  ");
 186                 (void) efp->do_func(lp, &rp->rec_xrefs[i], fp);
 187         }
 188 
 189         fmdump_printf(fp, "\n");
 190         if (pctl)
 191                 nvlist_prt(rp->rec_nvl, pctl);
 192         else
 193                 nvlist_print(fp, rp->rec_nvl);
 194         fmdump_printf(fp, "\n");
 195 
 196         return (0);
 197 }
 198 
 199 static int
 200 flt_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
 201 {
 202         return (flt_verb23_cmn(lp, rp, fp, NULL));
 203 }
 204 
 205 
 206 static int