1 |
On 12/5/17 1:28 PM, Marcus Folkesson wrote: |
2 |
> Hi Anthony, |
3 |
> |
4 |
> On Tue, Dec 05, 2017 at 01:15:59PM -0500, Anthony G. Basile wrote: |
5 |
>> On 12/4/17 6:34 AM, Marcus Folkesson wrote: |
6 |
>>> Some headerfiles are missing "#pragma once" or corresponding |
7 |
>>> "#ifndef..." which may result in build error if multiple source files |
8 |
>>> include the same file. |
9 |
>>> |
10 |
>>> Add "#pragma once" for concerned files. |
11 |
>>> |
12 |
>>> Signed-off-by: Marcus Folkesson <marcus.folkesson@×××××.com> |
13 |
>>> --- |
14 |
>>> src/mtd_probe/mtd_probe.h | 2 ++ |
15 |
>>> src/scsi_id/scsi.h | 2 ++ |
16 |
>>> src/scsi_id/scsi_id.h | 2 ++ |
17 |
>>> src/shared/device-nodes.h | 2 ++ |
18 |
>>> src/shared/fileio.h | 2 ++ |
19 |
>>> src/shared/path-util.h | 2 ++ |
20 |
>>> src/shared/siphash24.h | 3 +++ |
21 |
>>> src/shared/socket-util.h | 2 ++ |
22 |
>>> src/udev/udevadm-util.h | 2 ++ |
23 |
>>> 9 files changed, 19 insertions(+) |
24 |
>>> |
25 |
>>> diff --git a/src/mtd_probe/mtd_probe.h b/src/mtd_probe/mtd_probe.h |
26 |
>>> index e048a0122..caea5c269 100644 |
27 |
>>> --- a/src/mtd_probe/mtd_probe.h |
28 |
>>> +++ b/src/mtd_probe/mtd_probe.h |
29 |
>>> @@ -17,6 +17,8 @@ |
30 |
>>> * Boston, MA 02110-1301 USA |
31 |
>>> */ |
32 |
>>> |
33 |
>>> +#pragma once |
34 |
>>> + |
35 |
>>> #include <mtd/mtd-user.h> |
36 |
>>> |
37 |
>>> #include "macro.h" |
38 |
>>> diff --git a/src/scsi_id/scsi.h b/src/scsi_id/scsi.h |
39 |
>>> index c423cac57..3f99ae772 100644 |
40 |
>>> --- a/src/scsi_id/scsi.h |
41 |
>>> +++ b/src/scsi_id/scsi.h |
42 |
>>> @@ -10,6 +10,8 @@ |
43 |
>>> * Free Software Foundation version 2 of the License. |
44 |
>>> */ |
45 |
>>> |
46 |
>>> +#pragma once |
47 |
>>> + |
48 |
>>> #include <scsi/scsi.h> |
49 |
>>> |
50 |
>>> struct scsi_ioctl_command { |
51 |
>>> diff --git a/src/scsi_id/scsi_id.h b/src/scsi_id/scsi_id.h |
52 |
>>> index 648b5ce42..141b116a8 100644 |
53 |
>>> --- a/src/scsi_id/scsi_id.h |
54 |
>>> +++ b/src/scsi_id/scsi_id.h |
55 |
>>> @@ -15,6 +15,8 @@ |
56 |
>>> * along with this program. If not, see <http://www.gnu.org/licenses/>. |
57 |
>>> */ |
58 |
>>> |
59 |
>>> +#pragma once |
60 |
>>> + |
61 |
>>> #define MAX_PATH_LEN 512 |
62 |
>>> |
63 |
>>> /* |
64 |
>>> diff --git a/src/shared/device-nodes.h b/src/shared/device-nodes.h |
65 |
>>> index d27ac0906..5df53e8c0 100644 |
66 |
>>> --- a/src/shared/device-nodes.h |
67 |
>>> +++ b/src/shared/device-nodes.h |
68 |
>>> @@ -17,5 +17,7 @@ |
69 |
>>> along with systemd; If not, see <http://www.gnu.org/licenses/>. |
70 |
>>> ***/ |
71 |
>>> |
72 |
>>> +#pragma once |
73 |
>>> + |
74 |
>>> int encode_devnode_name(const char *str, char *str_enc, size_t len); |
75 |
>>> int whitelisted_char_for_devnode(char c, const char *additional); |
76 |
>>> diff --git a/src/shared/fileio.h b/src/shared/fileio.h |
77 |
>>> index 641bf0230..7beed2eb8 100644 |
78 |
>>> --- a/src/shared/fileio.h |
79 |
>>> +++ b/src/shared/fileio.h |
80 |
>>> @@ -17,6 +17,8 @@ |
81 |
>>> along with systemd; If not, see <http://www.gnu.org/licenses/>. |
82 |
>>> ***/ |
83 |
>>> |
84 |
>>> +#pragma once |
85 |
>>> + |
86 |
>>> #include <stddef.h> |
87 |
>>> #include <stdio.h> |
88 |
>>> |
89 |
>>> diff --git a/src/shared/path-util.h b/src/shared/path-util.h |
90 |
>>> index 0123c2609..1d15d4c0f 100644 |
91 |
>>> --- a/src/shared/path-util.h |
92 |
>>> +++ b/src/shared/path-util.h |
93 |
>>> @@ -17,6 +17,8 @@ |
94 |
>>> along with systemd; If not, see <http://www.gnu.org/licenses/>. |
95 |
>>> ***/ |
96 |
>>> |
97 |
>>> +#pragma once |
98 |
>>> + |
99 |
>>> #include <stdbool.h> |
100 |
>>> |
101 |
>>> #include "macro.h" |
102 |
>>> diff --git a/src/shared/siphash24.h b/src/shared/siphash24.h |
103 |
>>> index 3253c179b..c2c19b437 100644 |
104 |
>>> --- a/src/shared/siphash24.h |
105 |
>>> +++ b/src/shared/siphash24.h |
106 |
>>> @@ -1,3 +1,6 @@ |
107 |
>>> + |
108 |
>>> +#pragma once |
109 |
>>> + |
110 |
>>> #include <inttypes.h> |
111 |
>>> #include <sys/types.h> |
112 |
>>> |
113 |
>>> diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h |
114 |
>>> index 2daa3279f..52b8dff66 100644 |
115 |
>>> --- a/src/shared/socket-util.h |
116 |
>>> +++ b/src/shared/socket-util.h |
117 |
>>> @@ -17,6 +17,8 @@ |
118 |
>>> along with systemd; If not, see <http://www.gnu.org/licenses/>. |
119 |
>>> ***/ |
120 |
>>> |
121 |
>>> +#pragma once |
122 |
>>> + |
123 |
>>> #include <sys/socket.h> |
124 |
>>> #include <netinet/in.h> |
125 |
>>> #include <sys/un.h> |
126 |
>>> diff --git a/src/udev/udevadm-util.h b/src/udev/udevadm-util.h |
127 |
>>> index dba651fdd..37e4fe836 100644 |
128 |
>>> --- a/src/udev/udevadm-util.h |
129 |
>>> +++ b/src/udev/udevadm-util.h |
130 |
>>> @@ -15,6 +15,8 @@ |
131 |
>>> * along with this program. If not, see <http://www.gnu.org/licenses/>. |
132 |
>>> */ |
133 |
>>> |
134 |
>>> +#pragma once |
135 |
>>> + |
136 |
>>> #include "udev.h" |
137 |
>>> |
138 |
>>> struct udev_device *find_device(struct udev *udev, |
139 |
>>> |
140 |
>> |
141 |
>> I know we have some clang users. Does #pragma work for clang? |
142 |
>> |
143 |
> Actually I don't know. But #pragma is used for most of the headers already: |
144 |
> |
145 |
> [19:21:38]marcus@little:~/git/eudev$ git grep pragma |
146 |
> src/shared/conf-files.h:21:#pragma once |
147 |
> src/shared/def.h:20:#pragma once |
148 |
> src/shared/dev-setup.h:20:#pragma once |
149 |
> src/shared/formats-util.h:1:#pragma once |
150 |
> src/shared/hashmap.h:3:#pragma once |
151 |
> src/shared/label.h:20:#pragma once |
152 |
> src/shared/list.h:3:#pragma once |
153 |
> src/shared/log.h:20:#pragma once |
154 |
> src/shared/macro.h:20:#pragma once |
155 |
> src/shared/mempool.h:3:#pragma once |
156 |
> src/shared/missing.h:20:#pragma once |
157 |
> src/shared/mkdir.h:20:#pragma once |
158 |
> src/shared/process-util.h:1:#pragma once |
159 |
> src/shared/random-util.h:1:#pragma once |
160 |
> src/shared/selinux-util.h:20:#pragma once |
161 |
> src/shared/set.h:3:#pragma once |
162 |
> src/shared/smack-util.h:22:#pragma once |
163 |
> src/shared/strbuf.h:20:#pragma once |
164 |
> src/shared/strv.h:20:#pragma once |
165 |
> src/shared/strxcpyx.h:20:#pragma once |
166 |
> src/shared/sysctl-util.h:3:#pragma once |
167 |
> src/shared/terminal-util.h:1:#pragma once |
168 |
> src/shared/time-util.h:20:#pragma once |
169 |
> src/shared/udev-util.h:20:#pragma once |
170 |
> src/shared/utf8.h:20:#pragma once |
171 |
> src/shared/util.h:20:#pragma once |
172 |
> src/shared/virt.h:20:#pragma once |
173 |
> src/udev/udev.h:19:#pragma once |
174 |
> |
175 |
> Only a few headers in src/libudev/ is using the #ifndef-#define-#endif |
176 |
> what I can tell. |
177 |
> |
178 |
> Maybe I should convert those to #pragma instead to keep it uniform. |
179 |
> |
180 |
> |
181 |
> Best regards |
182 |
> Marcus Folkesson |
183 |
|
184 |
|
185 |
Yeah let's switch everything to #pragma and get rid of the ifndefs. |
186 |
clang does respect gcc's #pragma's. See |
187 |
|
188 |
http://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas |
189 |
|
190 |
I think a single commit in which you sqaush your previous commit |
191 |
together with removing the ifndefs would be best. The commit message |
192 |
could be something like "consistenlty use #pragma to avoid double |
193 |
inclusion of headers" or similar. |
194 |
|
195 |
-- |
196 |
Anthony G. Basile, Ph.D. |
197 |
Gentoo Linux Developer [Hardened] |
198 |
E-Mail : basile@××××××××××.net |
199 |
GnuPG FP : 1FED FAD9 D82C 52A5 3BAB DC79 9384 FA6E F52D 4BBA |
200 |
GnuPG ID : F52D4BBA |