Skip to content

Commit

Permalink
Feature/fixing clang gnu compiler warnings (#45)
Browse files Browse the repository at this point in the history
* Support for CMake builds. Added Linux stub port for now to allow cross
compilation.

* Fixing misuse of doxygen documentation

* Converting prints from %lu to %u where possible as per request in comments related to (#35)

* Fixing clang compiler warnings.

* Fixing build test to work regardless of configuration.

* Adding in for Zynq port dependency on uncached_memory target.

* Excluding build_test from all build - must request it explicitly.

* Ensuring XPAR_XSDPS_0_IS_CACHE_COHERENT is 1 for this build since using
a modified xsdps driver that requires it.

* Updating compiler warnings.

* Fixing documentation, signed/unsigned conversion. Bugfix for time based code for removing failure in 2032 due to uint32_t used for time.

* Fixing error creation using FF_createERR everywhere missed.

* Fixing build_test in ci.yml

* Uncrustify: triggered by comment.

---------

Co-authored-by: Nikhil Kamath <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
3 people authored May 16, 2023
1 parent cee2654 commit 08d0cff
Show file tree
Hide file tree
Showing 32 changed files with 747 additions and 821 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
- uses: actions/checkout@v2
- name: Build checks (Default configuration)
run: |
cmake -S . -B build/ -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF
make -C build/
cmake -S . -B build -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF
cmake --build build --target freertos_plus_fat_build_test
# complexity:
# runs-on: ubuntu-latest
Expand Down
10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,16 @@ target_compile_definitions( freertos_plus_fat

target_compile_options( freertos_plus_fat
PRIVATE
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-array-bounds>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-constant-conversion>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation-unknown-command>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-declaration-after-statement>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wno-format>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-implicit-int-conversion>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-overflow>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-pedantic>

$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-reserved-macro-identifier>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-shorten-64-to-32>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-sign-conversion>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-tautological-constant-out-of-range-compare>
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-type-limits>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-undef>
Expand Down
146 changes: 68 additions & 78 deletions ff_dir.c

Large diffs are not rendered by default.

67 changes: 30 additions & 37 deletions ff_fat.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,
{
/* Setting an error code without the Module/Function,
* will be filled-in by the caller. */
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_ERRFLAG );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_ERRFLAG );
}
}

Expand Down Expand Up @@ -372,7 +372,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,

if( FF_isERR( xError ) )
{
xError = FF_GETERROR( xError ) | FF_GETFATENTRY;
xError = FF_CreateError( FF_GETERROR( xError ), FF_GETFATENTRY );
}
else
{
Expand All @@ -394,7 +394,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_GETFATENTRY );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_GETFATENTRY );
}
else
{
Expand Down Expand Up @@ -444,7 +444,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
{
/* _HT_ find a more specific error code.
* Probably not really important as this is a function internal to the library. */
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_GETFATENTRY );
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_GETFATENTRY );
}
else
{
Expand Down Expand Up @@ -505,7 +505,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,

if( FF_isERR( xError ) )
{
xError = FF_GETERROR( xError ) | FF_GETFATENTRY;
xError = FF_createERR( FF_GETERROR( xError ), FF_GETFATENTRY );
}
else
{
Expand Down Expand Up @@ -568,7 +568,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
*pxError = xError;
}

return ( int32_t ) ulFATEntry;
return ulFATEntry;
} /* FF_getFATEntry() */
/*-----------------------------------------------------------*/

Expand All @@ -595,14 +595,14 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_CLEARCLUSTER );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_CLEARCLUSTER );
break;
}

memset( pxBuffer->pucBuffer, 0x00, pxIOManager->usSectorSize );
}

xError = FF_BlockWrite( pxIOManager, ulBaseLBA + xIndex, 1, pxBuffer->pucBuffer, pdFALSE );
xError = FF_BlockWrite( pxIOManager, ( uint32_t ) ( ulBaseLBA + xIndex ), 1U, pxBuffer->pucBuffer, pdFALSE );

