1. 16 3月, 2019 1 次提交
    • E
      object: Add sanity check on correct parent class · 1c560052
      Eric Blake 提交于
      Checking that the derived class is larger than the requested parent
      class saves us from some obvious mistakes, but as written, it does not
      catch all the cases; in particular, it is easy to forget to update a
      VIR_CLASS_NEW when changing the 'parent' member from virObject to
      virObjectLockabale, but where the size checks don't catch that.  Add a
      parameter for one more layer of sanity checking.
      
      It would be cool if we could get gcc to stringize typeof(parent) into
      the string name of that type, so that we could confirm that the
      precise parent class is in use rather than just a struct that happens
      to have the same size as the parent class.  But sizeof checks are
      better than nothing.
      
      Note that I did NOT change the fact that we require derived classes to
      be larger (as the difference in size makes it easy to tell classes
      apart), which means that even if a derived class has no functionality
      to add (but rather exists for compiler-enforced type-safety), it must
      still include a dummy member.  But I did fix the wording of the error
      message to match the code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      1c560052
  2. 15 3月, 2019 19 次提交
  3. 14 3月, 2019 20 次提交