From 660db6b248d5ebbb83f87f409ffa74755d2bbbcd Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Sun, 22 Nov 2020 09:50:13 +0900 Subject: [PATCH] fs/nxffs/nxffs_pack.c: Appease nxstyle --- fs/nxffs/nxffs_pack.c | 143 ++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 62 deletions(-) diff --git a/fs/nxffs/nxffs_pack.c b/fs/nxffs/nxffs_pack.c index a87a88f13d..4216d412fc 100644 --- a/fs/nxffs/nxffs_pack.c +++ b/fs/nxffs/nxffs_pack.c @@ -337,7 +337,8 @@ static inline int nxffs_startpos(FAR struct nxffs_volume_s *volume, */ nbytes += blkentry.datlen; - offset = blkentry.hoffset + SIZEOF_NXFFS_DATA_HDR + blkentry.datlen; + offset = blkentry.hoffset + SIZEOF_NXFFS_DATA_HDR + + blkentry.datlen; } /* Make sure there is space at this location for an inode header */ @@ -454,10 +455,10 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, /* The destination can be in one of three of states: * * State 1: The inode position was not yet been found. This condition can - * only occur on initial entry into nxffs_packblock() when there we no space - * for the inode header at the end of the previous block. We must now be - * at the beginning of a shiny new I/O block, so we should always have - * space for a new inode header right here. + * only occur on initial entry into nxffs_packblock() when there we no + * space for the inode header at the end of the previous block. We must + * now be at the beginning of a shiny new I/O block, so we should always + * have space for a new inode header right here. */ if (pack->dest.entry.hoffset == 0) @@ -528,8 +529,8 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, pack->iooffset += namlen; } - /* State 3: Inode header not-written, inode name written. Still need the position - * of the first data block. + /* State 3: Inode header not-written, inode name written. Still need the + * position of the first data block. * * Deal with the special case where the source inode is a zero length file * with no data blocks to be transferred. @@ -539,16 +540,16 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, { if (pack->dest.entry.doffset == 0) { - /* Will the data block header plus a minimal amount of data fit in this - * block? (or the whole file if the file is very small). + /* Will the data block header plus a minimal amount of data fit in + * this block? (or the whole file if the file is very small). */ mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen); if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata > volume->geo.blocksize) { - /* No.. return an indication that we are at the end of the block - * and try again later. + /* No.. return an indication that we are at the end of the + * block and try again later. */ ret = -ENOSPC; @@ -560,29 +561,31 @@ static int nxffs_destsetup(FAR struct nxffs_volume_s *volume, pack->dest.entry.doffset = nxffs_packtell(volume, pack); pack->iooffset += SIZEOF_NXFFS_DATA_HDR; - /* Initialize the output data stream to start with the first data block */ + /* Initialize the output data stream to start with the first data + * block + */ pack->dest.blkoffset = pack->dest.entry.doffset; pack->dest.blklen = 0; pack->dest.blkpos = 0; } - /* State 4: Starting a new block. Verify that there is space in the current - * block for another (minimal sized) block + /* State 4: Starting a new block. Verify that there is space in the + * current block for another (minimal sized) block */ if (pack->dest.blkoffset == 0) { - /* Will the data block header plus a minimal amount of data fit in this - * block? (or the whole file if the file is very small). + /* Will the data block header plus a minimal amount of data fit in + * this block? (or the whole file if the file is very small). */ mindata = MIN(NXFFS_MINDATA, pack->dest.entry.datlen); if (pack->iooffset + SIZEOF_NXFFS_DATA_HDR + mindata > volume->geo.blocksize) { - /* No.. return an indication that we are at the end of the block - * and try again later. + /* No.. return an indication that we are at the end of the + * block and try again later. */ ret = -ENOSPC; @@ -691,7 +694,8 @@ static int nxffs_wrinodehdr(FAR struct nxffs_volume_s *volume, /* Calculate the CRC */ crc = crc32((FAR const uint8_t *)inode, SIZEOF_NXFFS_INODE_HDR); - crc = crc32part((FAR const uint8_t *)pack->dest.entry.name, namlen, crc); + crc = crc32part((FAR const uint8_t *)pack->dest.entry.name, namlen, + crc); /* Finish the inode header */ @@ -742,9 +746,9 @@ static void nxffs_wrdathdr(FAR struct nxffs_volume_s *volume, if (pack->dest.blklen > 0) { - /* Get the offset in the block corresponding to the location of the data - * block header. NOTE: This must lie in the same block as we currently have - * buffered. + /* Get the offset in the block corresponding to the location of the + * data block header. NOTE: This must lie in the same block as we + * currently have buffered. */ ioblock = nxffs_getblock(volume, pack->dest.blkoffset); @@ -928,8 +932,8 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, } /* Loop, transferring data from the source block to the destination pack - * buffer until either (1) the source stream is exhausted, (2) the destination - * block is full, or (3) an error occurs. + * buffer until either (1) the source stream is exhausted, (2) the + * destination block is full, or (3) an error occurs. */ for (; ; ) @@ -962,8 +966,8 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, ret = nxffs_nextentry(volume, offset, &pack->src.entry); if (ret < 0) { - /* No more valid inode entries. Just return an end-of-flash error - * indication. + /* No more valid inode entries. Just return an end-of-flash + * error indication. */ return -ENOSPC; @@ -989,10 +993,11 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, * the inode header? */ - if (pack->iooffset + SIZEOF_NXFFS_INODE_HDR > volume->geo.blocksize) + if (pack->iooffset + SIZEOF_NXFFS_INODE_HDR > + volume->geo.blocksize) { - /* No, just return success... we will handle this condition when - * this function is called on the next I/O block. + /* No, just return success... we will handle this condition + * when this function is called on the next I/O block. */ return OK; @@ -1003,9 +1008,9 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, ret = nxffs_destsetup(volume, pack); if (ret < 0) { - /* -ENOSPC is a special return value which simply means that all of the - * has been used up to the end. We need to return OK in this case and - * resume at the next block. + /* -ENOSPC is a special return value which simply means that + * all of the has been used up to the end. We need to return + * OK in this case and resume at the next block. */ if (ret == -ENOSPC) @@ -1014,7 +1019,8 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, } else { - ferr("ERROR: Failed to configure the dest stream: %d\n", -ret); + ferr("ERROR: Failed to configure the dest stream: %d\n", + -ret); return ret; } } @@ -1037,7 +1043,9 @@ static inline int nxffs_packblock(FAR struct nxffs_volume_s *volume, if (pack->iooffset >= volume->geo.blocksize) { - /* Yes.. Write the destination data block header and return success */ + /* Yes.. Write the destination data block header and return + * success + */ nxffs_wrdathdr(volume, pack); return OK; @@ -1081,10 +1089,10 @@ nxffs_setupwriter(FAR struct nxffs_volume_s *volume, * this packing activity. The writer may have failed in one of several * different stages: * - * hoffset == 0: The write failed early before even FLASH for the inode - * header was set aside. - * noffset == 0: The write failed after the inode header was set aside, - * but before the inode name was written. + * hoffset == 0: The write failed early before even FLASH for the + * inode header was set aside. + * noffset == 0: The write failed after the inode header was set + * aside, but before the inode name was written. * doffset == 0: The write failed after writing the inode name, bue * before any data blocks were written to FLASH. * @@ -1182,8 +1190,8 @@ static inline int nxffs_packwriter(FAR struct nxffs_volume_s *volume, } /* Loop, transferring data from the source block to the destination pack - * buffer until either (1) the source stream is exhausted, (2) the destination - * block is full, or (3) an error occurs. + * buffer until either (1) the source stream is exhausted, (2) the + * destination block is full, or (3) an error occurs. */ for (; ; ) @@ -1237,7 +1245,9 @@ static inline int nxffs_packwriter(FAR struct nxffs_volume_s *volume, if (pack->iooffset >= volume->geo.blocksize) { - /* Yes.. Write the destination data block header and return success */ + /* Yes.. Write the destination data block header and return + * success + */ nxffs_wrdathdr(volume, pack); return OK; @@ -1287,10 +1297,10 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume) if (iooffset == 0) { /* Offset zero is only returned if no valid blocks were found on the - * FLASH media or if there are no valid inode entries on the FLASH after - * the first valid block. There are two possibilities: (1) there - * really is nothing on the FLASH, or (2) there is a file being written - * to the FLASH now. + * FLASH media or if there are no valid inode entries on the FLASH + * after the first valid block. There are two possibilities: (1) + * there* really is nothing on the FLASH, or (2) there is a file being + * written to the FLASH now. */ /* Is there a writer? */ @@ -1350,11 +1360,12 @@ int nxffs_pack(FAR struct nxffs_volume_s *volume) if (ret == -ENOSPC) { /* In the case where the volume is full, nxffs_startpos() will - * recalculate the free FLASH offset and store it in iooffset. There - * may be deleted files at the end of FLASH. In this case, we don't - * have to pack any files, we simply have to erase FLASH at the end. - * But don't do this unless there is some particularly big FLASH - * savings (otherwise, we risk wearing out these final blocks). + * recalculate the free FLASH offset and store it in iooffset. + * There may be deleted files at the end of FLASH. In this case, + * we don't have to pack any files, we simply have to erase FLASH + * at the end. But don't do this unless there is some particularly + * big FLASH savings (otherwise, we risk wearing out these final + * blocks). */ if (iooffset + CONFIG_NXFFS_TAILTHRESHOLD < volume->froffset) @@ -1419,7 +1430,8 @@ start_pack: * previously marked bad blocks. */ - ret = MTD_BREAD(volume->mtd, pack.block0, volume->blkper, volume->pack); + ret = MTD_BREAD(volume->mtd, pack.block0, volume->blkper, + volume->pack); if (ret < 0) { ferr("ERROR: Failed to read erase block %d: %d\n", eblock, -ret); @@ -1498,7 +1510,8 @@ start_pack: if (ret < 0) { /* The error -ENOSPC is a special value that simply - * means that there is nothing further to be packed. + * means that there is nothing further to be + * packed. */ if (ret == -ENOSPC) @@ -1506,10 +1519,11 @@ start_pack: packed = true; /* Writing is performed at the end of the free - * FLASH region and this implementation is restricted - * to a single writer. The new inode is not - * written to FLASH until the writer is closed - * and so will not be found by nxffs_packblock(). + * FLASH region and this implementation is + * restricted to a single writer. The new + * inode is not written to FLASH until the + * writer is closed and so will not be found + * by nxffs_packblock(). */ wrfile = nxffs_setupwriter(volume, &pack); @@ -1518,15 +1532,17 @@ start_pack: { /* Otherwise, something really bad happened */ - ferr("ERROR: Failed to pack into block %d: %d\n", + ferr("ERROR: Failed to pack into block %d: " + "%d\n", block, ret); goto errout_with_pack; } } } - /* If all of the "normal" inodes have been packed, then check if - * we need to pack the current, in-progress write operation. + /* If all of the "normal" inodes have been packed, then + * check if we need to pack the current, in-progress write + * operation. */ if (wrfile) @@ -1539,7 +1555,8 @@ start_pack: if (ret < 0) { /* The error -ENOSPC is a special value that simply - * means that there is nothing further to be packed. + * means that there is nothing further to be + * packed. */ if (ret == -ENOSPC) @@ -1550,7 +1567,8 @@ start_pack: { /* Otherwise, something really bad happened */ - ferr("ERROR: Failed to pack into block %d: %d\n", + ferr("ERROR: Failed to pack into block %d: " + "%d\n", block, ret); goto errout_with_pack; } @@ -1591,7 +1609,8 @@ start_pack: /* Write the packed I/O block to FLASH */ - ret = MTD_BWRITE(volume->mtd, pack.block0, volume->blkper, volume->pack); + ret = MTD_BWRITE(volume->mtd, pack.block0, volume->blkper, + volume->pack); if (ret < 0) { ferr("ERROR: Failed to write erase block %d [%d]: %d\n",