Skip to content

Commit 9febf1b

Browse files
committed
Enforce misc-include-cleaner on mkenvimage_slim
Also use include paths relative to the workspace root for files under //cuttlefish.
1 parent c4f1643 commit 9febf1b

File tree

4 files changed

+43
-6
lines changed

4 files changed

+43
-6
lines changed

base/cvd/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ filegroup(
3838
".clang-tidy",
3939
"//cuttlefish/host/commands/cvd/cli/commands:.clang-tidy",
4040
"//cuttlefish/host/commands/kernel_log_monitor:.clang-tidy",
41+
"//cuttlefish/host/commands/mkenvimage_slim:.clang-tidy",
4142
"//cuttlefish/host/commands/run_cvd/launch:.clang-tidy",
4243
],
4344
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# "clang-diagnostic-pragma-once-outside-header" has a bad interaction with the
2+
# `parse_headers` bazel feature.
3+
4+
Checks: &checks >-
5+
clang-analyzer-*,
6+
clang-diagnostic-*,
7+
-clang-diagnostic-pragma-once-outside-header,
8+
misc-definitions-in-headers,
9+
misc-include-cleaner,
10+
misc-unused-alias-decls,
11+
readability-avoid-const-params-in-decls,
12+
readability-const-return-type,
13+
readability-container-size-empty,
14+
readability-inconsistent-declaration-parameter-name,
15+
readability-misleading-indentation,
16+
readability-redundant-control-flow,
17+
readability-string-compare,
18+
19+
# Using the bazel clang-tidy helper, warnings are not shown from files that
20+
# don't have any errors. "*" here treats everything from `Checks` as an error,
21+
# and from there some exclusions are added.
22+
WarningsAsErrors: >
23+
*,
24+
-clang-analyzer-core.uninitialized.Assign,
25+
-clang-analyzer-core.UndefinedBinaryOperatorResult,
26+
-clang-diagnostic-builtin-macro-redefined,
27+
-clang-diagnostic-pragma-once-outside-header,
28+
-clang-diagnostic-unused-const-variable,
29+
-clang-diagnostic-unused-variable,

base/cvd/cuttlefish/host/commands/mkenvimage_slim/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package(
55
default_visibility = ["//:android_cuttlefish"],
66
)
77

8+
exports_files([".clang-tidy"])
9+
810
cc_binary(
911
name = "mkenvimage_slim",
1012
srcs = [

base/cvd/cuttlefish/host/commands/mkenvimage_slim/mkenvimage_slim.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@
1717
// https://github.com/u-boot/u-boot/blob/master/tools/mkenvimage.c The bare
1818
// minimum amount of functionality for our application is replicated.
1919

20+
#include <stdint.h>
21+
#include <stdlib.h>
22+
#include <string.h>
23+
2024
#include <zlib.h>
2125

26+
#include <vector>
27+
2228
#include <android-base/logging.h>
23-
#include <android-base/strings.h>
2429
#include <gflags/gflags.h>
2530

26-
#include "common/libs/fs/shared_buf.h"
27-
#include "common/libs/fs/shared_fd.h"
28-
#include "common/libs/utils/files.h"
29-
#include "common/libs/utils/result.h"
31+
#include "cuttlefish/common/libs/fs/shared_buf.h"
32+
#include "cuttlefish/common/libs/fs/shared_fd.h"
33+
#include "cuttlefish/common/libs/utils/files.h"
34+
#include "cuttlefish/common/libs/utils/result.h"
3035

3136
#define PAD_VALUE (0xff)
3237
#define CRC_SIZE (sizeof(uint32_t))
@@ -68,7 +73,7 @@ Result<int> MkenvimageSlimMain(int argc, char** argv) {
6873
uint32_t crc = crc32(0, env_ptr, FLAGS_env_size - CRC_SIZE);
6974
memcpy(env_buffer.data(), &crc, sizeof(uint32_t));
7075

71-
auto output_fd =
76+
auto output_fd = // NOLINTNEXTLINE(misc-include-cleaner)
7277
SharedFD::Creat(FLAGS_output_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
7378
if (!output_fd->IsOpen()) {
7479
return CF_ERR("Couldn't open the output file " + FLAGS_output_path);

0 commit comments

Comments
 (0)