Cleanup: quiet -Warray-bounds warning
authorCampbell Barton <ideasman42@gmail.com>
Tue, 8 May 2018 11:32:52 +0000 (13:32 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 8 May 2018 11:32:52 +0000 (13:32 +0200)
source/blender/blenloader/intern/readfile.c

index 7d73b3050a61d38d07f3c0e6241c5e2bfcbc2eba..9e9481566b0ed9bc6a0356b582aa43ce3d5921f8 100644 (file)
@@ -765,7 +765,9 @@ static BHeadN *get_bhead(FileData *fd)
                                                bh8_from_bh4(&bhead, &bhead4);
                                        }
                                        else {
-                                               memcpy(&bhead, &bhead4, sizeof(bhead));
+                                               /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
+                                               BLI_assert(sizeof(bhead) == sizeof(bhead4));
+                                               memcpy(&bhead, &bhead4, MIN2(sizeof(bhead), sizeof(bhead4)));
                                        }
                                }
                                else {
@@ -786,7 +788,9 @@ static BHeadN *get_bhead(FileData *fd)
                                                bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN));
                                        }
                                        else {
-                                               memcpy(&bhead, &bhead8, sizeof(bhead));
+                                               /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */
+                                               BLI_assert(sizeof(bhead) == sizeof(bhead8));
+                                               memcpy(&bhead, &bhead8, MIN2(sizeof(bhead), sizeof(bhead8)));
                                        }
                                }
                                else {