mtd/nftlmount: Adjustments for seven function implementations
Subsystems (2)
cover mtd/nftlmount: Adjustments for seven function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 6 Jan 2018 13:38:32 +0100
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete two error messages for a failed memory allocation in find_boot_record() Delete eight unwanted spaces behind function names
Add some spaces for better code readability
drivers/mtd/nftlmount.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
Signature · 1 line
2.15.1
PATCH 1/3 mtd/nftlmount: Delete two error messages for a failed memory allocation in find_boot_record()
From: Markus Elfring <[email protected]>
Date: Sat, 6 Jan 2018 11:04:59 +0100
Omit extra messages for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/mtd/nftlmount.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mtd/nftlmount.c +1 -4
@@ -201,15 +201,12 @@ device is already correct./* memory alloc */ nftl->EUNtable =kmalloc (nftl->nb_blocks *sizeof (u16),GFP_KERNEL ); -if (!nftl->EUNtable) { -printk (KERN_NOTICE "NFTL: allocation of EUNtable failed\n" ); +if (!nftl->EUNtable)return -ENOMEM ; - } nftl->ReplUnitTable =kmalloc (nftl->nb_blocks *sizeof (u16),GFP_KERNEL );if (!nftl->ReplUnitTable) {kfree (nftl->EUNtable); -printk (KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n" );return -ENOMEM ; }
Signature · 1 line
2.15.1
PATCH 2/3 mtd/nftlmount: Delete eight unwanted spaces behind function names
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 6 Jan 2018 12:55:23 +0100
The script "checkpatch.pl" pointed information out like the following.
WARNING: space prohibited between function name and open parenthesis '('
Thus fix the affected source code places.
--- drivers/mtd/nftlmount.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/mtd/nftlmount.c +14 -9
@@ -314,7 +314,7 @@ int NFTL_formatblock(struct NFTLrecord *nftl, int block) 8, &retlen, (char *)&uci) < 0) goto default_uci1; - erase_mark =le16_to_cpu ((uci.EraseMark | uci.EraseMark1)); + erase_mark =le16_to_cpu (uci.EraseMark | uci.EraseMark1);if (erase_mark !=ERASE_MARK ) { default_uci1: uci.EraseMark =cpu_to_le16 (ERASE_MARK );
@@ -501,11 +501,12 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block) &retlen, (char *)&h1) < 0)return -1 ; - erase_mark =le16_to_cpu ((h1.EraseMark | h1.EraseMark1)); + erase_mark =le16_to_cpu (h1.EraseMark | h1.EraseMark1);if (erase_mark !=ERASE_MARK ) {/* if no erase mark, the block must be totally free. This is possible in two cases : empty filesystem or interrupted erase (very unlikely) */ -if (check_free_sectors (nftl, block * nftl->EraseSize, nftl->EraseSize,1 ) !=0 ) +if (check_free_sectors (nftl, block * nftl->EraseSize, + nftl->EraseSize,1 ) !=0 )return -1 ;/* free block : write erase mark */
@@ -521,8 +522,9 @@ static int check_and_mark_free_block(struct NFTLrecord *nftl, int block)/* if erase mark present, need to skip it when doing check */ for (i =0 ; i < nftl->EraseSize; i +=SECTORSIZE ) {/* check free sector */ -if (check_free_sectors (nftl, block * nftl->EraseSize + i, -SECTORSIZE ,0 ) !=0 ) +if (check_free_sectors (nftl, + block * nftl->EraseSize + i, +SECTORSIZE ,0 ) !=0 )return -1 ; if (nftl_read_oob(mtd, block * nftl->EraseSize + i,
@@ -608,10 +610,13 @@ int NFTL_mount(struct NFTLrecord *s)break ; } - logical_block =le16_to_cpu ((h0.VirtUnitNum | h0.SpareVirtUnitNum)); - rep_block =le16_to_cpu ((h0.ReplUnitNum | h0.SpareReplUnitNum)); - nb_erases =le32_to_cpu (h1.WearInfo); - erase_mark =le16_to_cpu ((h1.EraseMark | h1.EraseMark1)); + logical_block =le16_to_cpu (h0.VirtUnitNum | + h0.SpareVirtUnitNum); + rep_block =le16_to_cpu (h0.ReplUnitNum | + h0.SpareReplUnitNum); + nb_erases =le32_to_cpu (h1.WearInfo); + erase_mark =le16_to_cpu (h1.EraseMark | + h1.EraseMark1); is_first_block = !(logical_block >>15 ); logical_block = logical_block &0x7fff ;
Signature · 1 line
2.15.1
PATCH 3/3 mtd/nftlmount: Add some spaces for better code readability
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 6 Jan 2018 12:58:37 +0100
Use space characters at some source code places according to the Linux coding style convention.
--- drivers/mtd/nftlmount.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nftlmount.c +4 -4
@@ -253,7 +253,7 @@ The new DiskOnChip driver already scanned the bad block table. Just query it. }/* foreach (block) */ -return boot_record_count?0 :-1 ; +return boot_record_count ?0 :-1 ; }static int memcmpb (void *a,int c,int n)
@@ -282,8 +282,8 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, intreturn -1 ;if (check_oob) { -if (nftl_read_oob (mtd, address, mtd->oobsize, - &retlen, &buf[SECTORSIZE ]) <0 ) +if (nftl_read_oob (mtd, address, mtd->oobsize, + &retlen, &buf[SECTORSIZE ]) <0 )return -1 ;if (memcmpb (buf +SECTORSIZE ,0xff , mtd->oobsize) !=0 )return -1 ;
@@ -389,7 +389,7 @@ static void check_sectors_in_chain(struct NFTLrecord *nftl, unsigned int first_belse status = bci.Status | bci.Status1; -switch (status) { +switch (status) {case SECTOR_FREE :/* verify that the sector is really free. If not, mark as ignore */
Signature · 1 line
2.15.1