Skip to content

Commit 9f54148

Browse files
committed
Fix some warnings with GCC -Wall
1 parent 2e290f4 commit 9f54148

7 files changed

Lines changed: 11 additions & 17 deletions

File tree

library/Core.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,6 @@ static void listScripts(PluginManager *plug_mgr, std::map<string,string> &pset,
300300
}
301301
}
302302

303-
static bool fileExists(std::string path)
304-
{
305-
ifstream script(path.c_str());
306-
return script.good();
307-
}
308-
309303
namespace {
310304
struct ScriptArgs {
311305
const string *pcmd;
@@ -1612,16 +1606,19 @@ bool Core::Init()
16121606
cerr << "Starting IO thread.\n";
16131607
// create IO thread
16141608
thread * IO = new thread(fIOthread, (void *) temp);
1609+
(void)IO;
16151610
}
16161611
else
16171612
{
16181613
cerr << "Starting dfhack.init thread.\n";
16191614
thread * init = new thread(fInitthread, (void *) temp);
1615+
(void)init;
16201616
}
16211617

16221618
cerr << "Starting DF input capture thread.\n";
16231619
// set up hotkey capture
16241620
thread * HK = new thread(fHKthread, (void *) temp);
1621+
(void)HK;
16251622
screen_window = new Windows::top_level_window();
16261623
screen_window->addChild(new Windows::dfhack_dummy(5,10));
16271624
started = true;
@@ -1819,6 +1816,7 @@ void Core::Resume()
18191816
lock_guard<mutex> lock(d->AccessMutex);
18201817

18211818
assert(d->df_suspend_depth > 0 && d->df_suspend_thread == tid);
1819+
(void)tid;
18221820

18231821
if (--d->df_suspend_depth == 0)
18241822
d->core_cond.Unlock();
@@ -1858,6 +1856,7 @@ void Core::DisclaimSuspend(int level)
18581856
lock_guard<mutex> lock(d->AccessMutex);
18591857

18601858
assert(d->df_suspend_depth == level && d->df_suspend_thread == tid);
1859+
(void)tid;
18611860

18621861
if (level == 1000000)
18631862
d->df_suspend_depth = 0;

library/DataDefs.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ virtual_identity *virtual_identity::find(void *vtable)
271271
Core &core = Core::getInstance();
272272
std::string name = core.p->doReadClassName(vtable);
273273

274-
virtual_identity *actual = NULL;
275-
276274
auto name_it = name_lookup.find(name);
277275
if (name_it != name_lookup.end()) {
278276
virtual_identity *p = name_it->second;

library/LuaApi.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ static int filesystem_listdir(lua_State *L)
22432243
return 3;
22442244
}
22452245
lua_newtable(L);
2246-
for(int i=0;i<files.size();i++)
2246+
for(size_t i=0;i<files.size();i++)
22472247
{
22482248
lua_pushinteger(L,i+1);
22492249
lua_pushstring(L,files[i].c_str());
@@ -2492,7 +2492,7 @@ static int internal_patchBytes(lua_State *L)
24922492
{
24932493
uint8_t *addr = (uint8_t*)checkaddr(L, -2, true);
24942494
int isnum;
2495-
uint8_t value = (uint8_t)lua_tounsignedx(L, -1, &isnum);
2495+
lua_tounsignedx(L, -1, &isnum);
24962496
if (!isnum)
24972497
luaL_error(L, "invalid value in write table");
24982498
lua_pop(L, 1);

library/LuaTools.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ bool DFHack::Lua::SafeCallString(color_ostream &out, lua_State *state, const std
953953
env_idx = lua_absindex(state, env_idx);
954954

955955
int base = lua_gettop(state);
956+
(void)base; // used in assert()
956957

957958
// Parse the code
958959
if (luaL_loadbuffer(state, code.data(), code.size(), debug_tag) != LUA_OK)

library/LuaTypes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ static int method_container_insert(lua_State *state)
911911
static int meta_bitfield_len(lua_State *state)
912912
{
913913
uint8_t *ptr = get_object_addr(state, 1, 0, "get size");
914+
(void)ptr;
914915
auto id = (bitfield_identity*)lua_touserdata(state, UPVAL_CONTAINER_ID);
915916
lua_pushinteger(state, id->getNumBits());
916917
return 1;

library/LuaWrapper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ distribution.
4646
using namespace DFHack;
4747
using namespace DFHack::LuaWrapper;
4848

49-
static luaL_Reg no_functions[] = { { NULL, NULL } };
50-
5149
/**
5250
* Report an error while accessing a field (index = field name).
5351
*/
@@ -1594,8 +1592,6 @@ static void RenderTypeChildren(lua_State *state, const std::vector<compound_iden
15941592

15951593
static int DoAttach(lua_State *state)
15961594
{
1597-
int base = lua_gettop(state);
1598-
15991595
lua_newtable(state);
16001596
lua_rawsetp(state, LUA_REGISTRYINDEX, &DFHACK_PTR_IDTABLE_TOKEN);
16011597

library/PluginManager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ struct Plugin::LuaEvent : public Lua::Event::Owner {
184184

185185
Plugin::Plugin(Core * core, const std::string & path,
186186
const std::string &name, PluginManager * pm)
187-
:name(name),
188-
path(path),
187+
:path(path),
188+
name(name),
189189
parent(pm)
190190
{
191191
plugin_lib = 0;
@@ -492,7 +492,6 @@ command_result Plugin::invoke(color_ostream &out, const std::string & command, s
492492

493493
bool Plugin::can_invoke_hotkey(const std::string & command, df::viewscreen *top )
494494
{
495-
Core & c = Core::getInstance();
496495
bool cr = false;
497496
access->lock_add();
498497
if(state == PS_LOADED)

0 commit comments

Comments
 (0)