Skip to content

Commit 51bd7a7

Browse files
committed
better fix warning with "-Wclass-memaccess" in SPI
1 parent a7a8b02 commit 51bd7a7

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

libraries/SPI/SPI.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,24 +333,16 @@ void SPIClass::dmaAllocate(void) {
333333
use_dma = true; // Everything allocated successfully
334334
extraWriteDescriptors = &extraReadDescriptors[numReadDescriptors];
335335

336-
// dmac.h didn't include extern "C" which cause
337-
// DmacDescriptor and its members are defined as C++ struct therefore
338-
// memcpy will throw warning on copying where simple assignment won't work
339-
#pragma GCC diagnostic push
340-
#pragma GCC diagnostic ignored "-Wclass-memaccess"
341-
342336
// Initialize descriptors (copy from first ones)
337+
// cast to void* to suppress warning: with no trivial copy-assignment [-Wclass-memaccess]
343338
for(int i=0; i<numReadDescriptors; i++) {
344-
memcpy(&extraReadDescriptors[i], firstReadDescriptor,
339+
memcpy((void*) &extraReadDescriptors[i], firstReadDescriptor,
345340
sizeof(DmacDescriptor));
346341
}
347342
for(int i=0; i<numWriteDescriptors; i++) {
348-
memcpy(&extraWriteDescriptors[i], firstWriteDescriptor,
343+
memcpy((void*) &extraWriteDescriptors[i], firstWriteDescriptor,
349344
sizeof(DmacDescriptor));
350345
}
351-
352-
#pragma GCC diagnostic pop
353-
354346
} // end malloc
355347
} // end extra descriptor check
356348

0 commit comments

Comments
 (0)