GCOV Execution Analysis for sahpi_event_utils.c

The left column is the number of times the code was executed during the unit test suites.

Exec CodeLine #
 
Source:sahpi_event_utils.c
1
 
Object:t/sahpi/sahpi_event_utils.bb
2
 
/*      -*- linux-c -*-
3
 
 *
4
 
 * (C) Copyright IBM Corp. 2004
5
 
 *
6
 
 * This program is distributed in the hope that it will be useful,
7
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This
9
 
 * file and program are licensed under a BSD style license.  See
10
 
 * the Copying file included with the OpenHPI distribution for
11
 
 * full licensing terms.
12
 
 *
13
 
 * Author(s):
14
 
 *      Steve Sherman < address removed >
15
 
 */
16
 
17
 
#include <glib.h>
18
 
#include <stdlib.h>
19
 
#include <stdio.h>
20
 
#include <string.h>
21
 
22
 
#include <SaHpi.h>
23
 
#include <oh_utils.h>
24
 
25
 
/**
26
 
 * oh_decode_eventstate:
27
 
 * @event_state: Event state bit map to be converted to a string.
28
 
 * @event_cat: Event category of @event_state.
29
 
 * @buffer: Pointer to buffer to store generated string.
30
 
 *
31
 
 * Converts @event_state into a string based on @event_state's HPI definition.
32
 
 * For example, @event_state = SAHPI_ES_UPPER_MAJOR | SAHPI_ES_UPPER_MINOR
33
 
 * is returned as the string "UPPER_MINOR | UPPER_MAJOR".
34
 
 * String is stored in an SaHpiTextBufferT data structure.
35
 
 *
36
 
 * Function validates that the @event_state bit map is valid for @event_cat. And
37
 
 * that the states are complete and not mutually exclusive.
38
 
 *
39
 
 * SAHPI_ES_UNSPECIFIED definitions are stripped from @event_state, if there are 
40
 
 * other valid non-global states defined. For example, @event_state = 
41
 
 * SAHPI_ES_IDLE | SAHPI_ES_UNSPECIFIED, returns the string "IDLE".
42
 
 *
43
 
 * Returns:
44
 
 * SA_OK - normal operation.
45
 
 * SA_ERR_HPI_INVALID_PARAMS - @buffer is NULL; Invalid @event_state or @event_cat.
46
 
 * SA_ERR_HPI_OUT_OF_SPACE - @buffer too small.
47
 
  **/
48
 
SaErrorT oh_decode_eventstate(SaHpiEventStateT event_state,
49
 
			      SaHpiEventCategoryT event_cat,
50
 
			      SaHpiTextBufferT *buffer)
51
94 
{
52
94 
	int i, found;
53
94 
	SaErrorT err;
54
94 
	SaHpiTextBufferT working;
55
 
56
94 
	if (!buffer || !oh_valid_eventstate(event_state, event_cat)) {
57
2 
		return(SA_ERR_HPI_INVALID_PARAMS);
58
 
	}
59
 
60
92 
	err = oh_init_textbuffer(&working);
61
92 
	if (err != SA_OK) { return(err); }
62
 
63
92 
	found = 0;
64
 
	/* Look for category's event states */
65
7176 
	for (i=0; i<OH_MAX_STATE_STRINGS; i++) {
66
7084 
		if (state_strings[i].category == event_cat) {
67
829 
			if ((state_strings[i].state & event_state) == state_strings[i].state) {
68
101 
				found++;
69
101 
				err = oh_append_textbuffer(&working, (char *)state_strings[i].str);
70
101 
				if (err != SA_OK) { return(err); }
71
101 
				err = oh_append_textbuffer(&working, OH_ENCODE_DELIMITER);
72
101 
				if (err != SA_OK) { return(err); }
73
 
			}
74
 
		}
75
 
	}
76
 
	
77
 
	/* Look for global event states */
78
184 
	for (i=0; i<OH_MAX_STATE_GLOBAL_STRINGS; i++) {
79
92 
		if ((state_global_strings[i].state & event_state) == state_global_strings[i].state) {
80
 
			/* Strip any UNSPECIFIED definitions, if another definition found */
81
92 
			if (!(found && state_global_strings[i].state == SAHPI_ES_UNSPECIFIED)) {
82
5 
				found++;
83
5 
				err = oh_append_textbuffer(&working, (char *)state_global_strings[i].str);
84
5 
				if (err != SA_OK) { return(err); }
85
5 
				err = oh_append_textbuffer(&working, OH_ENCODE_DELIMITER);
86
5 
				if (err != SA_OK) { return(err); }
87
 
			}
88
 
		}
89
 
	}
90
 
91
 
	/* Remove last delimiter */
92
92 
	if (found) {
93
460 
		for (i=0; i<OH_ENCODE_DELIMITER_LENGTH + 1; i++) {
94
368 
			working.Data[working.DataLength - i] = 0x00;
95
 
		}
96
92 
		working.DataLength = working.DataLength - (i+1);
97
 
	}
98
 
99
92 
	err = oh_copy_textbuffer(buffer, &working);
100
 
101
92 
	return(SA_OK);
102
 
}
103
 
