From: Kay Sievers Date: Sun, 17 Jul 2005 13:40:29 +0000 (-0400) Subject: add padding to rules structure X-Git-Tag: 064~8 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=422d5becc339304805bbe1e359f6389633036a98;p=systemd add padding to rules structure Some architectures really want well alingned structures. Thanks to Jim Gifford for help finding it. Signed-off-by: Kay Sievers --- diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index f4011ee8..ab116e9d 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -497,6 +497,3 @@ int main(int argc, char **argv) } exit(retval); } - - - diff --git a/udev_rules_parse.c b/udev_rules_parse.c index 0259268c..e708f355 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -241,6 +241,7 @@ static int add_to_rules(struct udev_rules *rules, char *line) int valid; char *linepos; char *attr; + size_t padding; int retval; /* get all the keys */ @@ -506,6 +507,11 @@ static int add_to_rules(struct udev_rules *rules, char *line) /* grow buffer and add rule */ rule_size = sizeof(struct udev_rule) + rule->bufsize; + padding = (sizeof(size_t) - rule_size % sizeof(size_t)) % sizeof(size_t); + dbg("add %zi padding bytes", padding); + rule_size += padding; + rule->bufsize += padding; + rules->buf = realloc(rules->buf, rules->bufsize + rule_size); if (!rules->buf) { err("realloc failed");