Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix addAtAddress ambiguous overloads #12

Open
JJL772 opened this issue Jul 12, 2024 · 0 comments
Open

Fix addAtAddress ambiguous overloads #12

JJL772 opened this issue Jul 12, 2024 · 0 comments

Comments

@JJL772
Copy link
Member

JJL772 commented Jul 12, 2024

Getting a lot of warnings like:

../cpsw_api_builder.h:97:23: warning: ‘virtual void IDev::addAtAddress(Field, unsigned int)’ was hidden [-Woverloaded-virtual=]
   97 |         virtual  void addAtAddress( Field f, unsigned nelms = DFLT_NELMS ) = 0;
      |                       ^~~~~~~~~~~~
../cpsw_api_builder.h:127:22: note:   by ‘virtual void IMMIODev::addAtAddress(Field, uint64_t, unsigned int, uint64_t, ByteOrder)’
  127 |         virtual void addAtAddress(Field child, uint64_t offset, unsigned nelms = DFLT_NELMS, uint64_t stride = DFLT_STRIDE, ByteOrder byteOrder = DFLT_BYTE_ORDER ) = 0;
      |                      ^~~~~~~~~~~~
../cpsw_api_builder.h:97:23: warning: ‘virtual void IDev::addAtAddress(Field, unsigned int)’ was hidden [-Woverloaded-virtual=]
   97 |         virtual  void addAtAddress( Field f, unsigned nelms = DFLT_NELMS ) = 0;
      |                       ^~~~~~~~~~~~
../cpsw_api_builder.h:140:33: note:   by ‘virtual void IMemDev::addAtAddress(Field, int)’
  140 |         virtual void            addAtAddress(Field child, int align = DFLT_ALIGN) = 0;
      |                                 ^~~~~~~~~~~~

This looks like a pretty big landmine since the only differentiating factor is signedness of the second argument. (int align vs unsigned nelms)

This could be resolved by either renaming the first method from virtual void addAtAddress( Field f, unsigned nelms = DFLT_NELMS ) to virtual void addArrayAtAddress( Field f, unsigned nelms = DFLT_NELMS ), or by changing the type of int align to something that isn't implicitly convertible to an integral type. For example, Align_t which has an explicit constructor taking int.

Both solutions will require an audit of modules using CPSW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant