fprintf: Remove bogus deduction of negative hole from size of previous field
commit4faf35b97c3427d1e2eebd6d7c6d900813d8c73c
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Mar 2024 15:09:53 +0000 (11 12:09 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 11 Mar 2024 15:09:53 +0000 (11 12:09 -0300)
tree571ea8f4130125edaab68849251a66efd05f4fe6
parent47e83035c12c153b579db2e5fabd306a0d6f2d29
fprintf: Remove bogus deduction of negative hole from size of previous field

In the previous fix for the usage of padding from ancestor classes the
negative hole was being deducted from the calculation of the previous
member/ancestor that is done purely using the offsets of the current and
previous fields, where it makes no sense to consider the hole, so revert
that specific hunk, with it the "Bitfield combined with next fields"
comment, which is wrong, is removed.

Before:

  $ pahole -C Spell_AdjustVital objects/spell_adjustvital.cpp.o
  class Spell_AdjustVital : public SpellActionType {
  public:

          /* class SpellActionType     <ancestor>; */      /*     0    16 */

          /* XXX last struct has 4 bytes of padding */
          void Spell_AdjustVital(class Spell_AdjustVital *);

          virtual int Cast(class Spell_AdjustVital *, class CUnit &, const class SpellType  &, class CUnit * &, const Vec2i  &);

          virtual void Parse(class Spell_AdjustVital *, lua_State *, int, int);

          /* Bitfield combined with next fields */

          int                        HP;                   /*    12     4 */
          int                        Mana;                 /*    16     4 */
          int                        Shield;               /*    20     4 */
          int                        MaxMultiCast;         /*    24     4 */
          virtual void ~Spell_AdjustVital(class Spell_AdjustVital *, int);

          /* vtable has 2 entries: {
             [2] = Cast((null)),
             [3] = Parse((null)),
          } */
          /* size: 32, cachelines: 1, members: 5 */
          /* padding: 4 */
          /* paddings: 1, sum paddings: 4 */
          /* last cacheline: 32 bytes */
  };

After:

  $ pahole -C Spell_AdjustVital objects/spell_adjustvital.cpp.o
  class Spell_AdjustVital : public SpellActionType {
  public:

          /* class SpellActionType     <ancestor>; */      /*     0    16 */

          /* XXX last struct has 4 bytes of padding */
          void Spell_AdjustVital(class Spell_AdjustVital *);

          virtual int Cast(class Spell_AdjustVital *, class CUnit &, const class SpellType  &, class CUnit * &, const Vec2i  &);

          virtual void Parse(class Spell_AdjustVital *, lua_State *, int, int);

          int                        HP;                   /*    12     4 */
          int                        Mana;                 /*    16     4 */
          int                        Shield;               /*    20     4 */
          int                        MaxMultiCast;         /*    24     4 */
          virtual void ~Spell_AdjustVital(class Spell_AdjustVital *, int);

          /* vtable has 2 entries: {
             [2] = Cast((null)),
             [3] = Parse((null)),
          } */
          /* size: 32, cachelines: 1, members: 5 */
          /* padding: 4 */
          /* paddings: 1, sum paddings: 4 */
          /* last cacheline: 32 bytes */
  };

  $

Reported-by: Matthias Schwarzott <zzam@gentoo.org>
Fixes: 47e83035c12c153b ("core: The padding in ancestor classes may be used in descendants")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
dwarves_fprintf.c