only use -Wno-unused-result on Linux, also actually fix the unused results that we could possibly care about

Fixes cross compilers, TODO: I don't think scons can check if a flag exists but might support adding a test for that, even if through hacky means, like CheckFramework
This commit is contained in:
jacob1 2016-04-26 23:55:14 -04:00
parent 6624550dc1
commit a8427ef33a
4 changed files with 19 additions and 41 deletions

View File

@ -388,7 +388,9 @@ if not msvc:
env.Append(CXXFLAGS=['-std=gnu++98'])
else:
env.Append(CXXFLAGS=['-std=c++98'])
env.Append(CXXFLAGS=['-Wno-invalid-offsetof', '-Wno-unused-result'])
env.Append(CXXFLAGS=['-Wno-invalid-offsetof'])
if platform == "Linux":
env.Append(CXXFLAGS=['-Wno-unused-result'])
#Add platform specific flags and defines

View File

@ -75,32 +75,6 @@ void strlist_free(struct strlist **list)
}
}
void save_string(FILE *f, char *str)
{
int li = strlen(str);
unsigned char lb[2];
lb[0] = li;
lb[1] = li >> 8;
fwrite(lb, 2, 1, f);
fwrite(str, li, 1, f);
}
int load_string(FILE *f, char *str, int max)
{
int li;
unsigned char lb[2];
fread(lb, 2, 1, f);
li = lb[0] | (lb[1] << 8);
if (li > max)
{
str[0] = 0;
return 1;
}
fread(str, li, 1, f);
str[li] = 0;
return 0;
}
const static char hex[] = "0123456789ABCDEF";
void strcaturl(char *dst, char *src)
{
@ -155,8 +129,13 @@ void *file_load(char *fn, int *size)
fclose(f);
return NULL;
}
fread(s, *size, 1, f);
int readsize = fread(s, *size, 1, f);
fclose(f);
if (readsize != *size)
{
free(s);
return NULL;
}
return s;
}

View File

@ -54,10 +54,6 @@ void save_presets(int do_update);
void load_presets(void);
void save_string(FILE *f, char *str);
int load_string(FILE *f, char *str, int max);
void strcaturl(char *dst, const char *src);
void strappend(char *dst, const char *src);

View File

@ -348,6 +348,7 @@ bool Client::DoInstallation()
#elif defined(LIN)
#include "icondoc.h"
int success == 1;
std::string filename = Platform::ExecutableName(), pathname = filename.substr(0, filename.rfind('/'));
for (size_t i = 0; i < filename.size(); i++)
{
@ -391,7 +392,7 @@ bool Client::DoInstallation()
return 0;
fwrite(protocolfiledata.str().c_str(), 1, strlen(protocolfiledata.str().c_str()), f);
fclose(f);
system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop");
success = system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop");
const char *desktopfiledata_tmp =
"[Desktop Entry]\n"
@ -408,8 +409,8 @@ bool Client::DoInstallation()
return 0;
fwrite(desktopfiledata.str().c_str(), 1, strlen(desktopfiledata.str().c_str()), f);
fclose(f);
system("xdg-mime install powdertoy-save.xml");
system("xdg-desktop-menu install powdertoy-tpt.desktop");
success = system("xdg-mime install powdertoy-save.xml") && success;
success = system("xdg-desktop-menu install powdertoy-tpt.desktop") && success;
f = fopen("powdertoy-save-32.png", "wb");
if (!f)
return 0;
@ -420,17 +421,17 @@ bool Client::DoInstallation()
return 0;
fwrite(icon_doc_16_png, 1, sizeof(icon_doc_16_png), f);
fclose(f);
system("xdg-icon-resource install --noupdate --context mimetypes --size 32 powdertoy-save-32.png application-vnd.powdertoy.save");
system("xdg-icon-resource install --noupdate --context mimetypes --size 16 powdertoy-save-16.png application-vnd.powdertoy.save");
system("xdg-icon-resource forceupdate");
system("xdg-mime default powdertoy-tpt.desktop application/vnd.powdertoy.save");
system("xdg-mime default powdertoy-tpt-ptsave.desktop x-scheme-handler/ptsave");
success = system("xdg-icon-resource install --noupdate --context mimetypes --size 32 powdertoy-save-32.png application-vnd.powdertoy.save") && success;
success = system("xdg-icon-resource install --noupdate --context mimetypes --size 16 powdertoy-save-16.png application-vnd.powdertoy.save") && success;
success = system("xdg-icon-resource forceupdate") && success;
success = system("xdg-mime default powdertoy-tpt.desktop application/vnd.powdertoy.save") && success;
success = system("xdg-mime default powdertoy-tpt-ptsave.desktop x-scheme-handler/ptsave") && success;
unlink("powdertoy-save-32.png");
unlink("powdertoy-save-16.png");
unlink("powdertoy-save.xml");
unlink("powdertoy-tpt.desktop");
unlink("powdertoy-tpt-ptsave.desktop");
return true;
return !success;
#elif defined MACOSX
return false;
#endif