Skip to content

Commit

Permalink
Merge pull request #7 from adafruit/fix-warnings
Browse files Browse the repository at this point in the history
fix warnings
  • Loading branch information
ladyada authored Jun 16, 2021
2 parents b2a3698 + 850e1aa commit 54ca0c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/FatLib/FatFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ bool FatFile::openParent(FatFile* dirFile) {
goto fail;
}
} else {
memset(&dotdot, 0, sizeof(FatFile));
memset((void*) &dotdot, 0, sizeof(FatFile));
dotdot.m_attr = FILE_ATTR_SUBDIR;
dotdot.m_flags = F_READ;
dotdot.m_vol = dirFile->m_vol;
Expand Down Expand Up @@ -1215,7 +1215,14 @@ bool FatFile::sync() {

// set modify time if user supplied a callback date/time function
if (m_dateTime) {
m_dateTime(&dir->lastWriteDate, &dir->lastWriteTime);
// use temp date/time to fix warning -Waddress-of-packed-member
uint16_t tmp_date = dir->lastWriteDate;
uint16_t tmp_time = dir->lastWriteTime;

m_dateTime(&tmp_date, &tmp_time);

dir->lastWriteDate = tmp_date;
dir->lastWriteTime = tmp_time;
dir->lastAccessDate = dir->lastWriteDate;
}
// clear directory dirty
Expand Down
9 changes: 8 additions & 1 deletion src/FatLib/FatFileLFN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,15 @@ bool FatFile::open(FatFile* dirFile, fname_t* fname, oflag_t oflag) {

// set timestamps
if (m_dateTime) {
// use temp date/time to fix warning -Waddress-of-packed-member
uint16_t tmp_date = dir->creationDate;
uint16_t tmp_time = dir->creationTime;

// call user date/time function
m_dateTime(&dir->creationDate, &dir->creationTime);
m_dateTime(&tmp_date, &tmp_time);

dir->creationDate = tmp_date;
dir->creationTime = tmp_time;
} else {
// use default date/time
dir->creationDate = FAT_DEFAULT_DATE;
Expand Down

0 comments on commit 54ca0c7

Please sign in to comment.