Skip to content

Commit

Permalink
Avoid strict aliasing warning by using memcpy to copy data
Browse files Browse the repository at this point in the history
  • Loading branch information
uyjulian committed Jun 11, 2021
1 parent 4929d8d commit 65d2571
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/iopcore/udnl-t300/udnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ static int InitModuleInfo(const void *module, struct ModuleInfo *ModuleInfo)
sizeof(AOUTHDR) = 56 bytes
sizeof(struct scnhdr) = 40 bytes */

Ident_10 = *(unsigned int *)&((struct coff_filehdr *)module)->f_opthdr;
memcpy(&Ident_10, &((struct coff_filehdr *)module)->f_opthdr, 4);
COFF_AoutHdr = (AOUTHDR *)((unsigned int)module + sizeof(struct coff_filehdr));
COFF_ScnHdr = (struct scnhdr *)((unsigned int)module + sizeof(struct coff_filehdr) + sizeof(AOUTHDR));
if (((struct coff_filehdr *)module)->f_magic == MIPSELMAGIC && COFF_AoutHdr->magic == OMAGIC && ((struct coff_filehdr *)module)->f_nscns < 0x20 && ((Ident_10 & 0x0002FFFF) == 0x20038) && COFF_ScnHdr->s_paddr == COFF_AoutHdr->text_start) {
Expand Down
2 changes: 1 addition & 1 deletion modules/iopcore/udnl/udnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static int InitModuleInfo(const void *module, struct ModuleInfo *ModuleInfo)
sizeof(AOUTHDR) = 56 bytes
sizeof(struct scnhdr) = 40 bytes */

Ident_10 = *(unsigned int *)&((struct coff_filehdr *)module)->f_opthdr;
memcpy(&Ident_10, &((struct coff_filehdr *)module)->f_opthdr, 4);
COFF_AoutHdr = (AOUTHDR *)((unsigned int)module + sizeof(struct coff_filehdr));
COFF_ScnHdr = (struct scnhdr *)((unsigned int)module + sizeof(struct coff_filehdr) + sizeof(AOUTHDR));
if (((struct coff_filehdr *)module)->f_magic == MIPSELMAGIC && COFF_AoutHdr->magic == OMAGIC && ((struct coff_filehdr *)module)->f_nscns < 0x20 && ((Ident_10 & 0x0002FFFF) == 0x20038) && COFF_ScnHdr->s_paddr == COFF_AoutHdr->text_start) {
Expand Down

0 comments on commit 65d2571

Please sign in to comment.