btrfs-progs/check
Qu Wenruo e76fb663a7 btrfs-progs: check: Fix false alert about uninitialized variable
GCC 8.2.1 will report the following error:

  check/main.c: In function 'try_repair_inode':
  check/main.c:2606:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (!ret) {
       ^
  check/main.c:2584:6: note: 'ret' was declared here
    int ret;
        ^~~

The offending code is in repair_mismatch_dir_hash():

	int ret;

	printf(
	"Deleting bad dir items with invalid hash for root %llu ino %llu\n",
		root->root_key.objectid, rec->ino);
	while (!list_empty(&rec->mismatch_dir_hash)) {
		/* do some repair */
	}
	if (!ret) { <<< Here
		/* do some fix */
	}

The truth is, to enter try_repair_inode(), we must have
I_ERR_MISMATCH_DIR_HASH bit set for rec->errors.

And just after we set I_ERR_MISMATCH_DIR_HASH, we call
add_mismatch_dir_hash() and handled its error correctly.

So it's impossible to to skip the while loop.

Fix it by initializing @ret to -EUCLEAN, so even we hit some impossible
case, repair_mismatch_dir_hash() won't falsely consider the mismatch
hash fixed.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-03-05 12:57:41 +01:00
..
main.c btrfs-progs: check: Fix false alert about uninitialized variable 2019-03-05 12:57:41 +01:00
mode-common.c btrfs-progs: check: lowmem: Add ability to repair dir item with mismatched hash 2019-01-15 18:42:13 +01:00
mode-common.h btrfs-progs: check: lowmem: Add ability to repair dir item with mismatched hash 2019-01-15 18:42:13 +01:00
mode-lowmem.c btrfs-progs: check: lowmem: Add ability to repair dir item with mismatched hash 2019-01-15 18:42:13 +01:00
mode-lowmem.h btrfs-progs: check: lowmem: Add ability to repair dir item with mismatched hash 2019-01-15 18:42:13 +01:00
mode-original.h btrfs-progs: check: orig: Use mismatch_dir_hash_record to record bad dir items 2019-01-15 18:42:13 +01:00