104
 
/**
105
 
 * oh_encode_eventstate:
106
 
 * @buffer: Pointer to buffer containing string representation of event
107
 
 *          state bit map. Generally received from oh_decode_eventstate().
108
 
 * @event_state: Pointer to store generated event state bit map.
109
 
 * @event_cat: Pointer to store generated event category.
110
 
 *
111
 
 * Converts string representation of an event state bit map (usually generated
112
 
 * by oh_decode_eventstate() back into an HPI event state and category 
113
 
 * structure. For example, the string "UPPER_MINOR | UPPER_MAJOR" generates
114
 
 * event state = SAHPI_ES_UPPER_MAJOR | SAHPI_ES_UPPER_MINOR and
115
 
 * event category = SAHPI_ES_THRESHOLD.
116
 
117
 
 * Function validates that the @event_state bit map is valid for @event_cat. And
118
 
 * that the states are complete and not mutually exclusive.
119
 
 *
120
 
 * NOTE!
121
 
 * @event_cat cannot always be deterministically calculated.
122
 
 *
123
 
 * - if @event_state is SAHPI_ES_UNSPECIFIED, @event_cat will be SAHPI_EC_UNSPECIFIED
124
 
 *   (though any category is valid).
125
 
 * - For event categories with the same events defined (e.g. SAHPI_EC_GENERIC and
126
 
 *   SAHPI_EC_SENSOR_SPECIFIC), the category returned may be either one.
127
 
 *
128
 
 * Returns:
129
 
 * SA_OK - normal operation.
130
 
 * SA_ERR_HPI_INVALID_PARAMS - @buffer, @event_state, or @event_cat NULL.
131
 
 *                             No Data in @buffer, invalid format, or
132
 
 *                             @event_state bit map not valid for @event_cat. 
133
 
 * SA_ERR_HPI_OUT_OF_SPACE - @buffer too small.
134
 
 **/
135
 
SaErrorT oh_encode_eventstate(SaHpiTextBufferT *buffer,
136
 
			      SaHpiEventStateT *event_state,
137
 
			      SaHpiEventCategoryT *event_cat)
