Skip to content

Commit 78a3920

Browse files
[fix](be) Reuse segment magic constants in meta tool (#66897)
PR #66789 centralized the segment footer magic constants in `storage/segment/common.h`, but `meta_tool.cpp` still declared the same names locally in its segment read and write paths. When `BUILD_META_TOOL=ON`, Clang reports four `-Wshadow` diagnostics and the ASAN build fails because warnings are treated as errors. This change includes the defining header explicitly and reuses `doris::segment_v2::k_segment_magic` and `k_segment_magic_length` in both paths.
1 parent 36d2e85 commit 78a3920

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

be/src/tools/meta_tool.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include "storage/olap_common.h"
5454
#include "storage/options.h"
5555
#include "storage/segment/column_reader.h"
56+
#include "storage/segment/common.h"
5657
#include "storage/segment/encoding_info.h"
5758
#include "storage/segment/page_pointer.h"
5859
#include "storage/storage_engine.h"
@@ -288,9 +289,8 @@ Status get_segment_footer(doris::io::FileReader* file_reader, SegmentFooterPB* f
288289
RETURN_IF_ERROR(file_reader->read_at(file_size - 12, slice, &bytes_read));
289290

290291
// validate magic number
291-
const char* k_segment_magic = "D0R1";
292-
const uint32_t k_segment_magic_length = 4;
293-
if (memcmp(fixed_buf + 8, k_segment_magic, k_segment_magic_length) != 0) {
292+
if (memcmp(fixed_buf + 8, doris::segment_v2::k_segment_magic,
293+
doris::segment_v2::k_segment_magic_length) != 0) {
294294
return Status::Corruption("Bad segment file {}: magic number not match", file_name);
295295
}
296296

@@ -1034,9 +1034,8 @@ void gen_empty_segment() {
10341034
footer_slices.push_back(Slice(footer_checksum_buf, 4));
10351035

10361036
// Magic number (4 bytes): "D0R1"
1037-
const char* k_segment_magic = "D0R1";
1038-
const uint32_t k_segment_magic_length = 4;
1039-
footer_slices.push_back(Slice(k_segment_magic, k_segment_magic_length));
1037+
footer_slices.push_back(
1038+
Slice(doris::segment_v2::k_segment_magic, doris::segment_v2::k_segment_magic_length));
10401039

10411040
// Write index page first, then footer
10421041
for (const auto& slice : index_body) {

0 commit comments

Comments
 (0)