Gentoo Archives: eudev

From: Marcus Folkesson <marcus.folkesson@×××××.com>
To: eudev@l.g.o
Cc: blueness@g.o, Marcus Folkesson <marcus.folkesson@×××××.com>
Subject: [eudev] [PATCH v2] consistently use #pragma once for header files
Date: Wed, 06 Dec 2017 12:56:17
Message-Id: 20171206125604.18125-1-marcus.folkesson@gmail.com
1 Some headerfiles are missing "#pragma once" or corresponding
2 "#ifndef..." which may result in build error if multiple source files
3 include the same file.
4
5 Use "#pragma once" for all header files.
6
7 Signed-off-by: Marcus Folkesson <marcus.folkesson@×××××.com>
8 ---
9 v2:
10 - Convert all #ifndef... to #pragma once
11 - Add *consistently* to patch description
12
13 src/libudev/libudev-hwdb-def.h | 5 +----
14 src/libudev/libudev-private.h | 5 +----
15 src/libudev/libudev.h | 5 +----
16 src/mtd_probe/mtd_probe.h | 2 ++
17 src/scsi_id/scsi.h | 2 ++
18 src/scsi_id/scsi_id.h | 2 ++
19 src/shared/MurmurHash2.h | 5 +----
20 src/shared/device-nodes.h | 2 ++
21 src/shared/fileio.h | 2 ++
22 src/shared/ioprio.h | 5 +----
23 src/shared/path-util.h | 2 ++
24 src/shared/siphash24.h | 3 +++
25 src/shared/socket-util.h | 2 ++
26 src/shared/sparse-endian.h | 6 ++----
27 src/udev/udevadm-util.h | 2 ++
28 15 files changed, 26 insertions(+), 24 deletions(-)
29
30 diff --git a/src/libudev/libudev-hwdb-def.h b/src/libudev/libudev-hwdb-def.h
31 index b76a13f3e..9fc60d258 100644
32 --- a/src/libudev/libudev-hwdb-def.h
33 +++ b/src/libudev/libudev-hwdb-def.h
34 @@ -17,8 +17,7 @@
35 along with systemd; If not, see <http://www.gnu.org/licenses/>.
36 ***/
37
38 -#ifndef _LIBUDEV_HWDB_DEF_H_
39 -#define _LIBUDEV_HWDB_DEF_H_
40 +#pragma once
41
42 #include "sparse-endian.h"
43
44 @@ -70,5 +69,3 @@ struct trie_value_entry_f {
45 le64_t key_off;
46 le64_t value_off;
47 } _packed_;
48 -
49 -#endif
50 diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
51 index 514bdde14..8d05994b6 100644
52 --- a/src/libudev/libudev-private.h
53 +++ b/src/libudev/libudev-private.h
54 @@ -17,8 +17,7 @@
55 along with systemd; If not, see <http://www.gnu.org/licenses/>.
56 ***/
57
58 -#ifndef _LIBUDEV_PRIVATE_H_
59 -#define _LIBUDEV_PRIVATE_H_
60 +#pragma once
61
62 #include <signal.h>
63 #include <stdint.h>
64 @@ -150,5 +149,3 @@ uint64_t util_string_bloom64(const char *str);
65
66 /* libudev-util-private.c */
67 int util_resolve_subsys_kernel(struct udev *udev, const char *string, char *result, size_t maxsize, int read_value);
68 -
69 -#endif
70 diff --git a/src/libudev/libudev.h b/src/libudev/libudev.h
71 index 0da4c9214..8491d2b81 100644
72 --- a/src/libudev/libudev.h
73 +++ b/src/libudev/libudev.h
74 @@ -17,8 +17,7 @@
75 along with systemd; If not, see <http://www.gnu.org/licenses/>.
76 ***/
77
78 -#ifndef _LIBUDEV_H_
79 -#define _LIBUDEV_H_
80 +#pragma once
81
82 #include <stdarg.h>
83 #include <sys/sysmacros.h>
84 @@ -205,5 +204,3 @@ int udev_util_encode_string(const char *str, char *str_enc, size_t len);
85 #ifdef __cplusplus
86 } /* extern "C" */
87 #endif
88 -
89 -#endif
90 diff --git a/src/mtd_probe/mtd_probe.h b/src/mtd_probe/mtd_probe.h
91 index e048a0122..caea5c269 100644
92 --- a/src/mtd_probe/mtd_probe.h
93 +++ b/src/mtd_probe/mtd_probe.h
94 @@ -17,6 +17,8 @@
95 * Boston, MA 02110-1301 USA
96 */
97
98 +#pragma once
99 +
100 #include <mtd/mtd-user.h>
101
102 #include "macro.h"
103 diff --git a/src/scsi_id/scsi.h b/src/scsi_id/scsi.h
104 index c423cac57..3f99ae772 100644
105 --- a/src/scsi_id/scsi.h
106 +++ b/src/scsi_id/scsi.h
107 @@ -10,6 +10,8 @@
108 * Free Software Foundation version 2 of the License.
109 */
110
111 +#pragma once
112 +
113 #include <scsi/scsi.h>
114
115 struct scsi_ioctl_command {
116 diff --git a/src/scsi_id/scsi_id.h b/src/scsi_id/scsi_id.h
117 index 648b5ce42..141b116a8 100644
118 --- a/src/scsi_id/scsi_id.h
119 +++ b/src/scsi_id/scsi_id.h
120 @@ -15,6 +15,8 @@
121 * along with this program. If not, see <http://www.gnu.org/licenses/>.
122 */
123
124 +#pragma once
125 +
126 #define MAX_PATH_LEN 512
127
128 /*
129 diff --git a/src/shared/MurmurHash2.h b/src/shared/MurmurHash2.h
130 index 93362dd48..7dc0b8365 100644
131 --- a/src/shared/MurmurHash2.h
132 +++ b/src/shared/MurmurHash2.h
133 @@ -2,8 +2,7 @@
134 // MurmurHash2 was written by Austin Appleby, and is placed in the public
135 // domain. The author hereby disclaims copyright to this source code.
136
137 -#ifndef _MURMURHASH2_H_
138 -#define _MURMURHASH2_H_
139 +#pragma once
140
141 //-----------------------------------------------------------------------------
142 // Platform-specific functions and macros
143 @@ -29,5 +28,3 @@ typedef unsigned __int64 uint64_t;
144 uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed );
145
146 //-----------------------------------------------------------------------------
147 -
148 -#endif // _MURMURHASH2_H_
149 diff --git a/src/shared/device-nodes.h b/src/shared/device-nodes.h
150 index d27ac0906..5df53e8c0 100644
151 --- a/src/shared/device-nodes.h
152 +++ b/src/shared/device-nodes.h
153 @@ -17,5 +17,7 @@
154 along with systemd; If not, see <http://www.gnu.org/licenses/>.
155 ***/
156
157 +#pragma once
158 +
159 int encode_devnode_name(const char *str, char *str_enc, size_t len);
160 int whitelisted_char_for_devnode(char c, const char *additional);
161 diff --git a/src/shared/fileio.h b/src/shared/fileio.h
162 index 641bf0230..7beed2eb8 100644
163 --- a/src/shared/fileio.h
164 +++ b/src/shared/fileio.h
165 @@ -17,6 +17,8 @@
166 along with systemd; If not, see <http://www.gnu.org/licenses/>.
167 ***/
168
169 +#pragma once
170 +
171 #include <stddef.h>
172 #include <stdio.h>
173
174 diff --git a/src/shared/ioprio.h b/src/shared/ioprio.h
175 index 950e59b23..7f047d255 100644
176 --- a/src/shared/ioprio.h
177 +++ b/src/shared/ioprio.h
178 @@ -1,5 +1,4 @@
179 -#ifndef IOPRIO_H
180 -#define IOPRIO_H
181 +#pragma once
182
183 /* This is minimal version of Linux' linux/ioprio.h header file, which
184 * is licensed GPL2 */
185 @@ -16,5 +15,3 @@ enum {
186 IOPRIO_CLASS_BE,
187 IOPRIO_CLASS_IDLE,
188 };
189 -
190 -#endif
191 diff --git a/src/shared/path-util.h b/src/shared/path-util.h
192 index 0123c2609..1d15d4c0f 100644
193 --- a/src/shared/path-util.h
194 +++ b/src/shared/path-util.h
195 @@ -17,6 +17,8 @@
196 along with systemd; If not, see <http://www.gnu.org/licenses/>.
197 ***/
198
199 +#pragma once
200 +
201 #include <stdbool.h>
202
203 #include "macro.h"
204 diff --git a/src/shared/siphash24.h b/src/shared/siphash24.h
205 index 3253c179b..c2c19b437 100644
206 --- a/src/shared/siphash24.h
207 +++ b/src/shared/siphash24.h
208 @@ -1,3 +1,6 @@
209 +
210 +#pragma once
211 +
212 #include <inttypes.h>
213 #include <sys/types.h>
214
215 diff --git a/src/shared/socket-util.h b/src/shared/socket-util.h
216 index 2daa3279f..52b8dff66 100644
217 --- a/src/shared/socket-util.h
218 +++ b/src/shared/socket-util.h
219 @@ -17,6 +17,8 @@
220 along with systemd; If not, see <http://www.gnu.org/licenses/>.
221 ***/
222
223 +#pragma once
224 +
225 #include <sys/socket.h>
226 #include <netinet/in.h>
227 #include <sys/un.h>
228 diff --git a/src/shared/sparse-endian.h b/src/shared/sparse-endian.h
229 index c913fda8c..7b7fa52dd 100644
230 --- a/src/shared/sparse-endian.h
231 +++ b/src/shared/sparse-endian.h
232 @@ -18,8 +18,8 @@
233 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
234 * IN THE SOFTWARE.
235 */
236 -#ifndef SPARSE_ENDIAN_H
237 -#define SPARSE_ENDIAN_H
238 +
239 +#pragma once
240
241 #include <byteswap.h>
242 #include <endian.h>
243 @@ -84,5 +84,3 @@ static inline uint64_t le64toh(le64_t value) { return bswap_64_on_be((uint64_t _
244 static inline uint16_t be16toh(be16_t value) { return bswap_16_on_le((uint16_t __force)value); }
245 static inline uint32_t be32toh(be32_t value) { return bswap_32_on_le((uint32_t __force)value); }
246 static inline uint64_t be64toh(be64_t value) { return bswap_64_on_le((uint64_t __force)value); }
247 -
248 -#endif /* SPARSE_ENDIAN_H */
249 diff --git a/src/udev/udevadm-util.h b/src/udev/udevadm-util.h
250 index dba651fdd..37e4fe836 100644
251 --- a/src/udev/udevadm-util.h
252 +++ b/src/udev/udevadm-util.h
253 @@ -15,6 +15,8 @@
254 * along with this program. If not, see <http://www.gnu.org/licenses/>.
255 */
256
257 +#pragma once
258 +
259 #include "udev.h"
260
261 struct udev_device *find_device(struct udev *udev,
262 --
263 2.15.0