138
83 
{
139
83 
	gchar *gstr = NULL;
140
83 
	gchar **eventdefs = NULL;
141
83 
	int i, j, found_event, found_global_event;
142
83 
	SaErrorT rtncode = SA_OK;
143
83 
	SaHpiEventStateT working_state=0;
144
83 
	SaHpiEventCategoryT working_cat=0;
145
 
		
146
83 
	if (!buffer || !event_state || !event_cat) {
147
1 
		return(SA_ERR_HPI_INVALID_PARAMS);
148
 
	}
149
82 
	if (buffer->Data == NULL || buffer->Data[0] == '\0') {
150
1 
		return(SA_ERR_HPI_INVALID_PARAMS);
151
 
	}
152
 
	
153
 
	/* Split out event definitions */
154
81 
	gstr = g_strstrip(g_strdup((gchar *)buffer->Data));
155
81 
	if (gstr == NULL || gstr[0] == '\0') {
156
0 
		dbg("g_strstrip failed");
157
0 
		rtncode = SA_ERR_HPI_INTERNAL_ERROR;
158
0 
		goto CLEANUP;
159
 
	}
160
 
161
81 
	eventdefs = g_strsplit(gstr, OH_ENCODE_DELIMITER_CHAR, -1);
162
81 
	if (eventdefs == NULL) {
163
0 
		rtncode = SA_ERR_HPI_INVALID_PARAMS;
164
0 
		goto CLEANUP;
165
 
	}
166
 
167
171 
	for (i=0; eventdefs[i] != NULL && eventdefs[i][0] != '\0'; i++) {
168
91 
		eventdefs[i] = g_strstrip(eventdefs[i]);
169
 
170
91 
		found_event = found_global_event = 0;
171
 
		/* Look for category event states */
172
7098 
		for (j=0; j<OH_MAX_STATE_STRINGS; j++) {
173
7007 
			if (strcasecmp(eventdefs[i], (char *)state_strings[j].str) == 0) {
174
120 
				found_event++;
175
 
                                /* Don't add twice for categories with duplicate events */
176
120 
				if (!(working_state & state_strings[j].state)) { 
177
88 
					working_state = working_state + state_strings[j].state;
178
 
				}
179
120 
				working_cat = state_strings[j].category;
180
 
			}
181
 
		}
182
 
		/* Look for global event states */
183
182 
		for (j=0; j<OH_MAX_STATE_GLOBAL_STRINGS; j++) {
184
91 
			if (strcasecmp(eventdefs[i], (char *)state_global_strings[j].str) == 0) {
185
1 
				found_global_event++;
186
 
                                /* Don't add twice for categories with duplicate events */
187
1 
				if (!(working_state & state_global_strings[j].state)) { 
188
1 
					working_state = working_state + state_global_strings[j].state;
189
 
				}
190
1 
				working_cat = state_global_strings[j].category;
191
 
			}
192
 
		}
193
 
194
91 
		if (!found_event && !found_global_event) {
195
1 
			rtncode = SA_ERR_HPI_INVALID_PARAMS;
196
1 
			goto CLEANUP;
197
 
		}
198
 
	}
199
 
	
200
80 
	if (oh_valid_eventstate(working_state, working_cat)) {
201
79 
		*event_state = working_state;
202
79 
		*event_cat = working_cat;
203
 
	}
204
 
	else {
205
1 
		rtncode = SA_ERR_HPI_INVALID_PARAMS;
206
 
	}
207
 
208
 
 CLEANUP:
209
81 
	g_free(gstr);
210
81 
	g_strfreev(eventdefs);
211
 
212
81 
	return(rtncode);
213
 
}
214
 
215
 
/**
216
 
 * oh_valid_eventstate:
217
 
 * @event_state: Event state bit field.
218
 
 * @event_cat: Event's category.
219
 
 * 
220
 
 * Validates that all the events in the event_state bit field are valid
221
 
 * for the event category. Routine also checks for mutually exclusive
222
 
 * events and that thresholds events have all the appropriate
223
 
 * lower-level threshold event states set.
224
 
 * 
225
 
 * Returns:
226
 
 * SAHPI_TRUE - Event(s) valid for category and met HPI spec criteria
227
 
 *              for exclusiveness and completeness.
228
 
 * SAHPI_FALSE - Any event(s) in bit field not valid for category or
229
 
 *               category is invalid.
230
 
 **/
231
 
SaHpiBoolT oh_valid_eventstate(SaHpiEventStateT event_state,
232
 
			       SaHpiEventCategoryT event_cat)