if( FF_isERR( xError ) )
{
Expand Down Expand Up @@ -631,15 +631,13 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager,
/*-----------------------------------------------------------*/

/**
* @private
* @brief Returns the Cluster address of the Cluster number from the beginning of a chain.
*
* @param pxIOManager FF_IOManager_t Object
* @param ulStart Cluster address of the first cluster in the chain.
* @param ulCount Number of Cluster in the chain,
*
*
*
**/
uint32_t FF_TraverseFAT( FF_IOManager_t * pxIOManager,
uint32_t ulStart,
Expand Down Expand Up @@ -728,7 +726,6 @@ uint32_t FF_FindEndOfChain( FF_IOManager_t * pxIOManager,
/*-----------------------------------------------------------*/

/**
* @private
* @brief Tests if the ulFATEntry is an End of Chain Marker.
*
* @param pxIOManager FF_IOManager_t Object
Expand Down Expand Up @@ -826,7 +823,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
{
if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY );
break;
}

Expand All @@ -844,7 +841,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
{
if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY );
break;
}

Expand All @@ -864,7 +861,6 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
#endif /* if ( ffconfigFAT12_SUPPORT != 0 ) */

/**
* @private
* @brief Writes a new Entry to the FAT Tables.
*
* @param pxIOManager IOMAN object.
Expand Down Expand Up @@ -899,7 +895,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
if( ( ulCluster == 0ul ) || ( ulCluster >= pxIOManager->xPartition.ulNumClusters ) )
{
/* find a more specific error code. */
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_PUTFATENTRY );
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_PUTFATENTRY );
}
else
{
Expand Down Expand Up @@ -950,7 +946,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,

if( FF_isERR( xError ) )
{
xError = FF_GETERROR( xError ) | FF_PUTFATENTRY;
xError = FF_createERR( FF_GETERROR( xError ), FF_PUTFATENTRY );
break;
}

Expand Down Expand Up @@ -1007,13 +1003,12 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
/*-----------------------------------------------------------*/

/**
* @private
* @brief Finds a Free Cluster and returns its number.
*
* @param pxIOManager IOMAN Object.
*
* @return The number of the cluster found to be free.
* @return 0 on error.
* @retval 0 on error.
**/
#if ( ffconfigFAT12_SUPPORT != 0 )
static uint32_t prvFindFreeClusterSimple( FF_IOManager_t * pxIOManager,
Expand Down Expand Up @@ -1060,7 +1055,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
{
/* There is no free cluster any more. */
ulCluster = 0;
xError = ( FF_Error_t ) ( FF_FINDFREECLUSTER | FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE );
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER );
}

*pxError = xError;
Expand Down Expand Up @@ -1112,7 +1107,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER );
}
else
{
Expand All @@ -1134,8 +1129,8 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
uint32_t ulFATSector;
uint32_t ulFATOffset;

ulEntriesPerSector = pxIOManager->usSectorSize / xEntrySize;
ulFATOffset = ulCluster * xEntrySize;
ulEntriesPerSector = ( uint32_t ) ( pxIOManager->usSectorSize / xEntrySize );
ulFATOffset = ( uint32_t ) ( ulCluster * xEntrySize );

/* Start from a sector where the first free entry is expected,
* and iterate through every FAT sector. */
Expand All @@ -1147,7 +1142,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER );
break;
}

Expand All @@ -1156,7 +1151,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
/* Double-check: don't use non-existing clusters */
if( ulCluster >= uNumClusters )
{
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_FINDFREECLUSTER );
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER );
break;
}

Expand Down Expand Up @@ -1201,7 +1196,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
if( ( FF_isERR( xError ) == pdFALSE ) &&
( ulFATSector == pxIOManager->xPartition.ulSectorsPerFAT ) )
{
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_FINDFREECLUSTER );
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER );
}
} /* if( FF_isERR( xError ) == pdFALSE ) */
} /* if( pxIOManager->xPartition.ucType != FF_T_FAT12 ) */
Expand Down Expand Up @@ -1243,10 +1238,9 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
/*-----------------------------------------------------------*/

/**
* @private
* @brief Creates a Cluster Chain
* @return > 0 New created cluster
* @return = 0 See pxError
* @retval > 0 New created cluster
* @retval = 0 See pxError
**/
uint32_t FF_CreateClusterChain( FF_IOManager_t * pxIOManager,
FF_Error_t * pxError )
Expand Down Expand Up @@ -1316,17 +1310,16 @@ uint32_t FF_GetChainLength( FF_IOManager_t * pxIOManager,
/*-----------------------------------------------------------*/

/**
* @private
* @brief Free's Disk space by freeing unused links on Cluster Chains
*
* @param pxIOManager, IOMAN object.
* @param pxIOManager IOMAN object.
* @param ulStartCluster Cluster Number that starts the chain.
* @param ulCount Number of Clusters from the end of the chain to unlink.
* @param ulCount 0 Means Free the entire chain (delete file).
* @param ulCount 1 Means mark the start cluster with EOF.
* @param xDoTruncate Perform truncation of the FAT entry
* when non-zero - truncate
* when 0 - do not perform truncation
*
* @return 0 On Success.
* @return -1 If the device driver failed to provide access.
* @retval 0 On Success.
* @retval -1 If the device driver failed to provide access.
*
**/
FF_Error_t FF_UnlinkClusterChain( FF_IOManager_t * pxIOManager,
Expand Down Expand Up @@ -1494,7 +1487,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS );
}
else
{
Expand Down Expand Up @@ -1542,7 +1535,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager,

if( pxBuffer == NULL )
{
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS );
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS );
break;
}

Expand Down
Loading

0 comments on commit 08d0cff

Please sign in to comment.