Skip to content

Commit 08d0cff

Browse files
phelteramazonKamathactions-user
authored
Feature/fixing clang gnu compiler warnings (#45)
* 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 <110539926+amazonKamath@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
1 parent cee2654 commit 08d0cff

32 files changed

+747
-821
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
- uses: actions/checkout@v2
5656
- name: Build checks (Default configuration)
5757
run: |
58-
cmake -S . -B build/ -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF
59-
make -C build/
58+
cmake -S . -B build -DFREERTOS_PLUS_FAT_TEST_CONFIGURATION=DEFAULT_CONF
59+
cmake --build build --target freertos_plus_fat_build_test
6060
6161
# complexity:
6262
# runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,16 @@ target_compile_definitions( freertos_plus_fat
186186

187187
target_compile_options( freertos_plus_fat
188188
PRIVATE
189+
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-array-bounds>
189190
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
190191
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-constant-conversion>
191192
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
192-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation-unknown-command>
193-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation>
194-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
193+
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-declaration-after-statement>
195194
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wno-format>
196-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-implicit-int-conversion>
197-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-variable-declarations>
198195
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-overflow>
199196
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-padded>
200197
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-pedantic>
201198

202-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-reserved-macro-identifier>
203-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-shorten-64-to-32>
204-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-sign-conversion>
205199
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-tautological-constant-out-of-range-compare>
206200
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-type-limits>
207201
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-undef>

ff_dir.c

Lines changed: 68 additions & 78 deletions
Large diffs are not rendered by default.

ff_fat.c

100755100644
Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,
339339
{
340340
/* Setting an error code without the Module/Function,
341341
* will be filled-in by the caller. */
342-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_ERRFLAG );
342+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_ERRFLAG );
343343
}
344344
}
345345

@@ -372,7 +372,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,
372372

373373
if( FF_isERR( xError ) )
374374
{
375-
xError = FF_GETERROR( xError ) | FF_GETFATENTRY;
375+
xError = FF_CreateError( FF_GETERROR( xError ), FF_GETFATENTRY );
376376
}
377377
else
378378
{
@@ -394,7 +394,7 @@ FF_Buffer_t * prvGetFromFATBuffers( FF_IOManager_t * pxIOManager,
394394

395395
if( pxBuffer == NULL )
396396
{
397-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_GETFATENTRY );
397+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_GETFATENTRY );
398398
}
399399
else
400400
{
@@ -444,7 +444,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
444444
{
445445
/* _HT_ find a more specific error code.
446446
* Probably not really important as this is a function internal to the library. */
447-
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_GETFATENTRY );
447+
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_GETFATENTRY );
448448
}
449449
else
450450
{
@@ -505,7 +505,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
505505

506506
if( FF_isERR( xError ) )
507507
{
508-
xError = FF_GETERROR( xError ) | FF_GETFATENTRY;
508+
xError = FF_createERR( FF_GETERROR( xError ), FF_GETFATENTRY );
509509
}
510510
else
511511
{
@@ -568,7 +568,7 @@ uint32_t FF_getFATEntry( FF_IOManager_t * pxIOManager,
568568
*pxError = xError;
569569
}
570570

571-
return ( int32_t ) ulFATEntry;
571+
return ulFATEntry;
572572
} /* FF_getFATEntry() */
573573
/*-----------------------------------------------------------*/
574574

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

596596
if( pxBuffer == NULL )
597597
{
598-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_CLEARCLUSTER );
598+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_CLEARCLUSTER );
599599
break;
600600
}
601601

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

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