233
202 
{
234
202 
	SaHpiEventStateT valid_states;
235
 
236
202 
	switch(event_cat) {
237
 
	case SAHPI_EC_UNSPECIFIED:
238
 
		/* Only SAHPI_ES_UNSPECIFIED valid for this category */
239
6 
		if (event_state) {
240
1 
			return(SAHPI_FALSE);
241
 
		}
242
5 
		return(SAHPI_TRUE);
243
 
244
 
	case SAHPI_EC_THRESHOLD:
245
27 
		valid_states = SAHPI_ES_LOWER_MINOR |
246
 
			       SAHPI_ES_LOWER_MAJOR |
247
 
			       SAHPI_ES_LOWER_CRIT |
248
 
			       SAHPI_ES_UPPER_MINOR |
249
 
			       SAHPI_ES_UPPER_MAJOR |
250
 
  			       SAHPI_ES_UPPER_CRIT;
251
 
252
27 
		if (event_state & (~valid_states)) {
253
1 
			return(SAHPI_FALSE);
254
 
		}
255
 
256
 
		/* Check that all lower-level thresholds are set */
257
26 
		if (event_state & SAHPI_ES_LOWER_CRIT) {
258
4 
			if (!(event_state & SAHPI_ES_LOWER_MAJOR)) {
259
1 
				return(SAHPI_FALSE);
260
 
			}
261
 
		}
262
25 
		if (event_state & SAHPI_ES_LOWER_MAJOR) {
263
9 
			if (!(event_state & SAHPI_ES_LOWER_MINOR)) {
264
1 
				return(SAHPI_FALSE);
265
 
			}
266
 
		}
267
24 
		if (event_state & SAHPI_ES_UPPER_CRIT) {
268
5 
			if (!(event_state & SAHPI_ES_UPPER_MAJOR)) {
269
1 
				return(SAHPI_FALSE);
270
 
			}
271
 
		}
272
23 
		if (event_state & SAHPI_ES_UPPER_MAJOR) {
273
7 
			if (!(event_state & SAHPI_ES_UPPER_MINOR)) {
274
1 
				return(SAHPI_FALSE);
275
 
			}
276
 
		}
277
 
		
278
22 
		return(SAHPI_TRUE);
279
 
280
 
	case SAHPI_EC_USAGE:
281
8 
		valid_states = SAHPI_ES_IDLE |
282
 
			       SAHPI_ES_ACTIVE |
283
 
			       SAHPI_ES_BUSY;
284
 
285
 
		/* FIXME:: Are these mutally exclusive states?? */
286
8 
		if (event_state & (~valid_states)) {
287
2 
			return(SAHPI_FALSE);
288
 
		}
289
 
		
290
6 
		return(SAHPI_TRUE);
291
 
292
 
	case SAHPI_EC_STATE:
293
6 
		valid_states = SAHPI_ES_STATE_DEASSERTED |
294
 
			       SAHPI_ES_STATE_ASSERTED;
295
 
		
296
6 
		if (event_state & (~valid_states)) {
297
1 
			return(SAHPI_FALSE);
298
 
		}
299
 
		
300
 
		/* Enforce mutual exclusion */
301
5 
		if ((event_state & SAHPI_ES_STATE_DEASSERTED) &&
302
 
		    (event_state & SAHPI_ES_STATE_ASSERTED)) {
303
1 
			return(SAHPI_FALSE);		
304
 
		}
305
 
306
4 
		return(SAHPI_TRUE);
307
 
308
 
	case SAHPI_EC_PRED_FAIL:
309
6 
		valid_states = SAHPI_ES_PRED_FAILURE_DEASSERT |
310
 
			       SAHPI_ES_PRED_FAILURE_ASSERT;
311
 
312
6 
		if (event_state & (~valid_states)) {
313
1 
			return(SAHPI_FALSE);
314
 
		}
315
 
		
316
 
		/* Enforce mutual exclusion */
317
5 
		if ((event_state & SAHPI_ES_PRED_FAILURE_DEASSERT) &&
318
 
		    (event_state & SAHPI_ES_PRED_FAILURE_ASSERT)) {
319
1 
			return(SAHPI_FALSE);		
320
 
		}
321
 
322
4 
		return(SAHPI_TRUE);
323
 
324
 
	case SAHPI_EC_LIMIT:
325
6 
		valid_states = SAHPI_ES_LIMIT_NOT_EXCEEDED |
326
 
			       SAHPI_ES_LIMIT_EXCEEDED;
327
 
328
6 
		if (event_state & (~valid_states)) {
329
1 
			return(SAHPI_FALSE);
330
 
		}
331
 
		
332
 
		/* Enforce mutual exclusion */
333
5 
		if ((event_state & SAHPI_ES_LIMIT_NOT_EXCEEDED) &&
334
 
		    (event_state & SAHPI_ES_LIMIT_EXCEEDED)) {
335
1 
			return(SAHPI_FALSE);		
336
 
		}
337
 
338
4 
		return(SAHPI_TRUE);
339
 
340
 
	case SAHPI_EC_PERFORMANCE:
341
6 
		valid_states = SAHPI_ES_PERFORMANCE_MET |
342
 
			       SAHPI_ES_PERFORMANCE_LAGS;
343
 
344
6 
		if (event_state & (~valid_states)) {
345
1 
			return(SAHPI_FALSE);
346
 
		}
347
 
		
348
 
		/* Enforce mutual exclusion */
349
5 
		if ((event_state & SAHPI_ES_PERFORMANCE_MET) &&
350
 
		    (event_state & SAHPI_ES_PERFORMANCE_LAGS)) {
351
1 
			return(SAHPI_FALSE);		
352
 
		}
353
 
354
4 
		return(SAHPI_TRUE);
355
 
356
 
	case SAHPI_EC_SEVERITY:
357
 
		/* FIXME :: Any of these exclusive??? */
358
19 
		valid_states = SAHPI_ES_OK |
359
 
			       SAHPI_ES_MINOR_FROM_OK |
360
 
                               SAHPI_ES_MAJOR_FROM_LESS |
361
 
                               SAHPI_ES_CRITICAL_FROM_LESS |
362
 
                               SAHPI_ES_MINOR_FROM_MORE |
363
 
                               SAHPI_ES_MAJOR_FROM_CRITICAL |
364
 
                               SAHPI_ES_CRITICAL |
365
 
                               SAHPI_ES_MONITOR |
366
 
                               SAHPI_ES_INFORMATIONAL;
367
 
368
19 
		if (event_state & (~valid_states)) {
369
1 
			return(SAHPI_FALSE);
370
 
		}
371
 
372
18 
		return(SAHPI_TRUE);
373
 
374
 
	case SAHPI_EC_PRESENCE:
375
6 
		valid_states = SAHPI_ES_ABSENT |
376
 
			       SAHPI_ES_PRESENT;
377
 
378
6 
		if (event_state & (~valid_states)) {
379
1 
			return(SAHPI_FALSE);
380
 
		}
381
 
		
382
 
		/* Enforce mutual exclusion */
383
5 
		if ((event_state & SAHPI_ES_ABSENT) &&
384
 
		    (event_state & SAHPI_ES_PRESENT)) {
385
1 
			return(SAHPI_FALSE);		
386
 
		}
387
 
388
4 
		return(SAHPI_TRUE);
389
 
390
 
	case SAHPI_EC_ENABLE:
391
6 
		valid_states = SAHPI_ES_DISABLED |
392
 
			       SAHPI_ES_ENABLED;
393
 
394
6 
		if (event_state & (~valid_states)) {
395
1 
			return(SAHPI_FALSE);
396
 
		}
397
 
		
398
 
		/* Enforce mutual exclusion */
399
5 
		if ((event_state & SAHPI_ES_DISABLED) &&
400
 
		    (event_state & SAHPI_ES_ENABLED)) {
401
1 
			return(SAHPI_FALSE);		
402
 
		}
403
 
404
4 
		return(SAHPI_TRUE);
405
 
406
 
	case SAHPI_EC_AVAILABILITY:
407
 
		/* FIXME:: Any of these exclusive? */
408
19 
		valid_states = SAHPI_ES_RUNNING |
409
 
			       SAHPI_ES_TEST |
410
 
			       SAHPI_ES_POWER_OFF |
411
 
			       SAHPI_ES_ON_LINE |
412
 
			       SAHPI_ES_OFF_LINE |
413
 
			       SAHPI_ES_OFF_DUTY |
414
 
			       SAHPI_ES_DEGRADED |
415
 
			       SAHPI_ES_POWER_SAVE |
416
 
			       SAHPI_ES_INSTALL_ERROR;
417
 
418
19 
		if (event_state & (~valid_states)) {
419
1 
			return(SAHPI_FALSE);
420
 
		}
421
 
		
422
18 
		return(SAHPI_TRUE);
423
 
424
 
	case SAHPI_EC_REDUNDANCY:
425
22 
		valid_states = SAHPI_ES_FULLY_REDUNDANT |
426
 
			       SAHPI_ES_REDUNDANCY_LOST |
427
 
			       SAHPI_ES_REDUNDANCY_DEGRADED |
428
 
		  	       SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES |
429
 
			       SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES |
430
 
			       SAHPI_ES_NON_REDUNDANT_INSUFFICIENT_RESOURCES |
431
 
			       SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL |
432
 
			       SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON;
433
 
434
22 
		if (event_state & (~valid_states)) {
435
1 
			return(SAHPI_FALSE);
436
 
		}
437
 
		
438
 
		/* Check for mutual exclusiveness */
439
 
		/* Assume SAHPI_ES_REDUNDANCY_LOST or SAHPI_ES_REDUNDANCY_DEGRADED
440
 
                   must be set in addition to the bits that establish direction */
441
21 
		if (event_state & SAHPI_ES_FULLY_REDUNDANT) {
442
3 
			if (event_state != SAHPI_ES_FULLY_REDUNDANT) {
443
1 
				return(SAHPI_FALSE);
444
 
			}
445
 
		}
446
20 
		if (event_state & SAHPI_ES_REDUNDANCY_LOST) {
447
4 
			valid_states = SAHPI_ES_REDUNDANCY_LOST |
448
 
				       SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES |
449
 
				       SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES |
450
 
				       SAHPI_ES_NON_REDUNDANT_INSUFFICIENT_RESOURCES;
451
4 
			if (event_state & (~valid_states)) {
452
1 
				return(SAHPI_FALSE);
453
 
			}
454
 
		}
455
19 
		if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED) {
456
4 
			valid_states = SAHPI_ES_REDUNDANCY_DEGRADED |
457
 
				       SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL |
458
 
				       SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON;
459
4 
			if (event_state & (~valid_states)) {
460
1 
				return(SAHPI_FALSE);
461
 
			}
462
 
		}
463
18 
		if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL) {
464
3 
			if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON) {
465
1 
				return(SAHPI_FALSE);	
466
 
			}
