Skip to content

Commit 2aa4f74

Browse files
added a check for the presence of #pragma once in files (#1478)
1 parent aa152f9 commit 2aa4f74

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+83
-223
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ jobs:
3434
exit 1
3535
fi
3636
37+
- name: Check "#pragma once" in files
38+
run: |
39+
EXIT_CODE=0
40+
for file in $(find . -name '*.h' -type f \( -path './common/*' -o -path './runtime/*' -o -path './runtime-common/*' -o -path './runtime-light/*' \)); do
41+
if [[ $( grep -q -E '^#pragma\ once' "$file" )$? -ne 0 ]]; then
42+
echo "Missing '#pragma once' in file '$file'"
43+
EXIT_CODE=1
44+
fi
45+
done
46+
47+
if [[ $EXIT_CODE -ne 0 ]]; then
48+
echo "There are errors in the files, please fix them.";
49+
exit 1
50+
fi
51+
3752
- name: Install clang-format
3853
run: sudo apt-get install -y clang-format-18
3954

common/algorithms/arithmetic.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef ENGINE_ALGO_ARITHMETIC_H
6-
#define ENGINE_ALGO_ARITHMETIC_H
5+
#pragma once
76

87
#include <limits.h>
98
#include <stdlib.h>
@@ -18,5 +17,3 @@ static inline int saturating_abs(int x) {
1817
static inline int align4(int x) {
1918
return (x + 3) & -4;
2019
}
21-
22-
#endif // ENGINE_ALGO_ARITHMETIC_H

common/algorithms/compare.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef ENGINE_COMMON_ALGO_COMPARE_H
6-
#define ENGINE_COMMON_ALGO_COMPARE_H
5+
#pragma once
76

87
#include <algorithm>
98
#include <iterator>
@@ -44,5 +43,3 @@ bool any_of(const Range& range, Predicate p) {
4443
}
4544

4645
} // namespace vk
47-
48-
#endif // ENGINE_COMMON_ALGO_COMPARE_H

common/algorithms/hashes.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef ENGINE_HASHES_H
6-
#define ENGINE_HASHES_H
5+
#pragma once
76

87
#include <array>
98
#include <cstddef>
@@ -95,5 +94,3 @@ class hash<vk::span<T>> {
9594
};
9695

9796
} // namespace std
98-
99-
#endif // ENGINE_HASHES_H

common/allocators/freelist.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef KDB_COMMON_ALLOCATORS_FREELIST_H
6-
#define KDB_COMMON_ALLOCATORS_FREELIST_H
5+
#pragma once
76

87
#include <sys/cdefs.h>
98

@@ -20,5 +19,3 @@ void freelist_init(freelist_t* freelist);
2019
void* freelist_get(freelist_t* freelist);
2120
bool freelist_try_put(freelist_t* freelist, void* ptr);
2221
void freelist_put(freelist_t* freelist, void* ptr);
23-
24-
#endif // KDB_COMMON_ALLOCATORS_FREELIST_H

common/allocators/lockfree-slab.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef KDB_COMMON_ALLOCATORS_LOCKFREE_SLAB_H
6-
#define KDB_COMMON_ALLOCATORS_LOCKFREE_SLAB_H
5+
#pragma once
76

87
#include <sys/cdefs.h>
98
#include <sys/queue.h>
@@ -73,5 +72,3 @@ static inline void* lockfree_slab_cache_alloc0(lockfree_slab_cache_tls_t* cache_
7372

7473
void lockfree_slab_cache_free(lockfree_slab_cache_tls_t* cache_tls, void* object);
7574
void lockfree_slab_cache_clear(lockfree_slab_cache_tls_t* cache_tls);
76-
77-
#endif // KDB_COMMON_ALLOCATORS_LOCKFREE_SLAB_H

common/binlog/binlog-buffer-replay.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef ENGINE_BINLOG_BUFFER_REPLAY_H
6-
#define ENGINE_BINLOG_BUFFER_REPLAY_H
5+
#pragma once
76

87
#include <stddef.h>
98

@@ -23,5 +22,3 @@ hash_t bb_buffer_calc_binlog_hash(struct bb_buffer* B, struct lev_rotate_to* nex
2322
hash_t binlog_relax_hash(hash_t prev_hash, long long pos, unsigned log_crc32);
2423

2524
extern struct bb_reader_functions bbr_replay_functions;
26-
27-
#endif // ENGINE_BINLOG_BUFFER_REPLAY_H

common/binlog/binlog-buffer-rotation-points.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef ENGINE_BINLOG_BUFFER_ROTATION_POINTS_H
6-
#define ENGINE_BINLOG_BUFFER_ROTATION_POINTS_H
5+
#pragma once
76

87
#include <sys/cdefs.h>
98

@@ -20,5 +19,3 @@ void bb_rotation_point_assign(struct bb_rotation_point** lhs, struct bb_rotation
2019

2120
void bb_rotation_point_close_binlog(struct bb_rotation_point* p);
2221
void bb_rotation_point_free(struct bb_rotation_point* p);
23-
24-
#endif // ENGINE_BINLOG_BUFFER_ROTATION_POINTS_H

common/binlog/binlog-buffer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2020 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef __KDB_BINLOG_BUFFER_H__
6-
#define __KDB_BINLOG_BUFFER_H__
5+
#pragma once
76

87
#include <aio.h>
98
#include <functional>
@@ -175,4 +174,3 @@ void bb_buffer_init(bb_buffer_t* B, bb_writer_t* W, bb_reader_t* R, std::functio
175174

176175
void bb_buffer_open_to_replay(bb_buffer_t* buffer, bb_writer_t* writer, bb_reader_t* reader, kfs_replica_t* replica,
177176
std::function<int(const struct lev_generic*, int)> replay_func);
178-
#endif

common/binlog/binlog-stats.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// Copyright (c) 2024 LLC «V Kontakte»
33
// Distributed under the GPL v3 License, see LICENSE.notice.txt
44

5-
#ifndef KPHP_BINLOG_STATS_H
6-
#define KPHP_BINLOG_STATS_H
5+
#pragma once
76

87
#include <chrono>
98

@@ -19,4 +18,3 @@ struct binlog_reader_stats : private vk::not_copyable {
1918
std::chrono::seconds next_binlog_wait_time{std::chrono::seconds::zero()};
2019
vk::string_view next_binlog_expectator_name;
2120
};
22-
#endif // KPHP_BINLOG_STATS_H

0 commit comments

Comments
 (0)