Skip to content

Commit c5eac97

Browse files
committed
Minor fix having to do with issue 6
1 parent 10464db commit c5eac97

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/build_filter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ int main(int argc, char **argv) {
142142
if (synthetic) {
143143
array_size = synthetic_size;
144144
array = (uint64_t *)malloc(array_size * sizeof(uint64_t));
145+
if(array == NULL) {
146+
printf("memory allocate failure\n");
147+
return EXIT_FAILURE;
148+
}
145149
for (size_t i = 0; i < array_size; i++) {
146150
array[i] = i;
147151
}

src/hexutil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static inline uint32_t hex_to_u32_nocheck(
2626
// all these will sign-extend the chars looked up, placing 1-bits into the
2727
// high 28 bits of every invalid value. After the shifts, this will *still*
2828
// result in the outcome that the high 16 bits of any value with any invalid
29-
// char will be all 1's. We check for this in the caller.
29+
// char will be all 1's. We check for this in the calling function.
3030
int32_t v1 = digittoval[src[0]];
3131
int32_t v2 = digittoval[src[1]];
3232
int32_t v3 = digittoval[src[2]];

src/query_filter.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <sys/mman.h>
1717

1818
static void printusage(char *command) {
19-
printf(" Try %s filter.bin 7C4A8D09CA3762AF \n", command);
19+
printf(" Try %s filter.bin 7C4A8D09CA3762AF (use 16-hex-character keys)\n", command);
2020
;
2121
printf("Use the -s if you want to provide a string to be hashed (SHA1).\n");
2222
}
@@ -59,10 +59,10 @@ int main(int argc, char **argv) {
5959
hexval = ((uint64_t)digest[0] << 32) | digest[1];
6060
} else {
6161
const char *hashhex = argv[optind + 1];
62-
if (strlen(hashhex) < 16) {
63-
printf("bad hex. length is %zu \n", strlen(hashhex));
62+
if (strlen(hashhex) != 16) {
63+
printf("bad hex. length is %zu, 16 hexadecimal characters expected.\n", strlen(hashhex));
6464
printusage(argv[0]);
65-
return -1;
65+
return EXIT_FAILURE;
6666
}
6767
uint64_t x1 = hex_to_u32_nocheck((const uint8_t *)hashhex);
6868
uint64_t x2 = hex_to_u32_nocheck((const uint8_t *)hashhex + 4);
@@ -122,6 +122,8 @@ int main(int argc, char **argv) {
122122
binfilter.Seed = seed;
123123
isok &=
124124
fread(&binfilter.SegmentLength, sizeof(binfilter.SegmentLength), 1, fp);
125+
isok &=
126+
fread(&binfilter.SegmentLengthMask, sizeof(binfilter.SegmentLengthMask), 1, fp);
125127
isok &=
126128
fread(&binfilter.SegmentCount, sizeof(binfilter.SegmentCount), 1, fp);
127129
isok &= fread(&binfilter.SegmentCountLength,

0 commit comments

Comments
 (0)