467
 
		}
468
17 
		if (event_state & SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES) {
469
3 
			if (event_state & SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES) {
470
1 
				return(SAHPI_FALSE);	
471
 
			}
472
 
		}
473
 
474
16 
		return(SAHPI_TRUE);
475
 
476
 
	case SAHPI_EC_SENSOR_SPECIFIC:
477
 
	case SAHPI_EC_GENERIC:
478
64 
		valid_states = SAHPI_ES_STATE_00 |
479
 
			       SAHPI_ES_STATE_01 |
480
 
			       SAHPI_ES_STATE_02 |
481
 
			       SAHPI_ES_STATE_03 |
482
 
			       SAHPI_ES_STATE_04 |
483
 
			       SAHPI_ES_STATE_05 |
484
 
			       SAHPI_ES_STATE_06 |
485
 
			       SAHPI_ES_STATE_07 |
486
 
			       SAHPI_ES_STATE_08 |
487
 
			       SAHPI_ES_STATE_09 |
488
 
			       SAHPI_ES_STATE_10 |
489
 
			       SAHPI_ES_STATE_11 |
490
 
			       SAHPI_ES_STATE_12 |
491
 
			       SAHPI_ES_STATE_13 |
492
 
			       SAHPI_ES_STATE_14;
493
 
