fix most write-strings warning.

This commit is contained in:
aliaspider 2018-03-23 04:21:46 +01:00
parent 198c946218
commit 3fbb340450
6 changed files with 18 additions and 22 deletions

View File

@ -275,10 +275,6 @@ if(NOT MSVC)
elseif(ANDROID)
add_definitions(-fsigned-char)
endif()
if(WIN32)
add_definitions(-Wno-write-strings)
endif()
else()
# Disable warnings about MS-specific _s variants of libc functions
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

View File

@ -56,7 +56,7 @@ namespace W32Util
void NiceSizeFormat(size_t size, char *out)
{
char *sizes[] = {"B","KB","MB","GB","TB","PB","EB"};
const char *sizes[] = {"B","KB","MB","GB","TB","PB","EB"};
int s = 0;
int frac = 0;
while (size>=1024)
@ -172,7 +172,7 @@ GenericListControl::GenericListControl(HWND hwnd, const GenericListViewDef& def)
int totalListSize = rect.right-rect.left;
for (int i = 0; i < columnCount; i++) {
lvc.cx = columns[i].size * totalListSize;
lvc.pszText = columns[i].name;
lvc.pszText = (LPTSTR)columns[i].name;
if (columns[i].flags & GLVC_CENTERED)
lvc.fmt = LVCFMT_CENTER;
@ -385,4 +385,4 @@ void GenericListControl::SelectAll()
int GenericListControl::GetSelectedIndex()
{
return ListView_GetNextItem(handle, -1, LVNI_SELECTED);
}
}

View File

@ -16,7 +16,7 @@ namespace W32Util
struct GenericListViewColumn
{
wchar_t *name;
const wchar_t *name;
float size;
int flags;
};

View File

@ -15,7 +15,7 @@ TabControl::TabControl(HWND handle, bool noDisplayArea)
hasButtons = (GetWindowLong(handle,GWL_STYLE) & TCS_BUTTONS) != 0;
}
HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
HWND TabControl::AddTabWindow(const wchar_t* className, const wchar_t *title, DWORD style)
{
TabInfo info;
info.hasBorder = (style & WS_BORDER) != 0;
@ -50,13 +50,13 @@ HWND TabControl::AddTabWindow(wchar_t* className, wchar_t* title, DWORD style)
return tabHandle;
}
void TabControl::AddTabDialog(Dialog* dialog, wchar_t* title)
void TabControl::AddTabDialog(Dialog* dialog, const wchar_t* title)
{
HWND handle = dialog->GetDlgHandle();
AddTab(handle,title);
}
void TabControl::AddTab(HWND handle, wchar_t* title)
void TabControl::AddTab(HWND handle, const wchar_t* title)
{
if (showTabTitles)
AppendPageToControl(title);
@ -93,13 +93,13 @@ void TabControl::AddTab(HWND handle, wchar_t* title)
ShowTab(index);
}
int TabControl::AppendPageToControl(wchar_t* title)
int TabControl::AppendPageToControl(const wchar_t *title)
{
TCITEM tcItem;
ZeroMemory (&tcItem,sizeof (tcItem));
tcItem.mask = TCIF_TEXT;
tcItem.dwState = 0;
tcItem.pszText = title;
tcItem.pszText = (LPTSTR)title;
tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1;
tcItem.iImage = 0;
@ -304,4 +304,4 @@ LRESULT CALLBACK TabControl::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
return (LRESULT)CallWindowProc((WNDPROC)tabControl->oldProc,hwnd,msg,wParam,lParam);
}
}

View File

@ -11,9 +11,9 @@ class TabControl
public:
TabControl(HWND handle, bool noDisplayArea = false);
void HandleNotify(LPARAM lParam);
HWND AddTabWindow(wchar_t* className, wchar_t* title, DWORD style = 0);
void AddTabDialog(Dialog* dialog, wchar_t* title);
void AddTab(HWND hwnd, wchar_t* title);
HWND AddTabWindow(const wchar_t* className, const wchar_t* title, DWORD style = 0);
void AddTabDialog(Dialog* dialog, const wchar_t* title);
void AddTab(HWND hwnd, const wchar_t* title);
void ShowTab(int index, bool setControlIndex = true);
void ShowTab(HWND pageHandle);
void NextTab(bool cycle);
@ -33,7 +33,7 @@ public:
private:
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void OnResize();
int AppendPageToControl(wchar_t* title);
int AppendPageToControl(const wchar_t* title);
struct TabInfo
{
@ -52,4 +52,4 @@ private:
int currentTab;
bool hasButtons;
bool noDisplayArea_;
};
};

View File

@ -247,7 +247,7 @@ void WindowsHost::BootDone() {
Core_EnableStepping(!g_Config.bAutoRun);
}
static std::string SymbolMapFilename(const char *currentFilename, char* ext) {
static std::string SymbolMapFilename(const char *currentFilename, const char* ext) {
FileInfo info;
std::string result = currentFilename;
@ -256,9 +256,9 @@ static std::string SymbolMapFilename(const char *currentFilename, char* ext) {
getFileInfo(currentFilename, &info);
if (info.isDirectory) {
#ifdef _WIN32
char* slash = "\\";
const char* slash = "\\";
#else
char* slash = "/";
const char* slash = "/";
#endif
if (!endsWith(result,slash))
result += slash;