mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: use STATIC_ASSERT macro for no padding verification
A simple comment above the struct declaration to indicate that the structure must not have any padding is prone to error. Therefore let's add a check for the structure size at compile time. Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
bac3f93772
commit
cc16e41595
@@ -60,6 +60,7 @@ struct sccb_header {
|
||||
uint8_t control_mask[3];
|
||||
uint16_t response_code;
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct sccb_header) == 2 + 1 + 3 + 2)
|
||||
|
||||
/* Structure must not have any padding */
|
||||
struct evbuf_header {
|
||||
@@ -68,6 +69,7 @@ struct evbuf_header {
|
||||
uint8_t flags;
|
||||
uint16_t _reserved;
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct evbuf_header) == 2 + 1 + 1 + 2)
|
||||
|
||||
struct mto {
|
||||
uint16_t length;
|
||||
|
||||
@@ -42,6 +42,8 @@ struct sdias_sccb {
|
||||
struct sccb_header header;
|
||||
struct sdias_evbuf evbuf;
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct sdias_sccb) ==
|
||||
sizeof(struct sccb_header) + sizeof(struct sdias_evbuf))
|
||||
|
||||
|
||||
int sclp_hsa_copy(void *, unsigned long, unsigned long);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "libc.h"
|
||||
#include "s390.h"
|
||||
|
||||
#include "lib/zt_common.h"
|
||||
|
||||
#define IPL_DEVICE 0x10404UL
|
||||
#define INITRD_START 0x10408UL
|
||||
#define INITRD_SIZE 0x10410UL
|
||||
@@ -128,6 +130,7 @@ struct ipl_rb_hdr {
|
||||
uint8_t rbt;
|
||||
uint8_t reserved1[11];
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct ipl_rb_hdr) == 4 + 1 + 11)
|
||||
|
||||
/* IPL Report Block types */
|
||||
enum ipl_rbt {
|
||||
@@ -168,6 +171,7 @@ struct ipl_rb_components {
|
||||
uint8_t reserved1[11];
|
||||
struct ipl_rb_component_entry entries[];
|
||||
};
|
||||
STATIC_ASSERT(sizeof(struct ipl_rb_components) == 4 + 1 + 11)
|
||||
|
||||
extern unsigned long long _parm_addr; /* address of parmline */
|
||||
extern unsigned long long _initrd_addr; /* address of initrd */
|
||||
|
||||
Reference in New Issue
Block a user