494
64 
		if (event_state & (~valid_states)) {
495
2 
			return(SAHPI_FALSE);
496
 
		}
497
 
		
498
62 
		return(SAHPI_TRUE);
499
 
500
 
	default:
501
1 
		return(SAHPI_FALSE);
502
 
	}
503
 
}
504
 
505
 
/**
506
 
 * oh_valid_addevent:
507
 
 * @event: Pointer to add event.
508
 
 * 
509
 
 * Validates @event is a valid event for SaHpiEventAdd. This routines makes 
510
 
 * all the checks specified in the HPI spec to see if @event is valid.
511
 
 * 
512
 
 * Returns:
513
 
 * SA_OK - Normal operation.
514
 
 * SA_ERR_HPI_INVALID_PARAMS - See HPI spec.
515
 
 **/
516
 
SaErrorT oh_valid_addevent(SaHpiEventT *event)
517
4 
{
518
4 
	if (!event) return(SA_ERR_HPI_INVALID_PARAMS);
519
 
	
520
4 
	if (event->Source != SAHPI_UNSPECIFIED_RESOURCE_ID ||
521
 
	    event->EventType != SAHPI_ET_USER ||
522
 
	    NULL == oh_lookup_severity(event->Severity) ||
523
 
	    !oh_valid_textbuffer(&(event->EventDataUnion.UserEvent.UserEventData))) {
524
3 
		return(SA_ERR_HPI_INVALID_PARAMS);
525
 
	}
526
 
527
 
	/* No check for implementation-specific restriction on to how much data may 
528
 
           be provided in the SAHPI_ET_USER event */
529
 
   
530
1 
	return(SA_OK);
531
 
}
532