Gentoo Archives: eudev

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

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [eudev] [PATCH] use #pragma once for header files "Anthony G. Basile" <basile@××××××××××.net>