On Fri, Jan 10, 2020 at 02:11:34PM +0200, Nikolay Borisov wrote:
> list_for_each_entry(fs_devices, &fs_uuids, fs_list) {
> - if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid,
> - BTRFS_FSID_SIZE) != 0 &&
> - memcmp(fs_devices->metadata_uuid, disk_super->metadata_uuid,
> - BTRFS_FSID_SIZE) == 0 &&
> - memcmp(fs_devices->fsid, disk_super->fsid,
> - BTRFS_FSID_SIZE) != 0) {
> + bool changed_fsdevices =
> + memcmp(fs_devices->metadata_uuid, fs_devices->fsid,
> + BTRFS_FSID_SIZE) != 0 &&
> + memcmp(fs_devices->metadata_uuid,
> + disk_super->metadata_uuid, BTRFS_FSID_SIZE) == 0 &&
> + memcmp(fs_devices->fsid, disk_super->fsid, BTRFS_FSID_SIZE) != 0;
> +
> + bool unchanged_fsdevices =
> + memcmp(fs_devices->metadata_uuid, fs_devices->fsid,
> + BTRFS_FSID_SIZE) == 0 &&
> + memcmp(fs_devices->fsid, disk_super->metadata_uuid, BTRFS_FSID_SIZE) == 0;
> + if (changed_fsdevices || unchanged_fsdevices)
> return fs_devices;
This is ugly, I've converted it to if (memcmp) and dropped the
variables.