warnings: ensure optimal packing in structures

Add padding where needed and order structure when it makes alignment fall
naturally to better order, with a single padding at the end of structure.

Reference: http://www.catb.org/esr/structure-packing/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2019-02-17 11:25:09 +00:00
parent 6f6369f517
commit 71714a0993
No known key found for this signature in database
GPG key ID: 0D46FEF7E61DBB46
3 changed files with 14 additions and 9 deletions

View file

@ -340,9 +340,9 @@ int main(int argc, char **argv)
.warn_count = 0x100000000, /* == 2^32 that is the entire IPv4 space */
.crit_count = 0x100000000, /* basically turns off the count criteria */
.header_limit = 8,
.color_mode = color_auto,
.ranges_size = 64,
.ip_version = IPvUNKNOWN,
.color_mode = color_auto,
0
};
int ret_val;

View file

@ -125,8 +125,9 @@ struct shared_network_t {
double used;
double touched;
double backups;
int netmask;
struct shared_network_t *next;
int netmask;
uint32_t pad;
};
/*! \struct range_t
@ -145,12 +146,13 @@ struct range_t {
* \brief Various per range and shared net temporary calculation results.
*/
struct output_helper_t {
int status;
double range_size;
double percent;
double tc;
double tcp;
double bup;
int status;
uint32_t pad;
};
/*! \enum ltype
@ -167,9 +169,10 @@ enum ltype {
*/
struct leases_t {
union ipaddr_t ip; /* ip as key */
enum ltype type;
char *ethernet;
UT_hash_handle hh;
enum ltype type;
uint32_t pad;
};
/*! \enum limbits
@ -209,22 +212,22 @@ struct conf_t {
struct shared_network_t *shared_net_head; /*!< Last entry in shared network linked list. */
struct range_t *ranges; /*!< Array of ranges. */
unsigned int num_ranges; /*!< Number of ranges in the ranges array. */
enum dhcp_version ip_version; /*!< Designator if the dhcpd is running in IPv4 or IPv6 mode. */
size_t ranges_size; /*!< Size of the ranges array. */
struct leases_t *leases; /*!< An array of individual leases from dhcpd.leases file. */
enum dhcp_version ip_version; /*!< Designator if the dhcpd is running in IPv4 or IPv6 mode. */
const char *dhcpdconf_file; /*!< Path to dhcpd.conf file. */
const char *dhcpdlease_file; /*!< Path to dhcpd.leases file. */
int color_format; /*!< Column to use in color_tags array. */
struct output_sort *sorts; /*!< Linked list how to sort ranges. */
const char *output_file; /*!< Output file path. */
char output_format; /*!< Output format, such as text, json, xml, .... */
const char *mustach_template; /*!< Mustach template file path. */
double warning; /*!< Warning percent threshold. */
double critical; /*!< Critical percent threshold. */
double warn_count; /*!< Maximum number of free IP's before warning. */
double crit_count; /*!< Maximum number of free IP's before critical. */
double minsize; /*!< Minimum size of range or shared network to be considered exceeding threshold. */
unsigned int
int color_format; /*!< Column to use in color_tags array. */
char output_format; /*!< Output format, such as text, json, xml, .... */
uint32_t
print_mac_addreses:1, /*!< Print mac address in xml or json. */
reverse_order:1, /*!< Reverse sort order. */
backups_found:1, /*!< Indicator if dhcpd.leases file has leases in backup state. */
@ -238,7 +241,8 @@ struct conf_t {
skip_critical:1, /*!< Skip critical values from output. */
skip_minsize:1, /*!< Skip alarming values that are below minsize from output. */
skip_suppressed:1, /*!< Skip alarming values that are suppressed with --snet-alarms option, or they are shared networks without IP availability. */
color_mode:2; /*!< Indicator if colors should be used in output. */
color_mode:2, /*!< Indicator if colors should be used in output. */
pad_bits:4;
};
/* Function prototypes */

View file

@ -62,6 +62,7 @@ struct expl {
struct shared_network_t *shnet_p;
struct output_helper_t oh;
int current;
uint32_t pad;
};
static int must_enter(void *closure, const char *name);