Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ char* str_replace_n(const char* src, size_t start_pos, size_t end_pos, const cha
int is_binary_string(const char* str)
{
for (; *str; str++) {
if (((unsigned char)*str) < 32 && ((1 << (unsigned char)*str) & ~0x2600)) {
if (((unsigned char)*str) < 32 && ((1u << (unsigned char)*str) & ~0x2600u)) {
return 1;
}
}
Expand Down
6 changes: 3 additions & 3 deletions hash_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ static int detect_hash_type(char** ptr, char* end, int* p_len)
*/
static int is_acceptable_bit_length(int length)
{
if ((length & 31) == 0 && length <= 512)
if (length > 0 && (length & 31) == 0 && length <= 512)
{
int pow = get_ctz(length >> 5);
int code = ((length >> (pow + 6)) << 3) | pow;
return (code < 32 && ((1 << code) & 0x101061d));
return (code < 32 && ((1u << code) & 0x101061du));
}
return 0;
}
Expand Down Expand Up @@ -347,7 +347,7 @@ static unsigned bsd_hash_name_to_id(const char* name, size_t length, enum HashNa
return (length == strlen(hash_info_table[i].name) ? hash_mask : 0);
}
/* look for the hash_id in the hash_mask */
for (hash_id = 1 << i; hash_id && hash_id <= hash_mask; i++, hash_id <<= 1)
for (hash_id = 1u << i; hash_id && hash_id <= hash_mask; i++, hash_id <<= 1)
{
const char* a;
const char* b;
Expand Down
2 changes: 1 addition & 1 deletion librhash/hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ size_t rhash_base64_url_encoded_helper(char* dst, const unsigned char* src, size

/* RFC 3986: safe url characters are ascii alpha-numeric and "-._~", other characters should be percent-encoded */
static unsigned url_safe_char_mask[4] = { 0, 0x03ff6000, 0x87fffffe, 0x47fffffe };
#define IS_URL_GOOD_CHAR(c) ((unsigned)(c) < 128 && (url_safe_char_mask[c >> 5] & (1 << (c & 31))))
#define IS_URL_GOOD_CHAR(c) ((unsigned)(c) < 128 && (url_safe_char_mask[c >> 5] & (1u << (c & 31))))

/**
* URL-encode specified binary string.
Expand Down
7 changes: 5 additions & 2 deletions librhash/rhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,11 @@ static unsigned ids_array_to_hash_bitmask(size_t count, unsigned* data)
bitmask |= data[i];
else if (data[i] == RHASH_ALL_HASHES)
bitmask |= RHASH_LOW_HASHES_MASK;
else
bitmask |= 1 << GET_EXTENDED_HASH_ID_INDEX(data[i]);
else {
unsigned index = GET_EXTENDED_HASH_ID_INDEX(data[i]);
if (index < RHASH_HASH_COUNT)
bitmask |= 1u << index;
}
}
return bitmask;
}
Expand Down
2 changes: 1 addition & 1 deletion output.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ int fprintf_file_t(FILE* out, const char* format, struct file_t* file, unsigned

/* RFC 3986: safe url characters are ascii alpha-numeric and "-._~", other characters should be percent-encoded */
static unsigned url_safe_char_mask[4] = { 0, 0x03ff6000, 0x87fffffe, 0x47fffffe };
#define IS_URL_GOOD_CHAR(c) ((unsigned)(c) < 128 && (url_safe_char_mask[c >> 5] & (1 << (c & 31))))
#define IS_URL_GOOD_CHAR(c) ((unsigned)(c) < 128 && (url_safe_char_mask[c >> 5] & (1u << (c & 31))))

/**
* Print to a stram an url-encoded representation of the given string.
Expand Down
Loading