diff options
author | Ladar Levison <ladar@lavabit.com> | 2017-06-23 11:45:48 +0300 |
---|---|---|
committer | Ladar Levison <ladar@lavabit.com> | 2017-06-23 11:45:48 +0300 |
commit | feb0907b51d979d4b7b3a9ce9ce9b87a74d6535c (patch) | |
tree | 8386696e2d6fbf0ab04ba624ed0036bdf4baf62a | |
parent | 693e8b0e1b5ff532d1bbddf8921c668668d0e13e (diff) |
Normalized how the packed attribute is applied to structures.
-rw-r--r-- | src/core/indexes/hashed.c | 10 | ||||
-rw-r--r-- | src/core/indexes/indexes.h | 4 | ||||
-rw-r--r-- | src/core/indexes/linked.c | 8 | ||||
-rw-r--r-- | src/network/http.h | 2 | ||||
-rw-r--r-- | src/network/imap.h | 4 | ||||
-rw-r--r-- | src/network/meta.h | 8 | ||||
-rw-r--r-- | src/network/pop.h | 2 | ||||
-rw-r--r-- | src/objects/config/config.h | 4 | ||||
-rw-r--r-- | src/objects/contacts/contacts.h | 4 | ||||
-rw-r--r-- | src/objects/folders/folders.h | 2 | ||||
-rw-r--r-- | src/objects/messages/messages.h | 2 | ||||
-rw-r--r-- | src/objects/warehouse/warehouse.h | 4 | ||||
-rw-r--r-- | src/providers/dime/common/error.c | 6 | ||||
-rw-r--r-- | src/providers/dime/common/error.h | 4 | ||||
-rw-r--r-- | src/providers/dime/dmessage/crypto.h | 6 | ||||
-rw-r--r-- | src/providers/dime/dmessage/dmsg.c | 4 | ||||
-rw-r--r-- | src/providers/dime/sds/sds.h | 10 | ||||
-rw-r--r-- | src/providers/dime/signet-resolver/dns.h | 12 | ||||
-rw-r--r-- | src/providers/prime/prime.h | 3 | ||||
-rw-r--r-- | src/providers/storage/tree.c | 4 |
20 files changed, 50 insertions, 53 deletions
diff --git a/src/core/indexes/hashed.c b/src/core/indexes/hashed.c index 35a727ab..dca23009 100644 --- a/src/core/indexes/hashed.c +++ b/src/core/indexes/hashed.c @@ -10,21 +10,21 @@ #define MAGMA_HASHED_BUCKETS 1024 // Hashed lists. -typedef struct { +typedef struct __attribute__ ((packed)) { void *data; multi_t key; struct hashed_bucket_t *next; } hashed_bucket_t; -typedef struct { +typedef struct __attribute__ ((packed)) { inx_t *inx; hashed_bucket_t *bucket; uint64_t serial, slot, count; -} __attribute__((__packed__)) hashed_cursor_t; +} hashed_cursor_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint32_t buckets; -} __attribute__((__packed__)) hashed_index_t; +} hashed_index_t; // TODO: Finish implementing the hashed iterators. // TODO: Respect dupe/lock flags. diff --git a/src/core/indexes/indexes.h b/src/core/indexes/indexes.h index ad0f0dcd..cfba07e9 100644 --- a/src/core/indexes/indexes.h +++ b/src/core/indexes/indexes.h @@ -61,9 +61,9 @@ typedef struct { } inx_t; -typedef struct { +typedef struct __attribute__ ((packed)) { inx_t *inx; -} __attribute__((__packed__)) inx_cursor_t; +} inx_cursor_t; /// cursors.c inx_cursor_t * inx_cursor_alloc(inx_t *index); diff --git a/src/core/indexes/linked.c b/src/core/indexes/linked.c index 85766cb7..dc5b3307 100644 --- a/src/core/indexes/linked.c +++ b/src/core/indexes/linked.c @@ -8,22 +8,22 @@ #include "magma.h" // Linked lists. -typedef struct { +typedef struct __attribute__ ((packed)) { multi_t key; void **data; uint64_t size, count; } linked_record_t; -typedef struct { +typedef struct __attribute__ ((packed)) { linked_record_t *record; struct linked_node_t *next, *prev; } linked_node_t; -typedef struct { +typedef struct __attribute__ ((packed)) { inx_t *inx; linked_node_t *node; uint64_t serial, count, position; -}__attribute__ ((__packed__)) linked_cursor_t; +} linked_cursor_t; /** * @brief Get the data associated with a linked list record. diff --git a/src/network/http.h b/src/network/http.h index 8d23bd42..b5cadf1d 100644 --- a/src/network/http.h +++ b/src/network/http.h @@ -70,7 +70,7 @@ typedef struct { } portal; }; -} __attribute__ ((__packed__)) http_session_t; +} __attribute__ ((packed)) http_session_t; #endif diff --git a/src/network/imap.h b/src/network/imap.h index 360a8a6c..ba69b055 100644 --- a/src/network/imap.h +++ b/src/network/imap.h @@ -25,13 +25,13 @@ typedef struct { struct imap_fetch_response_t *next; } imap_fetch_response_t; -typedef struct { +typedef struct __attribute__ ((packed)) { meta_user_t *user; imap_arguments_t *arguments; stringer_t *tag, *command, *username; int_t read_only, uid, session_state; uint64_t usernum, selected, user_checkpoint, messages_checkpoint, folders_checkpoint, messages_recent, messages_total; -} __attribute__((__packed__)) imap_session_t; +} imap_session_t; #endif diff --git a/src/network/meta.h b/src/network/meta.h index 68d60365..1288d264 100644 --- a/src/network/meta.h +++ b/src/network/meta.h @@ -62,20 +62,20 @@ enum { CREDENTIAL_AUTH = 1 }; -typedef struct { +typedef struct __attribute__ ((packed)) { uint64_t alertnum, created; stringer_t *type, *message; -} __attribute__((__packed__)) meta_alert_t; +} meta_alert_t; /*** * @struct meta_alias_t * @brief Describes user mailboxes and provides the display name for each address, while also indicating which address is the preferred default. */ -typedef struct { +typedef struct __attribute__ ((packed)) { bool_t selected; uint64_t aliasnum, created; stringer_t *display, *address; -} __attribute__((__packed__)) meta_alias_t; +} meta_alias_t; typedef struct { size_t size; diff --git a/src/network/pop.h b/src/network/pop.h index 77544eaa..1fc22f9f 100644 --- a/src/network/pop.h +++ b/src/network/pop.h @@ -14,7 +14,7 @@ typedef struct { int_t session_state; stringer_t *username; uint64_t usernum; -} __attribute__ ((__packed__)) pop_session_t; +} __attribute__ ((packed)) pop_session_t; #endif diff --git a/src/objects/config/config.h b/src/objects/config/config.h index 15bfd110..c2de4117 100644 --- a/src/objects/config/config.h +++ b/src/objects/config/config.h @@ -8,7 +8,7 @@ #ifndef MAGMA_OBJECTS_CONFIG_H #define MAGMA_OBJECTS_CONFIG_H -typedef struct __attribute__ ((__packed__)) { +typedef struct __attribute__ ((packed)) { uint64_t flags; stringer_t *key, *value; } user_config_entry_t; @@ -19,7 +19,7 @@ enum { USER_CONF_STATUS_CRITICAL = 1 }; -typedef struct __attribute__ ((__packed__)) { +typedef struct __attribute__ ((packed)) { inx_t *entries; uint64_t usernum, serial; } user_config_t; diff --git a/src/objects/contacts/contacts.h b/src/objects/contacts/contacts.h index f13da69a..1b4dab7e 100644 --- a/src/objects/contacts/contacts.h +++ b/src/objects/contacts/contacts.h @@ -13,12 +13,12 @@ enum { CONTACT_DETAIL_FLAG_CRITICAL = 1 }; -typedef struct __attribute__ ((__packed__)) { +typedef struct __attribute__ ((packed)) { uint64_t flags; stringer_t *key, *value; } contact_detail_t; -typedef struct __attribute__ ((__packed__)) { +typedef struct __attribute__ ((packed)) { inx_t *details; stringer_t *name; uint64_t contactnum; diff --git a/src/objects/folders/folders.h b/src/objects/folders/folders.h index aa35ab91..bbe15c87 100644 --- a/src/objects/folders/folders.h +++ b/src/objects/folders/folders.h @@ -19,7 +19,7 @@ enum { M_FOLDER_CONTACTS = 2 //!< M_FOLDER_CONTACTS }; -typedef struct __attribute__((__packed__)) { +typedef struct __attribute__ ((packed)) { inx_t *records; uint32_t order; stringer_t *name; diff --git a/src/objects/messages/messages.h b/src/objects/messages/messages.h index f435bd01..f49272d8 100644 --- a/src/objects/messages/messages.h +++ b/src/objects/messages/messages.h @@ -66,7 +66,7 @@ enum { /// LOW: Update the Messages table columns so they match the tank mail message header fields. Store individual header/body lengths /// and the compressed/uncompressed hash values; then update the message type to store and use the new information. -typedef struct __attribute__ ((__packed__)) { +typedef struct __attribute__ ((packed)) { struct { uint64_t num; /* Unique message number. */ diff --git a/src/objects/warehouse/warehouse.h b/src/objects/warehouse/warehouse.h index 04ff43a4..06389bbd 100644 --- a/src/objects/warehouse/warehouse.h +++ b/src/objects/warehouse/warehouse.h @@ -11,14 +11,14 @@ /// HIGH: Create an interface for loading SSL/TLS and DKIM certificates from the database. /// HIGH: Create an interface for checking whether an address or IP is trusted. -typedef struct { +typedef struct __attribute__ ((packed)) { int_t spf; int_t dkim; int_t wildcard; int_t mailboxes; int_t restricted; stringer_t *domain; -} __attribute__((__packed__)) domain_t; +} domain_t; /// datatier.c inx_t * warehouse_fetch_domains(void); diff --git a/src/providers/dime/common/error.c b/src/providers/dime/common/error.c index 934aae7f..15e534d2 100644 --- a/src/providers/dime/common/error.c +++ b/src/providers/dime/common/error.c @@ -13,16 +13,14 @@ #include "providers/symbols.h" // sizeof(errinfo_t) and number elements chosen so the entire data structure fits inside one 4,096 byte page. -struct thread_err_stack { +struct __attribute__ ((packed)) thread_err_stack { errinfo_t error_stack[ERR_STACK_SIZE]; errinfo_t *error_stack_top; unsigned char error_stack_overflow; -} __attribute__((__packed__)); - +}; __thread struct thread_err_stack _t_err_stack; - // The global error message string table. static const err_desc_t err_desc_table[] = { { ERR_SYSCALL, "error [errno] was returned by syscall" }, diff --git a/src/providers/dime/common/error.h b/src/providers/dime/common/error.h index 4eb0257e..ebd05d39 100644 --- a/src/providers/dime/common/error.h +++ b/src/providers/dime/common/error.h @@ -62,14 +62,14 @@ typedef struct { } err_desc_t; -struct errinfo { +struct __attribute__ ((packed)) errinfo { char filename[56]; char funcname[56]; int lineno; unsigned int errcode; int xerrno; char auxmsg[384]; -} __attribute__((__packed__)); +}; typedef struct errinfo errinfo_t; diff --git a/src/providers/dime/dmessage/crypto.h b/src/providers/dime/dmessage/crypto.h index 9eef60f8..17cad3d7 100644 --- a/src/providers/dime/dmessage/crypto.h +++ b/src/providers/dime/dmessage/crypto.h @@ -43,7 +43,7 @@ typedef enum { } dmime_message_state_t; // structure to easily store the KEKs and IVs -typedef struct __attribute__((packed)) { +typedef struct __attribute__ ((packed)) { unsigned char iv[16]; unsigned char key[AES_256_KEY_SIZE]; } dmime_kek_t; @@ -87,7 +87,7 @@ typedef struct { } dmime_object_t; //tracing structure -typedef struct __attribute__((packed)) { +typedef struct __attribute__ ((packed)) { unsigned char size[TRACING_LENGTH_SIZE]; unsigned char data[]; } dmime_tracing_t; @@ -105,7 +105,7 @@ typedef enum { } dmime_message_chunk_state_t; // Chunk of a DIME message. -typedef struct __attribute__((packed)) { +typedef struct __attribute__ ((packed)) { dmime_message_chunk_state_t state; // this size is used to serialize the chunk which follows size_t serial_size; diff --git a/src/providers/dime/dmessage/dmsg.c b/src/providers/dime/dmessage/dmsg.c index bcb79153..9e0676c0 100644 --- a/src/providers/dime/dmessage/dmsg.c +++ b/src/providers/dime/dmessage/dmsg.c @@ -9,7 +9,7 @@ typedef dmime_kek_t dmime_kekset_t[4]; typedef unsigned char dmime_ephemeral_payload_t[EC_PUBKEY_SIZE]; //standard payload structure -typedef struct __attribute__((packed)) { +typedef struct __attribute__ ((packed)) { unsigned char signature[ED25519_SIG_SIZE]; unsigned char data_size[CHUNK_LENGTH_SIZE]; unsigned char flags; @@ -24,7 +24,7 @@ typedef unsigned char dmime_signature_payload_t[ED25519_SIG_SIZE]; typedef unsigned char *dmime_encrypted_payload_t; // keyslot contains the aes keys. Each chunk can have between 0 and 4 keyslots. -typedef struct __attribute__((packed)) { +typedef struct __attribute__ ((packed)) { unsigned char random[16]; // Random bytes. unsigned char iv[16]; // Initialization vector. unsigned char aes_key[AES_256_KEY_SIZE]; diff --git a/src/providers/dime/sds/sds.h b/src/providers/dime/sds/sds.h index ce9f312d..4ce5fc2c 100644 --- a/src/providers/dime/sds/sds.h +++ b/src/providers/dime/sds/sds.h @@ -43,29 +43,29 @@ typedef char *sds; /* Note: sdshdr5 is never used, we just access the flags byte directly. * However is here to document the layout of type 5 SDS strings. */ -struct __attribute__ ((__packed__)) sdshdr5 { +struct __attribute__ ((packed)) sdshdr5 { unsigned char flags; /* 3 lsb of type, and 5 msb of string length */ char buf[]; }; -struct __attribute__ ((__packed__)) sdshdr8 { +struct __attribute__ ((packed)) sdshdr8 { uint8_t len; /* used */ uint8_t alloc; /* excluding the header and null terminator */ unsigned char flags; /* 3 lsb of type, 5 unused bits */ char buf[]; }; -struct __attribute__ ((__packed__)) sdshdr16 { +struct __attribute__ ((packed)) sdshdr16 { uint16_t len; /* used */ uint16_t alloc; /* excluding the header and null terminator */ unsigned char flags; /* 3 lsb of type, 5 unused bits */ char buf[]; }; -struct __attribute__ ((__packed__)) sdshdr32 { +struct __attribute__ ((packed)) sdshdr32 { uint32_t len; /* used */ uint32_t alloc; /* excluding the header and null terminator */ unsigned char flags; /* 3 lsb of type, 5 unused bits */ char buf[]; }; -struct __attribute__ ((__packed__)) sdshdr64 { +struct __attribute__ ((packed)) sdshdr64 { uint64_t len; /* used */ uint64_t alloc; /* excluding the header and null terminator */ unsigned char flags; /* 3 lsb of type, 5 unused bits */ diff --git a/src/providers/dime/signet-resolver/dns.h b/src/providers/dime/signet-resolver/dns.h index 927e7f21..c6398a47 100644 --- a/src/providers/dime/signet-resolver/dns.h +++ b/src/providers/dime/signet-resolver/dns.h @@ -53,7 +53,7 @@ #define DNSSEC_DIGEST_SHA256 2 -typedef struct { +typedef struct __attribute__ ((packed)) { #if BYTE_ORDER == BIG_ENDIAN unsigned int reserved1 : 7; unsigned int zone_key : 1; @@ -65,9 +65,9 @@ typedef struct { unsigned int sep : 1; unsigned int reserved2 : 7; #endif -} __attribute__((__packed__)) dnskey_rr_flags_t; +} dnskey_rr_flags_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint16_t covered; ///< The type of the rr set covered by this record. uint8_t algorithm; ///< The numerical id of the cryptographic algorithm used to generate the signature. uint8_t labels; ///< The number of labels in the original RRSIG RR owner name. @@ -77,14 +77,14 @@ typedef struct { uint16_t key_tag; ///< A tag (selector) identifying the corresponding DNSKEY RR (which isn't necessarily unique) that validates this record. unsigned char signame; ///< A label identifying the owner name of the DNSKEY RR validating this signature (must not use name compression). // Signame is followed by the actual signature -} __attribute__((__packed__)) rrsig_rr_t; +} rrsig_rr_t; -typedef struct { +typedef struct __attribute__ ((packed)) { uint16_t key_tag; ///< The keytag of the DNSKEY RR to which this record refers. uint8_t algorithm; ///< The algorithm used by this RR's referenced DNSKEY. uint8_t digest_type; ///< The type of the digest algorithm used by the digest field. unsigned char digest; ///< A digest of this RR's referenced DNSKEY. -} __attribute__((__packed__)) ds_rr_t; +} ds_rr_t; typedef struct ds ds_t; diff --git a/src/providers/prime/prime.h b/src/providers/prime/prime.h index 7346cfc1..f682d916 100644 --- a/src/providers/prime/prime.h +++ b/src/providers/prime/prime.h @@ -89,8 +89,7 @@ typedef enum { /** * @typedef prime_message_chunk_type_t - */ -typedef enum { + */typedef enum { PRIME_CHUNK_INVALID = -1, // Tracing diff --git a/src/providers/storage/tree.c b/src/providers/storage/tree.c index 2ef79ea0..80965d9d 100644 --- a/src/providers/storage/tree.c +++ b/src/providers/storage/tree.c @@ -7,12 +7,12 @@ #include "magma.h" -typedef struct { +typedef struct __attribute__ ((packed)) { inx_t *inx; void *tree; multi_t key; void *value; -}__attribute__ ((__packed__)) tree_cursor_t; +} tree_cursor_t; /** * The return value is positive if the former is big, negative if the latter is big, 0 if both are equivalent. If asked to search for a NULL key pointer |