From 13047d5e6c7529201c66bbaa37a9f15d8b5a45e6 Mon Sep 17 00:00:00 2001 From: Stefan Baltruweit Date: Wed, 24 Apr 2024 14:10:25 +0200 Subject: [PATCH 1/2] Add explicit cast to uint32_t Otherwise the condition is always true for 64-bit architectures. --- ff_fat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ff_fat.c b/ff_fat.c index 4114e91..533cb01 100644 --- a/ff_fat.c +++ b/ff_fat.c @@ -712,7 +712,7 @@ uint32_t FF_FindEndOfChain( FF_IOManager_t * pxIOManager, { /* Traverse FAT for (2^32-1) items/clusters, * or until end-of-chain is encountered. */ - ulFatEntry = FF_TraverseFAT( pxIOManager, ulStart, ( uint32_t ) ~0UL, &xError ); + ulFatEntry = FF_TraverseFAT( pxIOManager, ulStart, ~( ( uint32_t ) 0U ), &xError ); } else { @@ -1496,7 +1496,7 @@ uint32_t FF_CountFreeClusters( FF_IOManager_t * pxIOManager, { ulFreeClusters = FF_getLong( pxBuffer->pucBuffer, 488 ); - if( ulFreeClusters != ~0ul ) + if( ulFreeClusters != ~( ( uint32_t ) 0U ) ) { xInfoKnown = pdTRUE; } From 54dfc085efdb95930e3b62e94b4a95d42e2ee9b4 Mon Sep 17 00:00:00 2001 From: Stefan Baltruweit Date: Wed, 24 Apr 2024 14:30:52 +0200 Subject: [PATCH 2/2] Add const qualifier to FF_IsNameCompliant() pointer argument The argument is read-only. --- ff_dir.c | 4 ++-- include/ff_dir.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ff_dir.c b/ff_dir.c index 8ea3c5c..1a80edf 100644 --- a/ff_dir.c +++ b/ff_dir.c @@ -2884,9 +2884,9 @@ FF_Error_t FF_ExtendDirectory( FF_IOManager_t * pxIOManager, /* *INDENT-OFF* */ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) - BaseType_t FF_IsNameCompliant( FF_T_WCHAR * pcName ) + BaseType_t FF_IsNameCompliant( const FF_T_WCHAR * pcName ) #else - BaseType_t FF_IsNameCompliant( char * pcName ) + BaseType_t FF_IsNameCompliant( const char * pcName ) #endif /* *INDENT-ON* */ { diff --git a/include/ff_dir.h b/include/ff_dir.h index 4a23624..71d5b55 100644 --- a/include/ff_dir.h +++ b/include/ff_dir.h @@ -177,9 +177,9 @@ int8_t FF_PushEntry( FF_IOManager_t * pxIOManager, * contains any legal characters only. */ #if ( ffconfigUNICODE_UTF16_SUPPORT != 0 ) - BaseType_t FF_IsNameCompliant( FF_T_WCHAR * pcName ); + BaseType_t FF_IsNameCompliant( const FF_T_WCHAR * pcName ); #else - BaseType_t FF_IsNameCompliant( char * pcName ); + BaseType_t FF_IsNameCompliant( const char * pcName ); #endif static portINLINE BaseType_t FF_isEndOfDir( const uint8_t * pucEntryBuffer )