Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/fm/modules/common/ext-event-transport/fmevt_outbound.c
+++ new/usr/src/cmd/fm/modules/common/ext-event-transport/fmevt_outbound.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 +/*
27 + * Copyright 2019 Joyent, Inc.
28 + */
29 +
26 30 #include <sys/types.h>
27 31 #include <strings.h>
28 32 #include <fm/fmd_api.h>
29 33 #include <sys/fm/protocol.h>
30 34 #include <sys/fm/util.h>
31 35 #include <sys/sysevent.h>
32 36
33 37 #include "fmevt.h"
34 38
35 39 static evchan_t *fmevt_outbound_chan;
36 40
37 41 static struct fmevt_outbound_stats {
38 42 fmd_stat_t recv_calls;
39 43 fmd_stat_t recv_list;
40 44 fmd_stat_t recv_ireport;
41 45 fmd_stat_t recv_other;
42 46 fmd_stat_t fwd_success;
43 47 fmd_stat_t fwd_failure;
44 48 } outbound_stats = {
45 49 { "outbound_recv_calls", FMD_TYPE_UINT64,
46 50 "total events received for forwarding" },
47 51 { "outbound_cat1class_list", FMD_TYPE_UINT64,
48 52 "events received matching list.*" },
49 53 { "outbound_cat1class_ireport", FMD_TYPE_UINT64,
50 54 "events received matching ireport.*" },
51 55 { "outbound_cat1class_other", FMD_TYPE_UINT64,
52 56 "events of other classes" },
53 57 { "outbound_fwd_success", FMD_TYPE_UINT64,
54 58 "events forwarded successfully" },
55 59 { "outbound_fwd_failure", FMD_TYPE_UINT64,
56 60 "events we failed to forward" }
57 61 };
58 62
59 63 #define BUMPSTAT(stat) outbound_stats.stat.fmds_value.ui64++
60 64
61 65 /*
62 66 * In the .conf file we subscribe to list.* and ireport.* event classes.
63 67 * Any additions to that set could cause some unexpected behaviour.
64 68 * For example adding fault.foo won't work (since we don't publish
65 69 * faults directly but only within a list.suspect) but we will get
66 70 * any list.* including fault.foo as a suspect.
67 71 */
68 72 /*ARGSUSED*/
69 73 void
70 74 fmevt_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class)
71 75 {
72 76 BUMPSTAT(recv_calls);
73 77
74 78 if (strncmp(class, "list.", 5) == 0)
75 79 BUMPSTAT(recv_list);
76 80 else if (strncmp(class, "ireport.", 8) == 0)
77 81 BUMPSTAT(recv_ireport);
78 82 else
79 83 BUMPSTAT(recv_other);
80 84
81 85 if (sysevent_evc_publish(fmevt_outbound_chan, class, "",
82 86 SUNW_VENDOR, FM_PUB, nvl, EVCH_SLEEP) == 0) {
83 87 BUMPSTAT(fwd_success);
84 88 } else {
85 89 BUMPSTAT(fwd_failure);
86 90 fmd_hdl_debug(hdl, "sysevent_evc_publish failed:");
87 91 }
88 92 }
89 93
90 94 void
91 95 fmevt_init_outbound(fmd_hdl_t *hdl)
92 96 {
93 97 int32_t channel_depth;
94 98 char *channel_name;
95 99 nvlist_t *nvl;
96 100
97 101 if (fmd_prop_get_int32(hdl, "protocol_forward_disable") == B_TRUE) {
98 102 fmd_hdl_debug(hdl, "protocol forwarding disabled "
99 103 "through .conf file setting\n");
100 104 return;
101 105 }
102 106
103 107 (void) fmd_stat_create(hdl, FMD_STAT_NOALLOC, sizeof (outbound_stats) /
104 108 sizeof (fmd_stat_t), (fmd_stat_t *)&outbound_stats);
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
105 109
106 110 /*
107 111 * Allow simulation environment to change outbound channel name.
108 112 */
109 113 channel_name = fmd_prop_get_string(hdl, "outbound_channel");
110 114
111 115 if (sysevent_evc_bind(channel_name, &fmevt_outbound_chan,
112 116 EVCH_CREAT | EVCH_HOLD_PEND_INDEF) != 0) {
113 117 fmd_hdl_abort(hdl, "Unable to bind channel %s",
114 118 channel_name);
115 - return;
116 119 }
117 120
118 121 channel_depth = fmd_prop_get_int32(hdl, "outbound_channel_depth");
119 122
120 123 if (sysevent_evc_control(fmevt_outbound_chan, EVCH_SET_CHAN_LEN,
121 124 (uint32_t)channel_depth) != 0) {
122 125 fmd_hdl_abort(hdl, "Unable to set depth of channel %s to %d",
123 126 channel_name, channel_depth);
124 127 }
125 128 fmd_prop_free_string(hdl, channel_name);
126 129
127 130 nvl = fmd_nvl_alloc(hdl, FMD_SLEEP);
128 131 (void) nvlist_add_nvlist(nvl, "fmdauth",
129 132 (nvlist_t *)fmd_hdl_fmauth(hdl));
130 133 (void) sysevent_evc_setpropnvl(fmevt_outbound_chan, nvl);
131 134 nvlist_free(nvl);
132 135
133 136 }
134 137
135 138 /*ARGSUSED*/
136 139 void
137 140 fmevt_fini_outbound(fmd_hdl_t *hdl)
138 141 {
139 142 if (fmevt_outbound_chan != NULL) {
140 143 (void) sysevent_evc_unbind(fmevt_outbound_chan);
141 144 fmevt_outbound_chan = NULL;
142 145 }
143 146 }
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX