]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Padding and alignment is really the same thing.
authorVincent Bernat <bernat@luffy.cx>
Thu, 11 Dec 2008 19:40:36 +0000 (20:40 +0100)
committerVincent Bernat <bernat@luffy.cx>
Thu, 11 Dec 2008 19:40:36 +0000 (20:40 +0100)
src/ctl.c

index f12b83cf27282c0ff4aec58001c4fb1850d1193e..4988b69c2c356b480607e09f508b4db7bad76b80 100644 (file)
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -435,6 +435,7 @@ ctl_msg_packunpack_structure(char *format, void *structure, unsigned int size,
                 * occur. */
                ce = NULL;
                if (*f == '(') {
+                       /* We need to align, compute the needed alignment */
                        if ((align = calloc(1,
                                    sizeof(struct stack_align))) == NULL) {
                                LLOG_WARN("unable to allocate memory "
@@ -444,17 +445,12 @@ ctl_msg_packunpack_structure(char *format, void *structure, unsigned int size,
                        talign = align->align = ctl_msg_get_alignment(f);
                        SLIST_INSERT_HEAD(&aligns, align, next);
                } else if (*f == ')') {
-                       /* Pad the structure */
+                       /* We need to pad, retrieve the needed alignment */
                        align = SLIST_FIRST(&aligns);
                        talign = align->align;
-                       if ((talign > 0) && (csize % talign != 0)) {
-                               structure += talign - (csize % talign);
-                               csize += talign - (csize % talign);
-                       }
                        align_next = SLIST_NEXT(align, next);
                        SLIST_REMOVE_HEAD(&aligns, next);
                        free(align);
-                       continue;
                } else {
                        for (ce = conv_table;
                             (ce->format != 0) && (ce->format != *f);