btrfs-progs: btrfstune: fix build-time detection of experimental features

Qu noticed that the full checksums are still printed even if the
experimental build is not enabled. This is caused by wrong use of #ifdef
(as the macro is always defined), this must be "#if".

Fixes: 1bb6fb896d ("btrfs-progs: btrfstune: experimental, new option to switch csums")
Reported-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-05-10 14:19:57 +02:00
parent 50a5dfde6d
commit f1178950d3
2 changed files with 6 additions and 4 deletions

View file

@ -794,7 +794,7 @@ static void print_usage(void)
printf(" general:\n");
printf("\t-f allow dangerous operations, make sure that you are aware of the dangers\n");
printf("\t--help print this help\n");
#ifdef EXPERIMENTAL
#if EXPERIMENTAL
printf("\nEXPERIMENTAL FEATURES:\n");
printf(" checksum changes:\n");
printf("\t--csum CSUM switch checksum for data and metadata to CSUM\n");
@ -821,7 +821,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
enum { GETOPT_VAL_CSUM = 256 };
static const struct option long_options[] = {
{ "help", no_argument, NULL, GETOPT_VAL_HELP},
#ifdef EXPERIMENTAL
#if EXPERIMENTAL
{ "csum", required_argument, NULL, GETOPT_VAL_CSUM },
#endif
{ NULL, 0, NULL, 0 }
@ -864,7 +864,7 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
ctree_flags |= OPEN_CTREE_IGNORE_FSID_MISMATCH;
change_metadata_uuid = 1;
break;
#ifdef EXPERIMENTAL
#if EXPERIMENTAL
case GETOPT_VAL_CSUM:
ctree_flags |= OPEN_CTREE_SKIP_CSUM_CHECK;
csum_type = parse_csum_type(optarg);

View file

@ -1218,7 +1218,9 @@ static void print_header_info(struct extent_buffer *eb, unsigned int mode)
{
struct btrfs_fs_info *fs_info = eb->fs_info;
char flags_str[128];
#if EXPERIMENTAL
u8 csum[BTRFS_CSUM_SIZE];
#endif
u64 flags;
u32 nr;
u8 backref_rev;
@ -1265,7 +1267,7 @@ static void print_header_info(struct extent_buffer *eb, unsigned int mode)
btrfs_header_bytenr(eb), flags, flags_str, backref_rev,
csum_str);
#ifdef EXPERIMENTAL
#if EXPERIMENTAL
printf("checksum stored ");
for (i = 0; i < csum_size; i++)
printf("%02hhx", (int)(eb->data[i]));