[ekiga] Modified the DXWindow::ErrorMessage implementation to make cppcheck happy
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Modified the DXWindow::ErrorMessage implementation to make cppcheck happy
- Date: Sun, 2 Jan 2011 19:57:55 +0000 (UTC)
commit a4bc431a26b444992d47c112da2d116806861f46
Author: Snark <jpuydt gnome org>
Date: Sun Jan 2 20:58:59 2011 +0100
Modified the DXWindow::ErrorMessage implementation to make cppcheck happy
Notice that this functions looks pretty insane, since it's returning a
pointer to a static variable... which means anything relying on it may see
the content change under its feet!
lib/gui/dxwindow.cpp | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/lib/gui/dxwindow.cpp b/lib/gui/dxwindow.cpp
index a27375d..ad3d3dd 100644
--- a/lib/gui/dxwindow.cpp
+++ b/lib/gui/dxwindow.cpp
@@ -1021,26 +1021,30 @@ DXWindow::NewWindow (int x, int y, int windowWidth, int windowHeight)
const char*
DXWindow::ErrorMessage()
{
- static char string [1024];
+ static char buffer[1024];
+ static char result[1024];
DWORD dwMsgLen;
- memset (string, 0, sizeof (string));
+ memset (buffer, 0, sizeof (buffer));
+ memset (result, 0, sizeof (result));
dwMsgLen = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR) string,
- sizeof (string)-1,
+ (LPSTR) buffer,
+ sizeof (buffer)-1,
NULL);
if (dwMsgLen) {
- string [ strlen(string) - 2 ] = 0;
- snprintf (string, sizeof (string), "%s (%u)", string, (int) GetLastError ());
+ buffer [ strlen(buffer) - 2 ] = 0;
+ g_snprintf (result, sizeof (result), "%s (%u)",
+ buffer, (int) GetLastError ());
}
else {
- snprintf (string, sizeof (string), "%u", (int) GetLastError ());
+ g_snprintf (result, sizeof (result), "%u",
+ (int) GetLastError ());
}
- return string;
+ return result;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]