Re: [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else'

Ira Weiny
2025-11-07T00:44:26Z

Andy Shevchenko wrote:
> In the snippets like the following
>
> if (...)
> return / goto / break / continue ...;
> else
> ...
>
> the 'else' is redundant. Get rid of it.
>

I still need a why to in this commit message.

[snip]

> @@ -768,20 +768,20 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
> {
> if (claim_class == NVDIMM_CCLASS_BTT)
> return &nvdimm_btt_guid;
> - else if (claim_class == NVDIMM_CCLASS_BTT2)
> + if (claim_class == NVDIMM_CCLASS_BTT2)
> return &nvdimm_btt2_guid;
> - else if (claim_class == NVDIMM_CCLASS_PFN)
> + if (claim_class == NVDIMM_CCLASS_PFN)
> return &nvdimm_pfn_guid;
> - else if (claim_class == NVDIMM_CCLASS_DAX)
> + if (claim_class == NVDIMM_CCLASS_DAX)
> return &nvdimm_dax_guid;
> - else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> - /*
> - * If we're modifying a namespace for which we don't
> - * know the claim_class, don't touch the existing guid.
> - */
> - return target;
> - } else
> + if (claim_class == NVDIMM_CCLASS_NONE)
> return &guid_null;
> +
> + /*
> + * If we're modifying a namespace for which we don't
> + * know the claim_class, don't touch the existing guid.
> + */
> + return target;

This is not an equivalent change.

> }
>
> /* CXL labels store UUIDs instead of GUIDs for the same data */
> @@ -790,20 +790,20 @@ static const uuid_t *to_abstraction_uuid(enum nvdimm_claim_class claim_class,
> {
> if (claim_class == NVDIMM_CCLASS_BTT)
> return &nvdimm_btt_uuid;
> - else if (claim_class == NVDIMM_CCLASS_BTT2)
> + if (claim_class == NVDIMM_CCLASS_BTT2)
> return &nvdimm_btt2_uuid;
> - else if (claim_class == NVDIMM_CCLASS_PFN)
> + if (claim_class == NVDIMM_CCLASS_PFN)
> return &nvdimm_pfn_uuid;
> - else if (claim_class == NVDIMM_CCLASS_DAX)
> + if (claim_class == NVDIMM_CCLASS_DAX)
> return &nvdimm_dax_uuid;
> - else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> - /*
> - * If we're modifying a namespace for which we don't
> - * know the claim_class, don't touch the existing uuid.
> - */
> - return target;
> - } else
> + if (claim_class == NVDIMM_CCLASS_NONE)
> return &uuid_null;
> +
> + /*
> + * If we're modifying a namespace for which we don't
> + * know the claim_class, don't touch the existing uuid.
> + */
> + return target;

This is not an equivalent change.

Ira

[snip]