From 952415ee990f17fed58ba22ca0d3f86fad38ff2b Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 10 Apr 2022 11:48:51 +0200 Subject: [PATCH] src/partmac.[ch]: Fix mac structure to avoid using pointers --- src/partmac.c | 5 +++-- src/partmac.h | 27 +++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/partmac.c b/src/partmac.c index eb1cbf36..58a88ec6 100644 --- a/src/partmac.c +++ b/src/partmac.c @@ -20,7 +20,7 @@ */ - +#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC) #ifdef HAVE_CONFIG_H #include #endif @@ -186,7 +186,7 @@ static list_part_t *read_part_mac(disk_t *disk_car, const int verbose, const int } for(i=1;i<=limit;i++) { - mac_DPME *dpme=(mac_DPME *)buffer; + const mac_DPME *dpme=(const mac_DPME *)buffer; if(disk_car->pread(disk_car, &buffer, sizeof(buffer), (uint64_t)i * PBLOCK_SIZE) != sizeof(buffer)) return new_list_part; if(be16(dpme->dpme_signature) != DPME_SIGNATURE) @@ -473,3 +473,4 @@ static const char *get_partition_typename_mac(const partition_t *partition) { return get_partition_typename_mac_aux(partition->part_type_mac); } +#endif diff --git a/src/partmac.h b/src/partmac.h index 88e8baf9..c45d19c9 100644 --- a/src/partmac.h +++ b/src/partmac.h @@ -25,7 +25,7 @@ #ifdef __cplusplus extern "C" { #endif - +#if !defined(SINGLE_PARTITION_TYPE) || defined(SINGLE_PARTITION_MAC) #define BLOCK0_SIGNATURE 0x4552 /* Signature value. */ @@ -83,20 +83,35 @@ struct dpme { #endif uint32_t dpme_boot_block ; uint32_t dpme_boot_bytes ; - uint8_t *dpme_load_addr ; - uint8_t *dpme_load_addr_2 ; - uint8_t *dpme_goto_addr ; - uint8_t *dpme_goto_addr_2 ; + uint32_t dpme_load_addr ; + uint32_t dpme_load_addr_2 ; + uint32_t dpme_goto_addr ; + uint32_t dpme_goto_addr_2 ; uint32_t dpme_checksum ; char dpme_process_id[16] ; uint32_t dpme_boot_args[32] ; uint32_t dpme_reserved_3[62] ; -}; +} __attribute__ ((gcc_struct, __packed__)); typedef struct dpme mac_DPME; +/*@ + @ requires valid_list_part(list_part); + @*/ int test_structure_mac(const list_part_t *list_part); + +/*@ + @ requires valid_disk(disk_car); + @ requires \valid_read(disk_car); + @ requires valid_list_part(list_part); + @ requires \valid(current_cmd); + @ requires separation: \separated(disk_car, list_part, current_cmd, *current_cmd); + @ requires valid_read_string(*current_cmd); + @*/ +// ensures valid_list_part(\result); +// ensures valid_read_string(*current_cmd); list_part_t *add_partition_mac_cli(disk_t *disk_car,list_part_t *list_part, char **current_cmd); +#endif #ifdef __cplusplus } /* closing brace for extern "C" */ #endif