summaryrefslogtreecommitdiff
path: root/src/TMstate.c
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2019-03-17 17:19:45 -0400
committerAlan Coopersmith <alan.coopersmith@oracle.com>2019-04-06 10:31:25 -0700
commitcf9e8c73c4ffa671d580938c9a84d6ef0bd2710d (patch)
tree21cd4cab8b92df9f9050ea8df40d9cc35bed451d /src/TMstate.c
parentfb7e899e94dd402c868e8eb59ccf32284732f6ac (diff)
This cleans up the "easy" warning fixes which can be made using my
Regress script, comparing object-files before/after the edits: https://invisible-island.net/ansification/index.html https://invisible-island.net/scripts/readme.html The changes are casts, which quiet the gcc warnings about implicit conversion that my "gcc-normal" script would show. I avoided reformatting the code. The change reduces the number of gcc warnings from 769 to 163. Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src/TMstate.c')
-rw-r--r--src/TMstate.c106
1 files changed, 53 insertions, 53 deletions
diff --git a/src/TMstate.c b/src/TMstate.c
index fda9a23..443eb09 100644
--- a/src/TMstate.c
+++ b/src/TMstate.c
@@ -130,11 +130,11 @@ static TMShortCard GetBranchHead(
if (parseTree->numBranchHeads == parseTree->branchHeadTblSize)
{
if (parseTree->branchHeadTblSize == 0)
- parseTree->branchHeadTblSize += TM_BRANCH_HEAD_TBL_ALLOC;
+ parseTree->branchHeadTblSize = (TMShortCard) (parseTree->branchHeadTblSize + TM_BRANCH_HEAD_TBL_ALLOC);
else
- parseTree->branchHeadTblSize +=
- TM_BRANCH_HEAD_TBL_REALLOC;
- newSize = (parseTree->branchHeadTblSize * sizeof(TMBranchHeadRec));
+ parseTree->branchHeadTblSize = (TMShortCard) (parseTree->branchHeadTblSize +
+ TM_BRANCH_HEAD_TBL_REALLOC);
+ newSize = (TMShortCard) (parseTree->branchHeadTblSize * sizeof(TMBranchHeadRec));
if (parseTree->isStackBranchHeads) {
TMBranchHead oldBranchHeadTbl = parseTree->branchHeadTbl;
parseTree->branchHeadTbl = (TMBranchHead) __XtMalloc(newSize);
@@ -144,7 +144,7 @@ static TMShortCard GetBranchHead(
else {
parseTree->branchHeadTbl = (TMBranchHead)
XtRealloc((char *)parseTree->branchHeadTbl,
- (parseTree->branchHeadTblSize *
+ (Cardinal)(parseTree->branchHeadTblSize *
sizeof(TMBranchHeadRec)));
}
}
@@ -161,7 +161,7 @@ static TMShortCard GetBranchHead(
branchHead->isSimple = True;
branchHead->hasActions = False;
branchHead->hasCycles = False;
- return parseTree->numBranchHeads-1;
+ return (TMShortCard) (parseTree->numBranchHeads - 1);
}
TMShortCard _XtGetQuarkIndex(
@@ -183,10 +183,10 @@ TMShortCard _XtGetQuarkIndex(
TMShortCard newSize;
if (parseTree->quarkTblSize == 0)
- parseTree->quarkTblSize += TM_QUARK_TBL_ALLOC;
+ parseTree->quarkTblSize = (TMShortCard) (parseTree->quarkTblSize + TM_QUARK_TBL_ALLOC);
else
- parseTree->quarkTblSize += TM_QUARK_TBL_REALLOC;
- newSize = (parseTree->quarkTblSize * sizeof(XrmQuark));
+ parseTree->quarkTblSize = (TMShortCard) (parseTree->quarkTblSize + TM_QUARK_TBL_REALLOC);
+ newSize = (TMShortCard) (parseTree->quarkTblSize * sizeof(XrmQuark));
if (parseTree->isStackQuarks) {
XrmQuark *oldquarkTbl = parseTree->quarkTbl;
@@ -197,7 +197,7 @@ TMShortCard _XtGetQuarkIndex(
else {
parseTree->quarkTbl = (XrmQuark *)
XtRealloc((char *)parseTree->quarkTbl,
- (parseTree->quarkTblSize *
+ (Cardinal)(parseTree->quarkTblSize *
sizeof(XrmQuark)));
}
}
@@ -223,11 +223,11 @@ static TMShortCard GetComplexBranchIndex(
TMShortCard newSize;
if (parseTree->complexBranchHeadTblSize == 0)
- parseTree->complexBranchHeadTblSize += TM_COMPLEXBRANCH_HEAD_TBL_ALLOC;
+ parseTree->complexBranchHeadTblSize = (TMShortCard) (parseTree->complexBranchHeadTblSize + TM_COMPLEXBRANCH_HEAD_TBL_ALLOC);
else
- parseTree->complexBranchHeadTblSize += TM_COMPLEXBRANCH_HEAD_TBL_REALLOC;
+ parseTree->complexBranchHeadTblSize = (TMShortCard) (parseTree->complexBranchHeadTblSize + TM_COMPLEXBRANCH_HEAD_TBL_REALLOC);
- newSize = (parseTree->complexBranchHeadTblSize * sizeof(StatePtr));
+ newSize = (TMShortCard) (parseTree->complexBranchHeadTblSize * sizeof(StatePtr));
if (parseTree->isStackComplexBranchHeads) {
StatePtr *oldcomplexBranchHeadTbl
@@ -240,12 +240,12 @@ static TMShortCard GetComplexBranchIndex(
else {
parseTree->complexBranchHeadTbl = (StatePtr *)
XtRealloc((char *)parseTree->complexBranchHeadTbl,
- (parseTree->complexBranchHeadTblSize *
+ (Cardinal)(parseTree->complexBranchHeadTblSize *
sizeof(StatePtr)));
}
}
parseTree->complexBranchHeadTbl[parseTree->numComplexBranchHeads++] = NULL;
- return parseTree->numComplexBranchHeads-1;
+ return (TMShortCard) (parseTree->numComplexBranchHeads - 1);
}
TMShortCard _XtGetTypeIndex(
@@ -276,10 +276,10 @@ TMShortCard _XtGetTypeIndex(
if (j == TM_TYPE_SEGMENT_SIZE) {
if (_XtGlobalTM.numTypeMatchSegments == _XtGlobalTM.typeMatchSegmentTblSize) {
- _XtGlobalTM.typeMatchSegmentTblSize += 4;
+ _XtGlobalTM.typeMatchSegmentTblSize = (TMShortCard) (_XtGlobalTM.typeMatchSegmentTblSize + 4);
_XtGlobalTM.typeMatchSegmentTbl = (TMTypeMatch *)
XtRealloc((char *)_XtGlobalTM.typeMatchSegmentTbl,
- (_XtGlobalTM.typeMatchSegmentTblSize * sizeof(TMTypeMatch)));
+ (Cardinal)(_XtGlobalTM.typeMatchSegmentTblSize * sizeof(TMTypeMatch)));
}
_XtGlobalTM.typeMatchSegmentTbl[_XtGlobalTM.numTypeMatchSegments++] =
segment = (TMTypeMatch)
@@ -371,10 +371,10 @@ TMShortCard _XtGetModifierIndex(
if (j == TM_MOD_SEGMENT_SIZE) {
if (_XtGlobalTM.numModMatchSegments == _XtGlobalTM.modMatchSegmentTblSize) {
- _XtGlobalTM.modMatchSegmentTblSize += 4;
+ _XtGlobalTM.modMatchSegmentTblSize = (TMShortCard) (_XtGlobalTM.modMatchSegmentTblSize + 4);
_XtGlobalTM.modMatchSegmentTbl = (TMModifierMatch *)
XtRealloc((char *)_XtGlobalTM.modMatchSegmentTbl,
- (_XtGlobalTM.modMatchSegmentTblSize * sizeof(TMModifierMatch)));
+ (Cardinal)(_XtGlobalTM.modMatchSegmentTblSize * sizeof(TMModifierMatch)));
}
_XtGlobalTM.modMatchSegmentTbl[_XtGlobalTM.numModMatchSegments++] =
segment = (TMModifierMatch)
@@ -446,8 +446,8 @@ Boolean _XtRegularMatch(
modMatch->lateModifiers,
&computed, &computedMask);
if (!resolved) return FALSE;
- computed |= modMatch->modifiers;
- computedMask |= modMatch->modifierMask;
+ computed = (Modifiers) (computed | modMatch->modifiers);
+ computedMask = (Modifiers) (computedMask | modMatch->modifierMask);
return ( (computed & computedMask) ==
(eventSeq->event.modifiers & computedMask));
@@ -462,7 +462,7 @@ Boolean _XtMatchAtom(
Atom atom;
atom = XInternAtom(eventSeq->xev->xany.display,
- XrmQuarkToString(typeMatch->eventCode),
+ XrmQuarkToString((XrmQuark)(typeMatch->eventCode)),
False);
return (atom == eventSeq->event.eventCode);
}
@@ -498,7 +498,7 @@ static void XEventToTMEvent(
tmEvent->xev = event;
tmEvent->event.eventCodeMask = 0;
tmEvent->event.modifierMask = 0;
- tmEvent->event.eventType = event->type;
+ tmEvent->event.eventType = (TMLongCard) event->type;
tmEvent->event.lateModifiers = NULL;
tmEvent->event.matchEvent = NULL;
tmEvent->event.standard = FALSE;
@@ -518,13 +518,13 @@ static void XEventToTMEvent(
break;
case MotionNotify:
- tmEvent->event.eventCode = event->xmotion.is_hint;
+ tmEvent->event.eventCode = (TMLongCard) event->xmotion.is_hint;
tmEvent->event.modifiers = event->xmotion.state;
break;
case EnterNotify:
case LeaveNotify:
- tmEvent->event.eventCode = event->xcrossing.mode;
+ tmEvent->event.eventCode = (TMLongCard) event->xcrossing.mode;
tmEvent->event.modifiers = event->xcrossing.state;
break;
@@ -554,13 +554,13 @@ static void XEventToTMEvent(
break;
case MappingNotify:
- tmEvent->event.eventCode = event->xmapping.request;
+ tmEvent->event.eventCode = (TMLongCard) event->xmapping.request;
tmEvent->event.modifiers = 0;
break;
case FocusIn:
case FocusOut:
- tmEvent->event.eventCode = event->xfocus.mode;
+ tmEvent->event.eventCode = (TMLongCard) event->xfocus.mode;
tmEvent->event.modifiers = 0;
break;
@@ -699,7 +699,7 @@ static void PushContext(
!(context->matches[i].isCycleStart);
i++){};
if (i < context->numMatches)
- context->numMatches = i+1;
+ context->numMatches = (TMShortCard) (i + 1);
#ifdef DEBUG
else
XtWarning("pushing cycle end with no cycle start");
@@ -710,12 +710,12 @@ static void PushContext(
if (context->numMatches == context->maxMatches)
{
if (context->maxMatches == 0)
- context->maxMatches += TM_CONTEXT_MATCHES_ALLOC;
+ context->maxMatches = (TMShortCard) (context->maxMatches + TM_CONTEXT_MATCHES_ALLOC);
else
- context->maxMatches += TM_CONTEXT_MATCHES_REALLOC;
+ context->maxMatches = (TMShortCard) (context->maxMatches + TM_CONTEXT_MATCHES_REALLOC);
context->matches = (MatchPairRec *)
XtRealloc((char *)context->matches,
- context->maxMatches * sizeof(MatchPairRec));
+ (Cardinal)(context->maxMatches * sizeof(MatchPairRec)));
}
context->matches[context->numMatches].isCycleStart = newState->isCycleStart;
context->matches[context->numMatches].isCycleEnd = newState->isCycleEnd;
@@ -901,7 +901,7 @@ static int MatchComplexBranch(
TMShortCard i;
LOCK_PROCESS;
- for (i = startIndex; i < stateTree->numComplexBranchHeads; i++)
+ for (i = (TMShortCard) startIndex; i < stateTree->numComplexBranchHeads; i++)
{
StatePtr candState;
TMShortCard numMatches = context->numMatches;
@@ -981,7 +981,7 @@ static StatePtr TryCurrentTree(
XEvent *xev = curEventPtr->xev;
unsigned long time = GetTime(tmRecPtr, xev);
XtPerDisplay pd = _XtGetPerDisplay(xev->xany.display);
- unsigned long delta = pd->multi_click_time;
+ unsigned long delta = (unsigned long) pd->multi_click_time;
if ((tmRecPtr->lastEventTime + delta) >= time) {
if (nextState->actions) {
@@ -1184,7 +1184,7 @@ static EventMask EventToMask(
unsigned long eventType = typeMatch->eventType;
if (eventType == MotionNotify) {
- Modifiers modifierMask = modMatch->modifierMask;
+ Modifiers modifierMask = (Modifiers) modMatch->modifierMask;
Modifiers tempMask;
returnMask = 0;
@@ -1211,7 +1211,7 @@ static EventMask EventToMask(
returnMask |= Button5MotionMask;
return returnMask;
}
- returnMask = _XtConvertTypeToMask(eventType);
+ returnMask = _XtConvertTypeToMask((int)eventType);
if (returnMask == (StructureNotifyMask|SubstructureNotifyMask))
returnMask = StructureNotifyMask;
return returnMask;
@@ -1285,7 +1285,7 @@ void _XtInstallTranslations(
_XtTraverseStateTree(stateTree,
AggregateEventMask,
(XtPointer)&xlations->eventMask);
- mappingNotifyInterest |= stateTree->simple.mappingNotifyInterest;
+ mappingNotifyInterest = (Boolean) (mappingNotifyInterest | stateTree->simple.mappingNotifyInterest);
}
/* double click needs to make sure that you have selected on both
button down and up. */
@@ -1339,7 +1339,7 @@ void _XtRemoveTranslations(
i++)
{
stateTree = (TMSimpleStateTree)xlations->stateTreeTbl[i];
- mappingNotifyInterest |= stateTree->mappingNotifyInterest;
+ mappingNotifyInterest = (Boolean) (mappingNotifyInterest | stateTree->mappingNotifyInterest);
}
if (mappingNotifyInterest)
RemoveFromMappingCallbacks(widget, (XtPointer)widget, NULL);
@@ -1399,7 +1399,7 @@ void XtUninstallTranslations(
_XtUninstallTranslations(widget);
if (XtIsRealized(widget) && oldMask)
XSelectInput(XtDisplay(widget), XtWindow(widget),
- XtBuildEventMask(widget));
+ (long) XtBuildEventMask(widget));
hookobj = XtHooksOfDisplay(XtDisplayOfObject(widget));
if (XtHasCallbacks(hookobj, XtNchangeHook) == XtCallbackHasSome) {
XtChangeHookDataRec call_data;
@@ -1423,8 +1423,8 @@ XtTranslations _XtCreateXlations(
TMShortCard i;
xlations = (XtTranslations)
- __XtMalloc(sizeof(TranslationData) +
- (numStateTrees-1) * sizeof(TMStateTree));
+ __XtMalloc((Cardinal)(sizeof(TranslationData) +
+ (numStateTrees - 1) * sizeof(TMStateTree)));
#ifdef TRACE_TM
LOCK_PROCESS;
if (_XtGlobalTM.numTms == _XtGlobalTM.tmTblSize) {
@@ -1463,7 +1463,7 @@ TMStateTree _XtParseTreeToStateTree(
complexTree = XtNew(TMComplexStateTreeRec);
complexTree->isSimple = False;
- tableSize = parseTree->numComplexBranchHeads * sizeof(StatePtr);
+ tableSize = (unsigned) (parseTree->numComplexBranchHeads * sizeof(StatePtr));
complexTree->complexBranchHeadTbl = (StatePtr *)
__XtMalloc(tableSize);
XtMemmove(complexTree->complexBranchHeadTbl,
@@ -1480,13 +1480,13 @@ TMStateTree _XtParseTreeToStateTree(
simpleTree->refCount = 0;
simpleTree->mappingNotifyInterest = parseTree->mappingNotifyInterest;
- tableSize = parseTree->numBranchHeads * sizeof(TMBranchHeadRec);
+ tableSize = (unsigned) (parseTree->numBranchHeads * sizeof(TMBranchHeadRec));
simpleTree->branchHeadTbl = (TMBranchHead)
__XtMalloc(tableSize);
XtMemmove(simpleTree->branchHeadTbl, parseTree->branchHeadTbl, tableSize);
simpleTree->numBranchHeads = parseTree->numBranchHeads;
- tableSize = parseTree->numQuarks * sizeof(XrmQuark);
+ tableSize = (unsigned) (parseTree->numQuarks * sizeof(XrmQuark));
simpleTree->quarkTbl = (XrmQuark *) __XtMalloc(tableSize);
XtMemmove(simpleTree->quarkTbl, parseTree->quarkTbl, tableSize);
simpleTree->numQuarks = parseTree->numQuarks;
@@ -1501,7 +1501,7 @@ static void FreeActions(
TMShortCard i;
for (action = actions; action;) {
ActionPtr nextAction = action->next;
- for (i = action->num_params; i;) {
+ for (i = (TMShortCard) action->num_params; i;) {
XtFree( action->params[--i] );
}
XtFree( (char*)action->params );
@@ -1669,7 +1669,7 @@ Boolean _XtCvtMergeTranslations(
first = ((TMConvertRec*)from->addr)->old;
second = ((TMConvertRec*)from->addr)->new;
- numStateTrees = first->numStateTrees + second->numStateTrees;
+ numStateTrees = (TMShortCard) (first->numStateTrees + second->numStateTrees);
stateTrees = (TMStateTree *)
XtStackAlloc(numStateTrees * sizeof(TMStateTree), stackStateTrees);
@@ -1773,7 +1773,7 @@ static XtTranslations UnmergeTranslations(
if (xlations->composers[1]) {
second = UnmergeTranslations(widget, xlations->composers[1],
unmergeXlations,
- currIndex +
+ (TMShortCard)currIndex +
xlations->composers[0]->numStateTrees,
oldBindings, numOldBindings,
newBindings, numNewBindingsRtn);
@@ -1908,14 +1908,14 @@ static TMBindData MakeBindData(
isComplex = (i < numBindings);
if (isComplex)
bytes = (sizeof(TMComplexBindDataRec) +
- ((numBindings - 1) *
+ ((TMLongCard)(numBindings - 1) *
sizeof(TMComplexBindProcsRec)));
else
bytes = (sizeof(TMSimpleBindDataRec) +
- ((numBindings - 1) *
+ ((TMLongCard)(numBindings - 1) *
sizeof(TMSimpleBindProcsRec)));
- bindData = (TMBindData) __XtCalloc(sizeof(char), bytes);
+ bindData = (TMBindData) __XtCalloc((Cardinal) sizeof(char), (Cardinal) bytes);
bindData->simple.isComplex = isComplex;
if (isComplex) {
TMComplexBindData cBindData = (TMComplexBindData)bindData;
@@ -2020,7 +2020,7 @@ static Boolean ComposeTranslations(
(&((TMSimpleBindData)bindData)->bindTbl[0]);
}
- numBytes =(((oldXlations ? oldXlations->numStateTrees : 0)
+ numBytes =(TMShortCard) (((oldXlations ? oldXlations->numStateTrees : 0)
+ newXlations->numStateTrees) * sizeof(TMComplexBindProcsRec));
newBindings = (TMComplexBindProcs) XtStackAlloc(numBytes, stackBindings);
XtBZero((char *)newBindings, numBytes);
@@ -2072,7 +2072,7 @@ static Boolean ComposeTranslations(
mask = newTable->eventMask;
if (mask != oldMask)
XSelectInput(XtDisplay(dest), XtWindow(dest),
- XtBuildEventMask(dest));
+ (long) XtBuildEventMask(dest));
}
XtStackFree((XtPointer)newBindings, (XtPointer)stackBindings);
return(newTable != NULL);
@@ -2113,8 +2113,8 @@ XtTranslations _XtGetTranslationValue(
Cardinal numBindings = xlations->numStateTrees;
(*aXlationsPtr) = aXlations = (ATranslations)
- __XtMalloc(sizeof(ATranslationData) +
- (numBindings - 1) * sizeof(TMComplexBindProcsRec));
+ __XtMalloc((Cardinal) (sizeof(ATranslationData) +
+ (numBindings - 1) * sizeof(TMComplexBindProcsRec)));
aXlations->hasBindings = True;
aXlations->xlations = xlations;