Call memcpy to copy a struct (#25)

* Call memcpy to copy a struct

* Insert 2 filler bytes to get better alignment.

* Sorry, typo

* Call sizeof with brackets - 1

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>

* Call sizeof with brackets - 2

Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>

Co-authored-by: Hein Tibosch <hein@htibosch.net>
Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
This commit is contained in:
Hein Tibosch
2022-06-28 05:30:58 +08:00
committed by GitHub
parent c25ae5f70c
commit ade8d8da69
2 changed files with 10 additions and 2 deletions

View File

@@ -1489,8 +1489,14 @@ int ff_findnext( FF_FindData_t * pxFindData )
pxFindData->xDirectoryEntry.xCreateTime.Hour = ( uint16_t ) xTimeStruct.tm_hour; /* Hour (0 - 23). */
pxFindData->xDirectoryEntry.xCreateTime.Minute = ( uint16_t ) xTimeStruct.tm_min; /* Min (0 - 59). */
pxFindData->xDirectoryEntry.xCreateTime.Second = ( uint16_t ) xTimeStruct.tm_sec; /* Second (0 - 59). */
pxFindData->xDirectoryEntry.xModifiedTime = pxFindData->xDirectoryEntry.xCreateTime; /* Date and Time Modified. */
pxFindData->xDirectoryEntry.xAccessedTime = pxFindData->xDirectoryEntry.xCreateTime; /* Date of Last Access. */
/* Date and Time Modified. */
memcpy( &( pxFindData->xDirectoryEntry.xModifiedTime ),
&( pxFindData->xDirectoryEntry.xCreateTime ),
sizeof( pxFindData->xDirectoryEntry.xModifiedTime ) );
/* Date of Last Access. */
memcpy( &( pxFindData->xDirectoryEntry.xAccessedTime ),
&( pxFindData->xDirectoryEntry.xCreateTime ),
sizeof( pxFindData->xDirectoryEntry.xAccessedTime ) );
}
}
#endif /* ffconfigTIME_SUPPORT */

View File

@@ -64,6 +64,8 @@ typedef struct
uint32_t ulAddrCurrentCluster;
uint32_t ulDirCluster;
uint16_t usCurrentItem;
/* Insert 2 bytes to make the next struct 32-bit aligned. */
uint16_t usFillerBytes;
/* End Book Keeping. */
#if ( ffconfigTIME_SUPPORT != 0 )