sunflower-embedded-system-emulator icon indicating copy to clipboard operation
sunflower-embedded-system-emulator copied to clipboard

Replace Maddr with uintptr_t

Open harrysarson opened this issue 6 years ago • 0 comments

Problem

  • make gives a fair few warnings: warning: cast from pointer to integer of different size.
  • These are all due to casts from void * (32 bit) to Maddr (64 bit).

Solutions

  • This cast is safe (as the number of bits are increasing) so we could turn off the warning.
  • However, there is a type designed for storing pointers as an int: uintptr_t (https://en.cppreference.com/w/c/types/integer).
  • The Maddr is only using in mmalloc.c. Unless there is some deeper perpose behind Maddr that I am missing we seem to have "reinvented the wheel" and we could simplify the code base as well as removing these compiler warnings by using uintptr_t here.

harrysarson avatar Mar 04 '19 15:03 harrysarson