TCMAPKMAXSIZ is used in assignments & comparisons both as bitmask and as integer.

Bug #500589 reported by eulores
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tokyocabinet
New
Undecided
Unassigned

Bug Description

In file tcutil.c the constant TCMAPKMAXSIZ is defined as:
#define TCMAPKMAXSIZ 0xfffff

Further down in the file, some excerpts make use of the constant:

a) ... = rec->ksiz & TCMAPKMAXSIZ
b) if(ksiz > TCMAPKMAXSIZ) ...
c) hash &= ~TCMAPKMAXSIZ

If someone changes the #define to a number not consisting of a sequence of binary "1", then statements a) and c) will fail.

I suggest rewriting the #define to something like:
# define TCMAPKMAXSIZ ((1 << 20) - 1)

Otherwise, rewriting statements a) and c) by using for example the ternary operator (?:).

Tags: enhancement
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.