Print this page
10075 make usr/src/tools smatch clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/protocmp/exception_list.c
+++ new/usr/src/tools/protocmp/exception_list.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
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ 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 2010 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 *
26 26 * Copyright 2015 PALO, Richard
27 + *
28 + * Copyright (c) 2018, Joyent, Inc.
27 29 */
28 30
29 31 #include <stdio.h>
30 32 #include <stdlib.h>
31 33 #include <string.h>
32 34
33 35 #include "list.h"
34 36 #include "exception_list.h"
35 37 #include "arch.h"
36 38
37 39 /*
38 40 * This is global so that the protodir reading functions can rely on the
39 41 * exception list to weed out innocuous problems in the IHV gate.
40 42 */
41 43 elem_list exception_list;
42 44
43 45 #define FS " \t\n"
44 46
45 47 static int
46 48 parse_exception_line(char *line, elem_list *list)
47 49 {
48 50 char *name, *arch;
49 51 elem *e;
50 52
51 53 if ((name = strtok(line, FS)) == NULL) {
52 54 /* don't complain; this is only a blank line */
53 55 return (0);
54 56 }
55 57
56 58 if ((arch = strtok(NULL, FS)) == NULL) {
57 59 arch = "all";
58 60 }
59 61
60 62 e = (elem *) malloc(sizeof (elem));
61 63 if (e == NULL) {
62 64 perror("malloc");
63 65 exit(1);
64 66 }
65 67
66 68 e->inode = 0;
67 69 e->perm = 0;
68 70 e->ref_cnt = 0;
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
69 71 e->flag = 0;
70 72 e->major = 0;
71 73 e->minor = 0;
72 74 e->link_parent = NULL;
73 75 e->link_sib = NULL;
74 76 e->symsrc = NULL;
75 77 e->file_type = DIR_T;
76 78
77 79 while ((e->arch = assign_arch(arch)) == 0) {
78 80 if ((arch = strtok(NULL, FS)) == NULL) {
81 + free(e);
79 82 return (0);
80 83 }
81 84 }
82 85
83 86 (void) strcpy(e->name, name);
84 87 add_elem(list, e);
85 88
86 89 return (1);
87 90 }
88 91
89 92 int
90 93 read_in_exceptions(const char *exception_file, int verbose)
91 94 {
92 95 FILE *except_fp;
93 96 char buf[BUFSIZ];
94 97 int count = 0;
95 98
96 99 exception_file = exception_file ? exception_file : EXCEPTION_FILE;
97 100
98 101 if (verbose) {
99 102 (void) printf("reading in exceptions from %s...\n",
100 103 exception_file);
101 104 }
102 105
103 106 if ((except_fp = fopen(exception_file, "r")) == NULL) {
104 107 perror(exception_file);
105 108 return (0);
106 109 }
107 110 while (fgets(buf, BUFSIZ, except_fp)) {
108 111 if (buf[0] != '#') /* allow for comments */
109 112 count += parse_exception_line(buf, &exception_list);
110 113 }
111 114 if (verbose)
112 115 (void) printf("read in %d exceptions...\n", count);
113 116
114 117 return (count);
115 118 }
↓ open down ↓ |
27 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX