summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authornijtmans <nijtmans>2009-08-10 23:16:28 (GMT)
committernijtmans <nijtmans>2009-08-10 23:16:28 (GMT)
commitcd1fb1befb4664ffe116712fdef181a76f84ff16 (patch)
tree97e0ef25dc75718395cdf7ff0d3ecf0f5d10f176 /win
parent7aefedb2ea921fbeb0f6d6b99afeb1224a319318 (diff)
downloadtk-cd1fb1befb4664ffe116712fdef181a76f84ff16.zip
tk-cd1fb1befb4664ffe116712fdef181a76f84ff16.tar.gz
tk-cd1fb1befb4664ffe116712fdef181a76f84ff16.tar.bz2
Eliminate more gcc warnings
Diffstat (limited to 'win')
-rw-r--r--win/tkWinPixmap.c6
-rw-r--r--win/tkWinTest.c44
-rw-r--r--win/tkWinWm.c19
3 files changed, 39 insertions, 30 deletions
diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c
index b496f61..3f9c21a 100644
--- a/win/tkWinPixmap.c
+++ b/win/tkWinPixmap.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinPixmap.c,v 1.8 2009/04/30 13:44:19 dkf Exp $
+ * RCS: @(#) $Id: tkWinPixmap.c,v 1.9 2009/08/10 23:16:28 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -76,7 +76,7 @@ Tk_GetPixmap(
if (newTwdPtr->bitmap.handle == NULL) {
static int repeatError = 0;
- unsigned char *bits = NULL;
+ void *bits = NULL;
BITMAPINFO bitmapInfo;
HDC dc;
@@ -90,7 +90,7 @@ Tk_GetPixmap(
bitmapInfo.bmiHeader.biSizeImage = 0;
dc = GetDC(NULL);
newTwdPtr->bitmap.handle = CreateDIBSection(dc, &bitmapInfo,
- DIB_RGB_COLORS, (void **) &bits, 0, 0);
+ DIB_RGB_COLORS, &bits, 0, 0);
ReleaseDC(NULL, dc);
/*
diff --git a/win/tkWinTest.c b/win/tkWinTest.c
index 8cc343f..78b06f3 100644
--- a/win/tkWinTest.c
+++ b/win/tkWinTest.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinTest.c,v 1.25 2009/05/13 22:03:39 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinTest.c,v 1.26 2009/08/10 23:16:28 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -100,16 +100,19 @@ AppendSystemError(
DWORD error) /* Result code from error. */
{
int length;
- WCHAR *wMsgPtr;
- char *msg;
+ WCHAR *wMsgPtr, **wMsgPtrPtr = &wMsgPtr;
+ const char *msg;
char id[TCL_INTEGER_SPACE], msgBuf[24 + TCL_INTEGER_SPACE];
Tcl_DString ds;
Tcl_Obj *resultPtr = Tcl_GetObjResult(interp);
+ if (Tcl_IsShared(resultPtr)) {
+ resultPtr = Tcl_DuplicateObj(resultPtr);
+ }
length = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) &wMsgPtr,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *) wMsgPtrPtr,
0, NULL);
if (length == 0) {
char *msgPtr;
@@ -128,36 +131,41 @@ AppendSystemError(
}
if (length == 0) {
if (error == ERROR_CALL_NOT_IMPLEMENTED) {
- msg = (char *)"function not supported under Win32s";
+ strcpy(msgBuf, "function not supported under Win32s");
} else {
sprintf(msgBuf, "unknown error: %ld", error);
- msg = msgBuf;
}
+ msg = msgBuf;
} else {
Tcl_Encoding encoding;
+ char *msgPtr;
encoding = Tcl_GetEncoding(NULL, "unicode");
- msg = Tcl_ExternalToUtfDString(encoding, (char *) wMsgPtr, -1, &ds);
+ Tcl_ExternalToUtfDString(encoding, (char *) wMsgPtr, -1, &ds);
Tcl_FreeEncoding(encoding);
LocalFree(wMsgPtr);
+ msgPtr = Tcl_DStringValue(&ds);
length = Tcl_DStringLength(&ds);
/*
* Trim the trailing CR/LF from the system message.
*/
- if (msg[length-1] == '\n') {
- msg[--length] = 0;
+ if (msgPtr[length-1] == '\n') {
+ --length;
}
- if (msg[length-1] == '\r') {
- msg[--length] = 0;
+ if (msgPtr[length-1] == '\r') {
+ --length;
}
+ msgPtr[length] = 0;
+ msg = msgPtr;
}
sprintf(id, "%ld", error);
Tcl_SetErrorCode(interp, "WINDOWS", id, msg, NULL);
Tcl_AppendToObj(resultPtr, msg, length);
+ Tcl_SetObjResult(interp, resultPtr);
if (length != 0) {
Tcl_DStringFree(&ds);
@@ -427,7 +435,7 @@ TestgetwindowinfoObjCmd(
int objc,
Tcl_Obj *const objv[])
{
- HWND hwnd = NULL;
+ long hwnd;
Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL;
Tcl_Obj *childrenObj = NULL;
char buf[512];
@@ -438,10 +446,10 @@ TestgetwindowinfoObjCmd(
return TCL_ERROR;
}
- if (Tcl_GetLongFromObj(interp, objv[1], (long *)&hwnd) != TCL_OK)
+ if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK)
return TCL_ERROR;
- cch = tkWinProcs->getClassName(hwnd, buf, cchBuf);
+ cch = tkWinProcs->getClassName((HWND)hwnd, buf, cchBuf);
if (cch == 0) {
Tcl_SetResult(interp, "failed to get class name: ", TCL_STATIC);
AppendSystemError(interp, GetLastError());
@@ -456,9 +464,9 @@ TestgetwindowinfoObjCmd(
dictObj = Tcl_NewDictObj();
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2),
- Tcl_NewLongObj(GetWindowLong(hwnd, GWL_ID)));
+ Tcl_NewLongObj(GetWindowLong((HWND)hwnd, GWL_ID)));
- cch = tkWinProcs->getWindowText(hwnd, (LPTSTR)buf, cchBuf);
+ cch = tkWinProcs->getWindowText((HWND)hwnd, (LPTSTR)buf, cchBuf);
if (tkWinProcs->useWide) {
textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch);
} else {
@@ -467,10 +475,10 @@ TestgetwindowinfoObjCmd(
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6),
- Tcl_NewLongObj((long)GetParent(hwnd)));
+ Tcl_NewLongObj((long)GetParent((HWND)hwnd)));
childrenObj = Tcl_NewListObj(0, NULL);
- EnumChildWindows(hwnd, EnumChildrenProc, (LPARAM)childrenObj);
+ EnumChildWindows((HWND)hwnd, EnumChildrenProc, (LPARAM)childrenObj);
Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj);
Tcl_SetObjResult(interp, dictObj);
diff --git a/win/tkWinWm.c b/win/tkWinWm.c
index 85523a7..9e969c7 100644
--- a/win/tkWinWm.c
+++ b/win/tkWinWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinWm.c,v 1.140 2009/08/02 21:40:17 nijtmans Exp $
+ * RCS: @(#) $Id: tkWinWm.c,v 1.141 2009/08/10 23:16:28 nijtmans Exp $
*/
#include "tkWinInt.h"
@@ -4310,7 +4310,8 @@ WmIconphotoCmd(
Tk_PhotoHandle photo;
Tk_PhotoImageBlock block;
int i, width, height, idx, bufferSize, startObj = 3;
- unsigned char *bgraPixelPtr, *bgraMaskPtr;
+ union {unsigned char *ptr; void *voidPtr;} bgraPixel;
+ union {unsigned char *ptr; void *voidPtr;} bgraMask;
BlockOfIconImagesPtr lpIR;
WinIconPtr titlebaricon = NULL;
HICON hIcon;
@@ -4388,7 +4389,7 @@ WmIconphotoCmd(
bmInfo.bmiHeader.biCompression = BI_RGB;
iconInfo.hbmColor = CreateDIBSection( NULL, &bmInfo,
- DIB_RGB_COLORS, (void **)&bgraPixelPtr, NULL, 0 );
+ DIB_RGB_COLORS, &bgraPixel.voidPtr, NULL, 0 );
if ( !iconInfo.hbmColor ) {
ckfree((char *) lpIR);
Tcl_AppendResult(interp, "failed to create color bitmap for \"",
@@ -4401,10 +4402,10 @@ WmIconphotoCmd(
*/
bufferSize = height * width * 4;
for (idx = 0 ; idx < bufferSize ; idx += 4) {
- bgraPixelPtr[idx] = block.pixelPtr[idx+2];
- bgraPixelPtr[idx+1] = block.pixelPtr[idx+1];
- bgraPixelPtr[idx+2] = block.pixelPtr[idx+0];
- bgraPixelPtr[idx+3] = block.pixelPtr[idx+3];
+ bgraPixel.ptr[idx] = block.pixelPtr[idx+2];
+ bgraPixel.ptr[idx+1] = block.pixelPtr[idx+1];
+ bgraPixel.ptr[idx+2] = block.pixelPtr[idx+0];
+ bgraPixel.ptr[idx+3] = block.pixelPtr[idx+3];
}
/*
@@ -4415,7 +4416,7 @@ WmIconphotoCmd(
bmInfo.bmiHeader.biBitCount = 1;
iconInfo.hbmMask = CreateDIBSection( NULL, &bmInfo,
- DIB_RGB_COLORS, (void **)&bgraMaskPtr, NULL, 0 );
+ DIB_RGB_COLORS, &bgraMask.voidPtr, NULL, 0 );
if ( !iconInfo.hbmMask ) {
DeleteObject(iconInfo.hbmColor);
ckfree((char *) lpIR);
@@ -4424,7 +4425,7 @@ WmIconphotoCmd(
return TCL_ERROR;
}
- ZeroMemory( bgraMaskPtr, width*height/8 );
+ ZeroMemory( bgraMask.ptr, width*height/8 );
/*
* Create an icon from the bitmaps.