[OpenWrt-Devel] [PATCH 1/3] kernel: improve ubi auto attach code readability

Mathias Kresin dev at kresin.me
Fri Jul 20 11:37:46 EDT 2018


2018-07-20 11:39 GMT+02:00 Felix Fietkau <nbd at nbd.name>:
> On 2018-07-19 19:05, Mathias Kresin wrote:
>> The early return on failed open of the mtd device allows to get rid of
>> one level of indentation.
>>
>> Move the put_mtd_device() called on multiple error conditions to a goto
>> label to use it later for more error conditions.
>>
>> While at it, make clear that we only check for the UBI magic if the read
>> from flash was successful.
>>
>> Signed-off-by: Mathias Kresin <dev at kresin.me>
> While you're touching this code, you could remove one more level of
> indentation (and fix a refcount bug) by writing:
>
>         if (mtd->type != MTD_NANDFLASH &&
>             mtd->type != MTD_NORFLASH &&
>             mtd->type != MTD_DATAFLASH &&
>             mtd->type != MTD_MLCNANDFLASH)
>                 goto cleanup;

Woho, I totally missed the refcount bug. Pushed an updated version of
the patch to may staging repo.

Mathias

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list