Seems like one really _needs_ to use CVS snapshot now... is
something preventing release of version 5.6?
Bert Wesarg
bert.wesarg at googlemail.com
Thu Jan 22 09:28:43 CET 2009
On Wed, Jan 21, 2009 at 13:59, Thomas Orgis <thomas-forum at orgis.org> wrote:
> PS: Probably I should try to prepare a patch for those when I got some time:
>
> macro.c: In function 'dialogMS':
> macro.c:2927: warning: cast to pointer from integer of different size
> macro.c: In function 'dialogBtnCB':
> macro.c:2968: warning: cast from pointer to integer of different size
> macro.c: In function 'stringDialogMS':
> macro.c:3104: warning: cast to pointer from integer of different size
> macro.c: In function 'stringDialogBtnCB':
> macro.c:3158: warning: cast from pointer to integer of different size
> macro.c: In function 'listDialogMS':
> macro.c:3683: warning: cast to pointer from integer of different size
I have done this before, and I have done it again now and checked all
these warnings, and its always the case that we assign a small integer
to a pointer and later cast the pointer back to an integer. Therefore
false-positives. And these integers are 'small', or will you have
sometime in the far future more that 2^32 menu entries or programming
languages? As far as I can see, the greatest number ever cast to a
pointer and back is (MAXPATHLEN + 1) (thats the size for the shell
name buffer in preferences.c).
The warnings in Xlt/SlideC.c, are only a problem, if on some
architectures NULL is something >=2^32, the same for
source/regularExp.c.
We have found some 64bit problems in the past and I use nedit for 5
years on a x86-64. So you can count on me that I'm behind this.
Regards,
Bert
PS: I've attached a patch to silent all warnings, execpt these for
Xlt/SlideC.c and source/regularExp.c.
-------------- next part --------------
---
source/file.c | 10 ++++++----
source/macro.c | 18 +++++++++---------
source/preferences.c | 16 +++++++++-------
source/userCmds.c | 8 ++++----
util/prefFile.c | 4 ++--
5 files changed, 30 insertions(+), 26 deletions(-)
diff --quilt old/source/file.c new/source/file.c
--- old/source/file.c
+++ new/source/file.c
@@ -1516,7 +1516,7 @@ int PromptForNewFile(WindowInfo *window,
xmToggleButtonWidgetClass, formatBtns,
XmNlabelString, s1 = XmStringCreateSimple("Unix"),
XmNset, *fileFormat == UNIX_FILE_FORMAT,
- XmNuserData, (XtPointer)UNIX_FILE_FORMAT,
+ XmNuserData, (XtPointer)(long)UNIX_FILE_FORMAT,
XmNmarginHeight, 0,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNmnemonic, 'U',
@@ -1528,7 +1528,7 @@ int PromptForNewFile(WindowInfo *window,
xmToggleButtonWidgetClass, formatBtns,
XmNlabelString, s1 = XmStringCreateSimple("DOS"),
XmNset, *fileFormat == DOS_FILE_FORMAT,
- XmNuserData, (XtPointer)DOS_FILE_FORMAT,
+ XmNuserData, (XtPointer)(long)DOS_FILE_FORMAT,
XmNmarginHeight, 0,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNmnemonic, 'O',
@@ -1540,7 +1540,7 @@ int PromptForNewFile(WindowInfo *window,
xmToggleButtonWidgetClass, formatBtns,
XmNlabelString, s1 = XmStringCreateSimple("Macintosh"),
XmNset, *fileFormat == MAC_FILE_FORMAT,
- XmNuserData, (XtPointer)MAC_FILE_FORMAT,
+ XmNuserData, (XtPointer)(long)MAC_FILE_FORMAT,
XmNmarginHeight, 0,
XmNalignment, XmALIGNMENT_BEGINNING,
XmNmnemonic, 'M',
@@ -1913,8 +1913,10 @@ static void setFormatCB(Widget w, XtPoin
{
if (XmToggleButtonGetState(w)) {
XtPointer userData;
+ int fileFormat;
XtVaGetValues(w, XmNuserData, &userData, NULL);
- *(int*) clientData = (int) userData;
+ fileFormat = (int)(long)userData;
+ *(int*)clientData = fileFormat;
}
}
diff --quilt old/source/macro.c new/source/macro.c
--- old/source/macro.c
+++ new/source/macro.c
@@ -2907,7 +2907,7 @@ static int dialogMS(WindowInfo *window,
AddMotifCloseCallback(XtParent(dialog), dialogCloseCB, window);
XtAddCallback(dialog, XmNokCallback, dialogBtnCB, window);
XtVaSetValues(XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON),
- XmNuserData, (XtPointer)1, NULL);
+ XmNuserData, (XtPointer)(long)1, NULL);
cmdData->dialog = dialog;
/* Unmanage default buttons, except for "OK" */
@@ -2924,7 +2924,7 @@ static int dialogMS(WindowInfo *window,
readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
XmNlabelString, s1=XmStringCreateSimple(btnLabel),
- XmNuserData, (XtPointer)(i+1), NULL);
+ XmNuserData, (XtPointer)(long)(i+1), NULL);
XtAddCallback(btn, XmNactivateCallback, dialogBtnCB, window);
XmStringFree(s1);
}
@@ -2965,7 +2965,7 @@ static void dialogBtnCB(Widget w, XtPoin
return; /* shouldn't happen */
if (XtClass(w) == xmPushButtonWidgetClass) {
XtVaGetValues(w, XmNuserData, &userData, NULL);
- retVal.val.n = (int)userData;
+ retVal.val.n = (int)(long)userData;
} else
retVal.val.n = 1;
retVal.tag = INT_TAG;
@@ -3081,7 +3081,7 @@ static int stringDialogMS(WindowInfo *wi
AddMotifCloseCallback(XtParent(dialog), stringDialogCloseCB, window);
XtAddCallback(dialog, XmNokCallback, stringDialogBtnCB, window);
XtVaSetValues(XmSelectionBoxGetChild(dialog, XmDIALOG_OK_BUTTON),
- XmNuserData, (XtPointer)1, NULL);
+ XmNuserData, (XtPointer)(long)1, NULL);
cmdData->dialog = dialog;
/* Unmanage unneded widgets */
@@ -3101,7 +3101,7 @@ static int stringDialogMS(WindowInfo *wi
readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
XmNlabelString, s1=XmStringCreateSimple(btnLabel),
- XmNuserData, (XtPointer)(i+1), NULL);
+ XmNuserData, (XtPointer)(long)(i+1), NULL);
XtAddCallback(btn, XmNactivateCallback, stringDialogBtnCB, window);
XmStringFree(s1);
}
@@ -3155,7 +3155,7 @@ static void stringDialogBtnCB(Widget w,
returned in w. */
if (XtClass(w) == xmPushButtonWidgetClass) {
XtVaGetValues(w, XmNuserData, &userData, NULL);
- btnNum = (int)userData;
+ btnNum = (int)(long)userData;
} else
btnNum = 1;
@@ -3645,7 +3645,7 @@ static int listDialogMS(WindowInfo *wind
AddMotifCloseCallback(XtParent(dialog), listDialogCloseCB, window);
XtAddCallback(dialog, XmNokCallback, listDialogBtnCB, window);
XtVaSetValues(XmSelectionBoxGetChild(dialog, XmDIALOG_OK_BUTTON),
- XmNuserData, (XtPointer)1, NULL);
+ XmNuserData, (XtPointer)(long)1, NULL);
XmStringFree(s1);
XmStringFree(s2);
cmdData->dialog = dialog;
@@ -3680,7 +3680,7 @@ static int listDialogMS(WindowInfo *wind
readStringArg(argList[i], &btnLabel, btnStorage, errMsg);
btn = XtVaCreateManagedWidget("mdBtn", xmPushButtonWidgetClass, dialog,
XmNlabelString, s1=XmStringCreateSimple(btnLabel),
- XmNuserData, (XtPointer)(i+1), NULL);
+ XmNuserData, (XtPointer)(long)(i+1), NULL);
XtAddCallback(btn, XmNactivateCallback, listDialogBtnCB, window);
XmStringFree(s1);
}
@@ -3760,7 +3760,7 @@ static void listDialogBtnCB(Widget w, Xt
returned in w. */
if (XtClass(w) == xmPushButtonWidgetClass) {
XtVaGetValues(w, XmNuserData, &userData, NULL);
- btnNum = (int)userData;
+ btnNum = (int)(long)userData;
} else
btnNum = 1;
diff --quilt old/source/preferences.c new/source/preferences.c
--- old/source/preferences.c
+++ new/source/preferences.c
@@ -2295,7 +2295,7 @@ void SetLanguageMode(WindowInfo *window,
XtVaGetValues(menu, XmNchildren, &items, XmNnumChildren, &nItems, NULL);
for (n=0; n<(int)nItems; n++) {
XtVaGetValues(items[n], XmNuserData, &userData, NULL);
- XmToggleButtonSetState(items[n], (int)userData == mode, False);
+ XmToggleButtonSetState(items[n], (int)(long)userData == mode, False);
}
}
}
@@ -5147,7 +5147,7 @@ static void updateLanguageModeSubmenu(Wi
xmToggleButtonGadgetClass, menu,
XmNlabelString, s1=XmStringCreateSimple(LanguageModes[i]->name),
XmNmarginHeight, 0,
- XmNuserData, (void *)i,
+ XmNuserData, (void *)(long)i,
XmNset, window->languageMode==i, NULL);
XmStringFree(s1);
XtAddCallback(btn, XmNvalueChangedCallback, setLangModeCB, window);
@@ -5159,23 +5159,25 @@ static void setLangModeCB(Widget w, XtPo
{
WindowInfo *window = WidgetToWindow(MENU_WIDGET(w));
char *params[1];
- void *mode;
+ void *userData;
+ int mode;
if (!XmToggleButtonGetState(w))
return;
/* get name of language mode stored in userData field of menu item */
- XtVaGetValues(w, XmNuserData, &mode, NULL);
+ XtVaGetValues(w, XmNuserData, &userData, NULL);
+ mode = (int)(long)userData;
/* If the mode didn't change, do nothing */
- if (window->languageMode == (int)mode)
+ if (window->languageMode == mode)
return;
/* redo syntax highlighting word delimiters, etc. */
/*
- reapplyLanguageMode(window, (int)mode, False);
+ reapplyLanguageMode(window, mode, False);
*/
- params[0] = (((int)mode) == PLAIN_LANGUAGE_MODE) ? "" : LanguageModes[(int)mode]->name;
+ params[0] = (mode == PLAIN_LANGUAGE_MODE) ? "" : LanguageModes[mode]->name;
XtCallActionProc(window->textArea, "set_language_mode", NULL, params, 1);
}
diff --quilt old/source/userCmds.c new/source/userCmds.c
--- old/source/userCmds.c
+++ new/source/userCmds.c
@@ -1111,12 +1111,12 @@ static void dimSelDepItemsInMenu(Widget
XtVaGetValues(menuPane, XmNchildren, &items, XmNnumChildren, &nItems, NULL);
for (n=0; n<(int)nItems; n++) {
XtVaGetValues(items[n], XmNuserData, &userData, NULL);
- if (userData != (XtPointer)PERMANENT_MENU_ITEM) {
+ if (userData != PERMANENT_MENU_ITEM) {
if (XtClass(items[n]) == xmCascadeButtonWidgetClass) {
XtVaGetValues(items[n], XmNsubMenuId, &subMenu, NULL);
dimSelDepItemsInMenu(subMenu, menuList, nMenuItems, sensitive);
} else {
- index = (int)userData - 10;
+ index = (int)(long)userData - 10;
if (index <0 || index >= nMenuItems)
return;
if (menuList[index]->input == FROM_SELECTION)
@@ -1928,7 +1928,7 @@ static Widget createUserMenuItem(Widget
XmNlabelString, st1,
XmNacceleratorText, st2,
XmNmnemonic, f->mnemonic,
- XmNuserData, (XtPointer)(index+10), NULL);
+ XmNuserData, (XtPointer)(long)(index+10), NULL);
XtAddCallback(btn, XmNactivateCallback, cbRtn, cbArg);
XmStringFree(st1);
XmStringFree(st2);
@@ -1979,7 +1979,7 @@ static void deleteMenuItems(Widget menuP
/* delete all of the widgets not marked as PERMANENT_MENU_ITEM */
for (n=0; n<(int)nItems; n++) {
XtVaGetValues(items[n], XmNuserData, &userData, NULL);
- if (userData != (XtPointer)PERMANENT_MENU_ITEM) {
+ if (userData != PERMANENT_MENU_ITEM) {
if (XtClass(items[n]) == xmCascadeButtonWidgetClass) {
XtVaGetValues(items[n], XmNsubMenuId, &subMenuID, NULL);
diff --quilt old/util/prefFile.c new/util/prefFile.c
--- old/util/prefFile.c
+++ new/util/prefFile.c
@@ -353,9 +353,9 @@ static int stringToPref(const char *stri
*(int *)rsrcDescrip->valueAddr = 0;
return False;
case PREF_STRING:
- if ((int)strlen(string) >= (int)rsrcDescrip->arg)
+ if (strlen(string) >= (size_t)rsrcDescrip->arg)
return False;
- strncpy(rsrcDescrip->valueAddr, string, (int)rsrcDescrip->arg);
+ strncpy(rsrcDescrip->valueAddr, string, (size_t)rsrcDescrip->arg);
return True;
case PREF_ALLOC_STRING:
*(char **)rsrcDescrip->valueAddr = XtMalloc(strlen(string) + 1);
More information about the Discuss
mailing list