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

unnecessary calculation in function s_get_next_block of salloc.c #167

Open
Changqing-JING opened this issue Jan 8, 2020 · 0 comments
Open

Comments

@Changqing-JING
Copy link

static char* s_get_next_block( char* ptr )
{
return ( char* )( ( ( u32 )ptr & 0x7FFFFFFF ) << DYN_SIZE_MULT_SHIFT );
}

This function is made of two calculations:

  1. set the highest bit as 0.
  2. left shift 3 bits

But if a number is left shift for 3 bits, the highest bit will be overflow. So the result is independent of whether the highest bit is 0 or 1. The first calculation can be removed.

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