Skip to content

Commit

Permalink
Fix an issue with parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
malaterre committed Oct 10, 2015
1 parent dc869c2 commit ab89292
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lib/openjp2/mct.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ void opj_mct_encode(
OPJ_SIZE_T i;
const OPJ_SIZE_T len = n;
/* buffer are aligned on 16 bytes */
assert( (uintptr_t)c0 & 16 == 0 );
assert( (uintptr_t)c1 & 16 == 0 );
assert( (uintptr_t)c2 & 16 == 0 );
assert( ((uintptr_t)c0 & 0xf) == 0 );
assert( ((uintptr_t)c1 & 0xf) == 0 );
assert( ((uintptr_t)c2 & 0xf) == 0 );

This comment has been minimized.

Copy link
@mayeut

mayeut Oct 11, 2015

Collaborator

Isn't uintptr_t optional even in c99 ? given the comparison, it can be replaced with a, maybe, shorter but always defined unsigned int.

This comment has been minimized.

Copy link
@malaterre

malaterre Oct 12, 2015

Author Collaborator

the code would be less readable. I believe uintptr_t is required in C99, we could use ptrdiff_t if we want to be closer to C89. ref: http://en.cppreference.com/w/c/types/ptrdiff_t and http://en.cppreference.com/w/c/types/integer

This comment has been minimized.

Copy link
@mayeut

mayeut Oct 12, 2015

Collaborator

I would use size_t but really, any type that's not C99 would do since it only needs to be able to hold 15U.


for(i = 0; i < (len & ~3U); i += 4) {
__m128i y, u, v;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjp2/opj_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static inline void *opj_aligned_realloc_n(void *ptr, size_t alignment, size_t si
/* glibc doc states one can mixed aligned malloc with realloc */
void *r_ptr = realloc( ptr, size );
/* fast path */
if( (uintptr_t)r_ptr & alignment == 0 )
if( ((uintptr_t)r_ptr & alignment) == 0 )

This comment has been minimized.

Copy link
@mayeut

mayeut Oct 11, 2015

Collaborator

Same comment about uintptr_t.
The comparison shall be made with (alignment -1U) I think ?

This comment has been minimized.

Copy link
@malaterre

malaterre Oct 12, 2015

Author Collaborator

sorry about that. I could not decide which one was clearer: % alignement or & alignement - 1u. Will fix asap

This comment has been minimized.

Copy link
@mayeut

mayeut Oct 12, 2015

Collaborator

& (alignement - 1U) will be faster.

return r_ptr;
/* this is non-trivial to implement a portable aligned realloc, so use a
* simple approach where we do not need a function that return the size of an
Expand Down

0 comments on commit ab89292

Please sign in to comment.