diff options
-rw-r--r-- | acpi/acpi.c | 16 | ||||
-rw-r--r-- | isofs/iso9660.h | 16 | ||||
-rw-r--r-- | libihash/murmur3.c | 10 | ||||
-rw-r--r-- | procfs/main.c | 4 |
4 files changed, 19 insertions, 27 deletions
diff --git a/acpi/acpi.c b/acpi/acpi.c index dd32d60f..736728ae 100644 --- a/acpi/acpi.c +++ b/acpi/acpi.c @@ -95,17 +95,19 @@ acpi_get_num_tables(size_t *num_tables) ntables = (root_sdt->length - sizeof(*root_sdt)) / sz_ptr; /* Get pointer to first ACPI table */ - uintptr_t acpi_ptr = (uintptr_t)root_sdt + sizeof(*root_sdt); + void *acpi_ptr = (void*)root_sdt + sizeof(*root_sdt); /* Get number of readable tables */ *num_tables = 0; for (int i = 0; i < ntables; i++) { - uintptr_t acpi_ptr32 = (uintptr_t)*((uint32_t *)(acpi_ptr + i*sz_ptr)); - uintptr_t acpi_ptr64 = (uintptr_t)*((uint64_t *)(acpi_ptr + i*sz_ptr)); if (is_64bit) { + uint64_t acpi_ptr64; + memcpy(&acpi_ptr64, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr64)); next = acpi_os_map_memory(acpi_ptr64, ESCD_SIZE); } else { + uint32_t acpi_ptr32; + memcpy(&acpi_ptr32, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr32)); next = acpi_os_map_memory(acpi_ptr32, ESCD_SIZE); } @@ -198,16 +200,18 @@ acpi_get_tables(struct acpi_table **tables) ntables = (root_sdt->length - sizeof(*root_sdt)) / sz_ptr; /* Get pointer to first ACPI table */ - uintptr_t acpi_ptr = (uintptr_t)root_sdt + sizeof(*root_sdt); + void *acpi_ptr = (void*)root_sdt + sizeof(*root_sdt); /* Get all tables and data */ for (int i = 0; i < ntables; i++) { - uintptr_t acpi_ptr32 = (uintptr_t)*((uint32_t *)(acpi_ptr + i*sz_ptr)); - uintptr_t acpi_ptr64 = (uintptr_t)*((uint64_t *)(acpi_ptr + i*sz_ptr)); if (is_64bit) { + uint64_t acpi_ptr64; + memcpy(&acpi_ptr64, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr64)); next = acpi_os_map_memory(acpi_ptr64, ESCD_SIZE); } else { + uint32_t acpi_ptr32; + memcpy(&acpi_ptr32, acpi_ptr + i*sz_ptr, sizeof(acpi_ptr32)); next = acpi_os_map_memory(acpi_ptr32, ESCD_SIZE); } diff --git a/isofs/iso9660.h b/isofs/iso9660.h index 2fd8cc2b..be96b8f5 100644 --- a/isofs/iso9660.h +++ b/isofs/iso9660.h @@ -102,24 +102,12 @@ struct dirrect static inline unsigned int isonum_733 (unsigned char *addr) { -#if BYTE_ORDER == LITTLE_ENDIAN - return *(unsigned int *)addr; -#elif BYTE_ORDER == BIG_ENDIAN - return *(unsigned int *)(addr + 4); -#else - return - addr[0] | (addr[1] << 8) | (addr[2] << 16) | (addr[3] << 24); -#endif + return addr[0] | (addr[1] << 8) | (addr[2] << 16) | + (((unsigned int) addr[3]) << 24); } static inline unsigned int isonum_723 (unsigned char *addr) { -#if BYTE_ORDER == LITTLE_ENDIAN - return *(unsigned short *)addr; -#elif BYTE_ORDER == BIG_ENDIAN - return *(unsigned short *)addr + 2; -#else return addr[0] | (addr[1] << 8); -#endif } diff --git a/libihash/murmur3.c b/libihash/murmur3.c index e45180a4..891470e4 100644 --- a/libihash/murmur3.c +++ b/libihash/murmur3.c @@ -19,9 +19,9 @@ static inline uint32_t rotl32 ( uint32_t x, int8_t r ) /* Block read - if your platform needs to do endian-swapping or can only handle aligned reads, do the conversion here. */ -FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i ) +FORCE_INLINE uint32_t getblock32 ( const uint8_t * p, int i ) { - return p[i]; + return p[i] + (p[i+1]<<8) + (p[i+2]<<16) + (((uint32_t) p[i+3])<<24); } /* Finalization mix - force all bits of a hash block to avalanche. */ @@ -51,11 +51,11 @@ MurmurHash3_x86_32 (const void *key, size_t len, uint32_t seed) /* body */ - const uint32_t * blocks = (const uint32_t *)(data + nblocks*4); + const uint8_t * tail = data + nblocks*4; for(int i = -nblocks; i; i++) { - uint32_t k1 = getblock32(blocks,i); + uint32_t k1 = getblock32(tail,i*4); k1 *= c1; k1 = ROTL32(k1,15); @@ -68,8 +68,6 @@ MurmurHash3_x86_32 (const void *key, size_t len, uint32_t seed) /* tail */ - const uint8_t * tail = (const uint8_t*)(data + nblocks*4); - uint32_t k1 = 0; switch(len & 3) diff --git a/procfs/main.c b/procfs/main.c index e9e29123..6200e0e4 100644 --- a/procfs/main.c +++ b/procfs/main.c @@ -270,6 +270,7 @@ root_make_node (struct ps_context *pc, struct node **np) proclist_make_node (pc), rootdir_make_node (pc), }; + uint32_t ino; *np = dircat_make_node (root_dirs, sizeof root_dirs / sizeof root_dirs[0]); if (! *np) @@ -277,7 +278,8 @@ root_make_node (struct ps_context *pc, struct node **np) /* Since this one is not created through proc_lookup(), we have to affect an inode number to it. */ - (*np)->nn_stat.st_ino = * (uint32_t *) "PROC"; + memcpy(&ino, "PROC", sizeof(ino)); + (*np)->nn_stat.st_ino = ino; return 0; } |