Skip to content

Commit

Permalink
Remove warnings from bytecode compiler headers
Browse files Browse the repository at this point in the history
ClamAV has specific sizes for arguments to be used in memcmp and malloc,
which are different from the standard arguments (uint32_t vs uint64_t).
Suppress those warnings so that they don't interfere with the legitimate
warnings that developers will want to see.
  • Loading branch information
ragusaa authored and val-ms committed Jun 23, 2022
1 parent 444bda7 commit 54c709f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions headers/bytecode_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ int32_t file_find(const uint8_t* data, uint32_t len);
*/
int32_t file_byteat(uint32_t offset);


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wincompatible-library-redeclaration"
/**
\group_adt
* Allocates memory. Currently this memory is freed automatically on exit
Expand All @@ -497,6 +500,7 @@ int32_t file_byteat(uint32_t offset);
* @return pointer to allocated memory
*/
void* malloc(uint32_t size);
#pragma GCC diagnostic pop

/**
* Test api2.
Expand Down
2 changes: 1 addition & 1 deletion headers/bytecode_ilog.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
static const ilog_table[2049] = {
static const int32_t ilog_table[2049] = {
0x0, 0x0, 0x58b90c0, 0x8c9f540, 0xb172180, 0xce02100, 0xe558600, 0xf913950,
0x10a2b240, 0x1193ea80, 0x126bb1c0, 0x132ee3c0, 0x13e116c0, 0x14850420, 0x151cca20, 0x15aa1640,
0x162e4300, 0x16aa6bc0, 0x171f7b40, 0x178e3600, 0x17f74280, 0x185b2ea0, 0x18ba7480, 0x19157e00,
Expand Down
8 changes: 6 additions & 2 deletions headers/bytecode_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ static force_inline bool hasPEInfo(void)
__fail_missing_PE_HOOK_DECLARE__or__PE_UNPACKER_DECLARE(); \
}


/**
\group_pe
* Returns whether this is a PE32+ executable.
Expand Down Expand Up @@ -913,8 +914,8 @@ static force_inline bool getPEisDLL()
static force_inline uint32_t getPEDataDirRVA(unsigned n)
{
NEED_PE_INFO;
struct pe_image_data_dir *p = &__clambc_pedata.opt64_dirs[n];
struct pe_image_data_dir *p32 = &__clambc_pedata.opt32_dirs[n];
const struct pe_image_data_dir *p = &__clambc_pedata.opt64_dirs[n];
const struct pe_image_data_dir *p32 = &__clambc_pedata.opt32_dirs[n];
return n < 16 ? le32_to_host(isPE64() ? p->VirtualAddress : p32->VirtualAddress)
: 0;
}
Expand Down Expand Up @@ -1139,6 +1140,8 @@ void *memmove(void *dst, const void *src, uintptr_t n)
void *memcpy(void *restrict dst, const void *restrict src, uintptr_t n)
__attribute__((__nothrow__)) __attribute__((__nonnull__(1, 2)));

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wincompatible-library-redeclaration"
/**
\group_string
* [LLVM Intrinsic] Compares two memory buffers, \p s1 and \p s2 to length \p n.
Expand All @@ -1150,6 +1153,7 @@ void *memcpy(void *restrict dst, const void *restrict src, uintptr_t n)
* or be greater than the first \p n bytes of \p s2.*/
int memcmp(const void *s1, const void *s2, uint32_t n)
__attribute__((__nothrow__)) __attribute__((__pure__)) __attribute__((__nonnull__(1, 2)));
#pragma GCC diagnostic pop

/**
\group_disasm
Expand Down

0 comments on commit 54c709f

Please sign in to comment.