diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2022-06-17 20:44:12 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2022-06-18 06:36:49 -0400 |
commit | 806aefc8c6175b6252a300905a327e9d60939af7 (patch) | |
tree | f6413008b2fc8c274598c89e70faf147c45b0d4d | |
parent | a80c543bb9955199619a2cb6280b89a879fd8811 (diff) |
cppcheck fixes (const, null dereferencing, uninitialized, scope)
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r-- | src/Converters.c | 2 | ||||
-rw-r--r-- | src/Destroy.c | 2 | ||||
-rw-r--r-- | src/Display.c | 2 | ||||
-rw-r--r-- | src/Error.c | 2 | ||||
-rw-r--r-- | src/Event.c | 57 | ||||
-rw-r--r-- | src/Geometry.c | 1 | ||||
-rw-r--r-- | src/GetResList.c | 2 | ||||
-rw-r--r-- | src/GetValues.c | 8 | ||||
-rw-r--r-- | src/Hooks.c | 2 | ||||
-rw-r--r-- | src/Keyboard.c | 6 | ||||
-rw-r--r-- | src/NextEvent.c | 4 | ||||
-rw-r--r-- | src/PassivGrab.c | 2 | ||||
-rw-r--r-- | src/ResConfig.c | 2 | ||||
-rw-r--r-- | src/Selection.c | 4 | ||||
-rw-r--r-- | src/SetValues.c | 3 | ||||
-rw-r--r-- | src/TMaction.c | 2 |
16 files changed, 53 insertions, 48 deletions
diff --git a/src/Converters.c b/src/Converters.c index 9bcf791..3140456 100644 --- a/src/Converters.c +++ b/src/Converters.c @@ -208,7 +208,7 @@ XtDisplayStringConversionWarning(Display *dpy, report_it = *(Boolean *) value.addr ? Report : Ignore; else if (rep_type == _XtQString) { XrmValue toVal; - Boolean report; + Boolean report = False; toVal.addr = (XPointer) &report; toVal.size = sizeof(Boolean); diff --git a/src/Destroy.c b/src/Destroy.c index 3c6e564..9595bed 100644 --- a/src/Destroy.c +++ b/src/Destroy.c @@ -193,7 +193,7 @@ Phase2Destroy(register Widget widget) } /* Phase2Destroy */ static Boolean -IsDescendant(Widget widget, Widget root) +IsDescendant(Widget widget, const Widget root) { while ((widget = XtParent(widget)) != root) { if (widget == NULL) diff --git a/src/Display.c b/src/Display.c index cff344c..e168075 100644 --- a/src/Display.c +++ b/src/Display.c @@ -139,7 +139,7 @@ AddToAppContext(Display *d, XtAppContext app) } static void -XtDeleteFromAppContext(Display *d, register XtAppContext app) +XtDeleteFromAppContext(const Display *d, register XtAppContext app) { register int i; diff --git a/src/Error.c b/src/Error.c index 4bf4713..ed5990a 100644 --- a/src/Error.c +++ b/src/Error.c @@ -241,7 +241,7 @@ DefaultMsg(String name, String class, String defaultp, String *params, - Cardinal *num_params, + const Cardinal *num_params, Bool error, void (*fn) (_Xconst _XtString)) { diff --git a/src/Event.c b/src/Event.c index b423eeb..c8a3996 100644 --- a/src/Event.c +++ b/src/Event.c @@ -105,39 +105,42 @@ typedef struct _XtEventRecExt { EventMask XtBuildEventMask(Widget widget) { - XtEventTable ev; EventMask mask = 0L; - WIDGET_TO_APPCON(widget); + if (widget != NULL) { + XtEventTable ev; - LOCK_APP(app); - for (ev = widget->core.event_table; ev != NULL; ev = ev->next) { - if (!ev->select) - continue; + WIDGET_TO_APPCON(widget); - if (!ev->has_type_specifier) - mask |= ev->mask; - else { - if (EXT_TYPE(ev) < LASTEvent) { - Cardinal i; + LOCK_APP(app); + for (ev = widget->core.event_table; ev != NULL; ev = ev->next) { + if (!ev->select) + continue; - for (i = 0; i < ev->mask; i++) - if (EXT_SELECT_DATA(ev, i)) - mask |= *(EventMask *) EXT_SELECT_DATA(ev, i); + if (!ev->has_type_specifier) + mask |= ev->mask; + else { + if (EXT_TYPE(ev) < LASTEvent) { + Cardinal i; + + for (i = 0; i < ev->mask; i++) + if (EXT_SELECT_DATA(ev, i)) + mask |= *(EventMask *) EXT_SELECT_DATA(ev, i); + } } } - } - LOCK_PROCESS; - if (widget->core.widget_class->core_class.expose != NULL) - mask |= ExposureMask; - if (widget->core.widget_class->core_class.visible_interest) - mask |= VisibilityChangeMask; - UNLOCK_PROCESS; - if (widget->core.tm.translations) - mask |= widget->core.tm.translations->eventMask; + LOCK_PROCESS; + if (widget->core.widget_class->core_class.expose != NULL) + mask |= ExposureMask; + if (widget->core.widget_class->core_class.visible_interest) + mask |= VisibilityChangeMask; + UNLOCK_PROCESS; + if (widget->core.tm.translations) + mask |= widget->core.tm.translations->eventMask; - mask = mask & ~NonMaskableMask; - UNLOCK_APP(app); + mask = mask & ~NonMaskableMask; + UNLOCK_APP(app); + } return mask; } @@ -180,8 +183,8 @@ RemoveEventHandler(Widget widget, int type, Boolean has_type_specifier, Boolean other, - XtEventHandler proc, - XtPointer closure, + const XtEventHandler proc, + const XtPointer closure, Boolean raw) { XtEventRec *p, **pp; diff --git a/src/Geometry.c b/src/Geometry.c index 3704cb6..bb92d4a 100644 --- a/src/Geometry.c +++ b/src/Geometry.c @@ -539,6 +539,7 @@ XtMakeResizeRequest(Widget widget, WIDGET_TO_APPCON(widget); LOCK_APP(app); + memset(&request, 0, sizeof(request)); request.request_mode = CWWidth | CWHeight; request.width = (Dimension) width; request.height = (Dimension) height; diff --git a/src/GetResList.c b/src/GetResList.c index f649de5..817a60c 100644 --- a/src/GetResList.c +++ b/src/GetResList.c @@ -131,7 +131,7 @@ XtGetResourceList(WidgetClass widget_class, } static Boolean -ClassIsSubclassOf(WidgetClass class, WidgetClass superclass) +ClassIsSubclassOf(WidgetClass class, const WidgetClass superclass) { for (; class != NULL; class = class->core_class.superclass) { if (class == superclass) diff --git a/src/GetValues.c b/src/GetValues.c index 3e8bfa0..a6dcb79 100644 --- a/src/GetValues.c +++ b/src/GetValues.c @@ -75,8 +75,8 @@ in this Software without prior written authorization from The Open Group. #include "StringDefs.h" static int -GetValues(char *base, /* Base address to fetch values from */ - XrmResourceList *res, /* The current resource values. */ +GetValues(char *const base, /* Base address to fetch values from */ + XrmResourceList *res, /* The current resource values. */ register Cardinal num_resources, /* number of items in resources */ ArgList args, /* The resource values requested */ Cardinal num_args) /* number of items in arg list */ @@ -200,9 +200,9 @@ XtGetValues(register Widget w, int targ; XtAppContext app = XtWidgetToApplicationContext(w); - if (num_args == 0) + if (num_args == 0) { return; - if ((args == NULL) && (num_args != 0)) { + } else if (args == NULL) { XtAppErrorMsg(app, "invalidArgCount", "xtGetValues", XtCXtToolkitError, "Argument count > 0 on NULL argument list in XtGetValues", diff --git a/src/Hooks.c b/src/Hooks.c index 3af4751..467ac06 100644 --- a/src/Hooks.c +++ b/src/Hooks.c @@ -87,7 +87,7 @@ XtRemoveBlockHook(XtBlockHookId id) } static void -DeleteShellFromHookObj(Widget shell, +DeleteShellFromHookObj(const Widget shell, XtPointer closure, XtPointer call_data _X_UNUSED) { diff --git a/src/Keyboard.c b/src/Keyboard.c index 71d8d12..c6b4b48 100644 --- a/src/Keyboard.c +++ b/src/Keyboard.c @@ -346,11 +346,7 @@ FindKeyDestination(Widget widget, device->grabType = XtPseudoPassiveServerGrab; pdi->activatingKey = (KeyCode) event->keycode; device->grab = *grab; - - if (grab) - dspWidget = grab->widget; - else - dspWidget = focusWidget; + dspWidget = grab->widget; } } } diff --git a/src/NextEvent.c b/src/NextEvent.c index c7b9345..5c754b0 100644 --- a/src/NextEvent.c +++ b/src/NextEvent.c @@ -144,7 +144,7 @@ static SignalEventRec *freeSignalRecs; #endif static void -AdjustHowLong(unsigned long *howlong, struct timeval *start_time) +AdjustHowLong(unsigned long *howlong, const struct timeval *start_time) { struct timeval new_time, time_spent, lstart_time; @@ -332,7 +332,7 @@ InitFds(XtAppContext app, static void AdjustTimes(XtAppContext app, Boolean block, - unsigned long *howlong, + const unsigned long *howlong, Boolean ignoreTimers, wait_times_ptr_t wt) { diff --git a/src/PassivGrab.c b/src/PassivGrab.c index 672c1ef..fb4800f 100644 --- a/src/PassivGrab.c +++ b/src/PassivGrab.c @@ -121,7 +121,7 @@ DeleteDetailFromMask(Mask **ppDetailMask, unsigned short detail) */ static Mask * -CopyDetailMask(Mask *pOriginalDetailMask) +CopyDetailMask(const Mask *pOriginalDetailMask) { Mask *pTempMask; int i; diff --git a/src/ResConfig.c b/src/ResConfig.c index c3bbd37..f73a358 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -620,7 +620,7 @@ _get_last_part(char *remainder, char **part) *part = XtNewString(tight); return ('.'); } - if ((tight == NULL) || (loose && (strcoll(tight, loose) < 0))) { + if ((tight == NULL) || (strcoll(tight, loose) < 0)) { *loose++ = '\0'; *part = XtNewString(loose); return ('*'); diff --git a/src/Selection.c b/src/Selection.c index 32984b3..9215d05 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -1610,6 +1610,7 @@ GetSelectionValue(Widget widget, RequestRec req; ctx->req = &req; + memset(&req, 0, sizeof(req)); req.ctx = ctx; req.event.time = time; ctx->ref_count++; @@ -2032,6 +2033,9 @@ CleanupRequest(Display *dpy, QueuedRequestInfo qi, Atom sel) { int i, j, n; + if (qi == NULL) + return; + i = 0; /* Remove this selection from the list */ diff --git a/src/SetValues.c b/src/SetValues.c index a326b0f..d05fcc5 100644 --- a/src/SetValues.c +++ b/src/SetValues.c @@ -201,7 +201,6 @@ XtSetValues(register Widget w, ArgList args, Cardinal num_args) double oldcCache[20], reqcCache[20]; Cardinal widgetSize, constraintSize; Boolean redisplay, cleared_rect_obj = False; - XtGeometryResult result; XtWidgetGeometry geoReq, geoReply; WidgetClass wc; ConstraintWidgetClass cwc = NULL; @@ -324,6 +323,8 @@ XtSetValues(register Widget w, ArgList args, Cardinal num_args) } if (geoReq.request_mode != 0) { + XtGeometryResult result; + /* Pass on any requests for unchanged geometry values */ if (geoReq.request_mode != (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)) { diff --git a/src/TMaction.c b/src/TMaction.c index accd20c..908ca61 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -102,7 +102,6 @@ CompileActionTable(register RConst struct _XtActionsRec *actions, register Cardi { register CompiledActionTable cActions; register int i; - CompiledAction hold; CompiledActionTable cTableHold; XrmQuark (*func) (_Xconst char *); @@ -130,6 +129,7 @@ CompileActionTable(register RConst struct _XtActionsRec *actions, register Cardi /* Insertion sort. Whatever sort is used, it must be stable. */ for (i = 1; (Cardinal) i <= count - 1; i++) { + CompiledAction hold; register Cardinal j; hold = cActions[i]; |