Skip to content

Commit

Permalink
loadmap: Better error support while loading/saving config
Browse files Browse the repository at this point in the history
  • Loading branch information
mefistotelis committed Jun 19, 2024
1 parent efaa560 commit 6922286
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/LoadMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool write_config_file(
szIniPath[sizeof(szIniPath) - 1] = '\0';

fh = qopen(szIniPath, O_CREAT|O_WRONLY|O_TRUNC);
if (!fh)
if (fh == -1)
return false;

qsnprintf(szLine, sizeof(szLine), ";\n; LoadMap Plugin auto-saved configuration file\n;\n");
Expand Down Expand Up @@ -191,7 +191,10 @@ static plugmod_t *idaapi init()

// Get options saved in cfg file; IDA Pro will find the file, it does
// not need the full path nor extension, only base name.
read_config_file("loadmap", g_optsinfo, qnumber(g_optsinfo), NULL);
if (!read_config_file("loadmap", g_optsinfo, qnumber(g_optsinfo), NULL))
{
msg("LoadMap: Plugin configuration file '%s.cfg' read failed.\n", "loadmap");
}

switch (inf.filetype)
{
Expand Down Expand Up @@ -483,7 +486,10 @@ void idaapi term(void)
msg("LoadMap: Plugin v%s terminate.\n", PLUG_VERSION);

// Write the plugin's options to cfg file
write_config_file("loadmap", g_optsinfo, qnumber(g_optsinfo));
if (!write_config_file("loadmap", g_optsinfo, qnumber(g_optsinfo)))
{
msg("LoadMap: Plugin configuration file '%s.cfg' save failed.\n", "loadmap");
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 6922286

Please sign in to comment.