607607
if( FF_isERR( xError ) )
608608
{
@@ -631,15 +631,13 @@ FF_Error_t FF_ClearCluster( FF_IOManager_t * pxIOManager,
631631
/*-----------------------------------------------------------*/
632632

633633
/**
634-
* @private
635634
* @brief Returns the Cluster address of the Cluster number from the beginning of a chain.
636635
*
637636
* @param pxIOManager FF_IOManager_t Object
638637
* @param ulStart Cluster address of the first cluster in the chain.
639638
* @param ulCount Number of Cluster in the chain,
640639
*
641640
*
642-
*
643641
**/
644642
uint32_t FF_TraverseFAT( FF_IOManager_t * pxIOManager,
645643
uint32_t ulStart,
@@ -728,7 +726,6 @@ uint32_t FF_FindEndOfChain( FF_IOManager_t * pxIOManager,
728726
/*-----------------------------------------------------------*/
729727

730728
/**
731-
* @private
732729
* @brief Tests if the ulFATEntry is an End of Chain Marker.
733730
*
734731
* @param pxIOManager FF_IOManager_t Object
@@ -826,7 +823,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
826823
{
827824
if( pxBuffer == NULL )
828825
{
829-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY );
826+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY );
830827
break;
831828
}
832829

@@ -844,7 +841,7 @@ BaseType_t FF_isEndOfChain( FF_IOManager_t * pxIOManager,
844841
{
845842
if( pxBuffer == NULL )
846843
{
847-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_PUTFATENTRY );
844+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_PUTFATENTRY );
848845
break;
849846
}
850847

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

866863
/**
867-
* @private
868864
* @brief Writes a new Entry to the FAT Tables.
869865
*
870866
* @param pxIOManager IOMAN object.
@@ -899,7 +895,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
899895
if( ( ulCluster == 0ul ) || ( ulCluster >= pxIOManager->xPartition.ulNumClusters ) )
900896
{
901897
/* find a more specific error code. */
902-
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_PUTFATENTRY );
898+
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_PUTFATENTRY );
903899
}
904900
else
905901
{
@@ -950,7 +946,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
950946

951947
if( FF_isERR( xError ) )
952948
{
953-
xError = FF_GETERROR( xError ) | FF_PUTFATENTRY;
949+
xError = FF_createERR( FF_GETERROR( xError ), FF_PUTFATENTRY );
954950
break;
955951
}
956952

@@ -1007,13 +1003,12 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
10071003
/*-----------------------------------------------------------*/
10081004

10091005
/**
1010-
* @private
10111006
* @brief Finds a Free Cluster and returns its number.
10121007
*
10131008
* @param pxIOManager IOMAN Object.
10141009
*
10151010
* @return The number of the cluster found to be free.
1016-
* @return 0 on error.
1011+
* @retval 0 on error.
10171012
**/
10181013
#if ( ffconfigFAT12_SUPPORT != 0 )
10191014
static uint32_t prvFindFreeClusterSimple( FF_IOManager_t * pxIOManager,
@@ -1060,7 +1055,7 @@ FF_Error_t FF_putFATEntry( FF_IOManager_t * pxIOManager,
10601055
{
10611056
/* There is no free cluster any more. */
10621057
ulCluster = 0;
1063-
xError = ( FF_Error_t ) ( FF_FINDFREECLUSTER | FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE );
1058+
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER );
10641059
}
10651060

10661061
*pxError = xError;
@@ -1112,7 +1107,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
11121107

11131108
if( pxBuffer == NULL )
11141109
{
1115-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER );
1110+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER );
11161111
}
11171112
else
11181113
{
@@ -1134,8 +1129,8 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
11341129
uint32_t ulFATSector;
11351130
uint32_t ulFATOffset;
11361131

1137-
ulEntriesPerSector = pxIOManager->usSectorSize / xEntrySize;
1138-
ulFATOffset = ulCluster * xEntrySize;
1132+
ulEntriesPerSector = ( uint32_t ) ( pxIOManager->usSectorSize / xEntrySize );
1133+
ulFATOffset = ( uint32_t ) ( ulCluster * xEntrySize );
11391134

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

11481143
if( pxBuffer == NULL )
11491144
{
1150-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_FINDFREECLUSTER );
1145+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_FINDFREECLUSTER );
11511146
break;
11521147
}
11531148

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

@@ -1201,7 +1196,7 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
12011196
if( ( FF_isERR( xError ) == pdFALSE ) &&
12021197
( ulFATSector == pxIOManager->xPartition.ulSectorsPerFAT ) )
12031198
{
1204-
xError = ( FF_Error_t ) ( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE | FF_FINDFREECLUSTER );
1199+
xError = FF_createERR( FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE, FF_FINDFREECLUSTER );
12051200
}
12061201
} /* if( FF_isERR( xError ) == pdFALSE ) */
12071202
} /* if( pxIOManager->xPartition.ucType != FF_T_FAT12 ) */
@@ -1243,10 +1238,9 @@ uint32_t FF_FindFreeCluster( FF_IOManager_t * pxIOManager,
12431238
/*-----------------------------------------------------------*/
12441239

12451240
/**
1246-
* @private
12471241
* @brief Creates a Cluster Chain
1248-
* @return > 0 New created cluster
1249-
* @return = 0 See pxError
1242+
* @retval > 0 New created cluster
1243+
* @retval = 0 See pxError
12501244
**/
12511245
uint32_t FF_CreateClusterChain( FF_IOManager_t * pxIOManager,
12521246
FF_Error_t * pxError )
@@ -1316,17 +1310,16 @@ uint32_t FF_GetChainLength( FF_IOManager_t * pxIOManager,
13161310
/*-----------------------------------------------------------*/
13171311

13181312
/**
1319-
* @private
13201313
* @brief Free's Disk space by freeing unused links on Cluster Chains
13211314
*
1322-
* @param pxIOManager, IOMAN object.
1315+
* @param pxIOManager IOMAN object.
13231316
* @param ulStartCluster Cluster Number that starts the chain.
1324-
* @param ulCount Number of Clusters from the end of the chain to unlink.
1325-
* @param ulCount 0 Means Free the entire chain (delete file).
1326-
* @param ulCount 1 Means mark the start cluster with EOF.
1317+
* @param xDoTruncate Perform truncation of the FAT entry
1318+
* when non-zero - truncate
1319+
* when 0 - do not perform truncation
13271320
*
1328-
* @return 0 On Success.
1329-
* @return -1 If the device driver failed to provide access.
1321+
* @retval 0 On Success.
1322+
* @retval -1 If the device driver failed to provide access.
13301323
*
13311324
**/
13321325
FF_Error_t FF_UnlinkClusterChain( FF_IOManager_t * pxIOManager,
@@ -1494,7 +1487,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager,
14941487

14951488
if( pxBuffer == NULL )
14961489
{
1497-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS );
1490+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS );
14981491
}
14991492
else
15001493
{
@@ -1542,7 +1535,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager,
15421535

15431536
if( pxBuffer == NULL )
15441537
{
1545-
xError = ( FF_Error_t ) ( FF_ERR_DEVICE_DRIVER_FAILED | FF_COUNTFREECLUSTERS );
1538+
xError = FF_createERR( FF_ERR_DEVICE_DRIVER_FAILED, FF_COUNTFREECLUSTERS );
15461539
break;
15471540
}
15481541

0 commit comments

Comments
 (0)