Skip to content

Commit

Permalink
fix some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
randomdude999 committed Jan 19, 2024
1 parent 0b4b929 commit 13393a9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/asar-tests/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# include <algorithm>
# include <set>
# include <list>
# include <cstdint>

# if defined(_MSC_VER)
# pragma warning(pop)
Expand Down
6 changes: 4 additions & 2 deletions src/asar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ macro(set_asar_shared_properties target msvc_lib_type_param enable_sanitizer)
else()
target_compile_options(${target} PRIVATE -Wall -pedantic
-Wno-varargs # passing an object that undergoes default argument promotion to 'va_start' has undefined behavior
-Wno-unused-result # ignoring return value
-Wno-class-memaccess # clearing/moving a non-trivially copyable type
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# doesn't exist on clang, and clang yells about unknown options
target_compile_options(${target} PRIVATE -Wno-class-memaccess)
endif()

# Static link for MinGW
if(MINGW)
Expand Down
15 changes: 8 additions & 7 deletions src/asar/arch-spc700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

#define write1 write1_pick

static int writesizeto=-1;
static int inlinestartpos=0;

static int64_t getnum_ck(const char* math)
{
return pass == 2 ? getnum(math) : 0;
Expand Down Expand Up @@ -267,11 +264,15 @@ bool asblock_spc700(char** word, int numwords)
#define vc(left1, right1, str2) if (isvc(left1, right1, str2))
#define vv(left1, right1, left2, right2) if (isvv(left1, right1, left2, right2))
#define w0(opcode) do { write1((unsigned int)opcode); return true; } while(0)
#define w1(opcode, math) do { write1((unsigned int)opcode); unsigned int val=getnum_ck(math); \
if ((((val&0xFF00)&&(val&0x80000000)==0)||(((val&0xFF00)!=0xFF00)&&(val&0x80000000)))&&opLen!=1) asar_throw_warning(0, warning_id_spc700_assuming_8_bit); write1(val);return true; } while(0)
#define w1(opcode, math) do { \
write1((unsigned int)opcode); unsigned int val=getnum_ck(math); \
if ((((val&0xFF00)&&(val&0x80000000)==0)||(((val&0xFF00)!=0xFF00)&&(val&0x80000000)))&&opLen!=1) asar_throw_warning(0, warning_id_spc700_assuming_8_bit); \
write1(val); return true; } while(0)
#define w2(opcode, math) do { write1((unsigned int)opcode); write2(getnum_ck(math)); return true; } while(0)
#define wv(opcode1, opcode2, math) do { if ((opLen == 1) || (opLen == 0 && getlen(math)==1)) { write1((unsigned int)opcode1); write1(getnum_ck(math)); } \
else { write1((unsigned int)opcode2); write2(getnum_ck(math)); } return true; } while(0)
#define wv(opcode1, opcode2, math) do { \
if ((opLen == 1) || (opLen == 0 && getlen(math)==1)) { write1((unsigned int)opcode1); write1(getnum_ck(math)); } \
else { write1((unsigned int)opcode2); write2(getnum_ck(math)); } \
return true; } while(0)
#define w11(opcode, math1, math2) do { write1((unsigned int)opcode); write1(getnum_ck(math1)); write1(getnum_ck(math2)); return true; } while(0)
#define wr(opcode, math) do { int len=getlen(math); int num=(int)getnum_ck(math); int pos=(len==1)?num:num-(snespos+2); \
if (pass && foundlabel && (pos<-128 || pos>127)) asar_throw_error(2, error_type_block, error_id_relative_branch_out_of_bounds, dec(pos).data()); \
Expand Down
1 change: 0 additions & 1 deletion src/asar/assembleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,6 @@ void assembleblock(const char * block, int& single_line_for_tracker)
#endif
else if (is1("incsrc"))
{
const char* current_file = get_current_file_name();
string name;
// RPG Hacker: Should this also throw on absolute paths?
// E.g., on something starting with C:/ or whatever.
Expand Down
6 changes: 3 additions & 3 deletions src/asar/libstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ string& string::qnormalize()
string out;
char *startstr = thisstring.raw();
char *str = startstr;
while(str = strpbrk(str, "'\" \t,\r"))
while((str = strpbrk(str, "'\" \t,\r")))
{
if(is_space(*str))
{
Expand Down Expand Up @@ -255,7 +255,7 @@ bool confirmqpar(const char * str)
{
//todo fully optimize
int par = 0;
while((unsigned char)*str >= 128 || !qparlut[*str]) str++;
while((unsigned char)*str >= 128 || !qparlut[(unsigned char)*str]) str++;
while(*str)
{
if(*str == '"')
Expand All @@ -275,7 +275,7 @@ bool confirmqpar(const char * str)
par += 1 - ((*str++ - '(') << 1);
if(par < 0) return false;
}
while((unsigned char)*str >= 128 || !qparlut[*str]) str++;
while((unsigned char)*str >= 128 || !qparlut[(unsigned char)*str]) str++;
}
return !par;
}
Expand Down
2 changes: 1 addition & 1 deletion src/asar/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static int getlenforlabel(snes_label thislabel, bool exists)
if (thislabel.freespace_id != freespaceid) return 3;
else return 2;
}
else if (bank != snespos >> 16){ return 3; }
else if ((int)bank != snespos >> 16){ return 3; }
else { return 2;}
}

Expand Down
2 changes: 1 addition & 1 deletion src/asar/platform/windows/thread-helpers-win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool run_as_thread(functor&& callback) {
char* stack_bottom = nullptr;
void init_stack_use_check() {
MEMORY_BASIC_INFORMATION mbi;
char stackvar;
char stackvar = 0;
VirtualQuery(&stackvar, &mbi, sizeof(mbi));
stack_bottom = (char*)mbi.AllocationBase;
}
Expand Down

0 comments on commit 13393a9

Please sign in to comment.