diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2022-06-14 20:25:20 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2022-06-18 06:36:36 -0400 |
commit | a6685523e189c6330ba7007ecaf8f6d462b63024 (patch) | |
tree | a646fbda0518e415e8f570af4517dae9734395ab /src | |
parent | 248f980a67ac721882465c48d60039ac70d3fa82 (diff) |
cppcheck and clang --analyze fixes
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/Converters.c | 2 | ||||
-rw-r--r-- | src/Create.c | 5 | ||||
-rw-r--r-- | src/Intrinsic.c | 5 | ||||
-rw-r--r-- | src/NextEvent.c | 2 | ||||
-rw-r--r-- | src/Object.c | 11 | ||||
-rw-r--r-- | src/ResConfig.c | 6 | ||||
-rw-r--r-- | src/Resources.c | 3 | ||||
-rw-r--r-- | src/Selection.c | 2 | ||||
-rw-r--r-- | src/SetValues.c | 4 | ||||
-rw-r--r-- | src/TMaction.c | 3 | ||||
-rw-r--r-- | src/TMparse.c | 1 | ||||
-rw-r--r-- | src/TMprint.c | 3 |
12 files changed, 28 insertions, 19 deletions
diff --git a/src/Converters.c b/src/Converters.c index 9e80544..9bcf791 100644 --- a/src/Converters.c +++ b/src/Converters.c @@ -817,7 +817,7 @@ XtCvtStringToFloat(Display *dpy, XtPointer *closure_ret _X_UNUSED) { int ret; - float f, nan; + float f, nan = 0.0; (void) sscanf("NaN", "%g", toVal->addr != NULL ? (float *) toVal->addr : &nan); diff --git a/src/Create.c b/src/Create.c index 8131f42..511aa39 100644 --- a/src/Create.c +++ b/src/Create.c @@ -352,7 +352,7 @@ xtCreate(String name, double widget_cache[100]; Widget req_widget; XtPointer req_constraints = NULL; - Cardinal wsize, csize; + Cardinal wsize; Widget widget; XtCacheRef *cache_refs; XtCreateHookDataRec call_data; @@ -415,6 +415,7 @@ xtCreate(String name, CallInitialize(XtClass(widget), req_widget, widget, args, num_args); if (parent_constraint_class != NULL) { double constraint_cache[20]; + Cardinal csize; csize = parent_constraint_class->constraint_class.constraint_size; if (csize) { @@ -432,7 +433,7 @@ xtCreate(String name, } } XtStackFree((XtPointer) req_widget, widget_cache); - if (post_proc != (XtWidgetProc) NULL) { + if (post_proc != (XtWidgetProc) NULL && (parent != NULL)) { Widget hookobj; (*post_proc) (widget); diff --git a/src/Intrinsic.c b/src/Intrinsic.c index 07ccc78..ede8e6f 100644 --- a/src/Intrinsic.c +++ b/src/Intrinsic.c @@ -1293,8 +1293,7 @@ FillInLangSubs(Substitution subs, XtPerDisplay pd) char **rest; char *ch; - if (pd->language == NULL || - (pd->language != NULL && pd->language[0] == '\0')) { + if (pd->language == NULL || pd->language[0] == '\0') { subs[0].substitution = subs[1].substitution = subs[2].substitution = subs[3].substitution = NULL; return; @@ -1302,7 +1301,7 @@ FillInLangSubs(Substitution subs, XtPerDisplay pd) string = ExtractLocaleName(pd->language); - if (string == NULL || (string != NULL && string[0] == '\0')) { + if (string == NULL || string[0] == '\0') { subs[0].substitution = subs[1].substitution = subs[2].substitution = subs[3].substitution = NULL; return; diff --git a/src/NextEvent.c b/src/NextEvent.c index b4802bf..c7b9345 100644 --- a/src/NextEvent.c +++ b/src/NextEvent.c @@ -601,7 +601,7 @@ _XtWaitForSomething(XtAppContext app, if (app->lock == (ThreadAppProc) NULL) drop_lock = FALSE; #else - drop_lock = drop_lock; /* avoid unused warning */ + (void) drop_lock; /* avoid unused warning */ #endif InitTimes((Boolean) block, howlong, &wt); diff --git a/src/Object.c b/src/Object.c index 178bcb5..f5cfb91 100644 --- a/src/Object.c +++ b/src/Object.c @@ -166,10 +166,13 @@ ConstructCallbackOffsets(WidgetClass myWidgetClass) /* Count the number of callbacks */ resourceList = (XrmResourceList) myObjectClass->object_class.resources; - for (i = (int) myObjectClass->object_class.num_resources; --i >= 0; - resourceList++) - if (resourceList->xrm_type == QCallback) - tableSize++; + if (resourceList != NULL) { + for (i = (int) myObjectClass->object_class.num_resources; --i >= 0; + resourceList++) { + if (resourceList->xrm_type == QCallback) + tableSize++; + } + } /* * Allocate and load the table. Make sure that the new callback diff --git a/src/ResConfig.c b/src/ResConfig.c index a6a27e9..c3bbd37 100644 --- a/src/ResConfig.c +++ b/src/ResConfig.c @@ -665,10 +665,12 @@ _search_widget_tree(Widget w, char *resource, char *value) Widget parent = w; char *last_part; char *remainder = NULL; - char last_token; char *loose, *tight; int loose_len, tight_len; + if (resource == NULL) + return; + /* * Find the root of the tree given any widget */ @@ -705,6 +707,8 @@ _search_widget_tree(Widget w, char *resource, char *value) * etc.) */ if (remainder) { + char last_token; + last_token = _get_last_part(remainder, &last_part); /* * this case covers resources of only one level (eg. *background) diff --git a/src/Resources.c b/src/Resources.c index 932ba7d..3f225dc 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -1047,7 +1047,6 @@ _XtGetSubresources(Widget w, /* Widget "parent" of subobject XrmClass *classes, classes_s[50]; XrmQuark quark_cache[100]; XrmQuarkList quark_args; - XrmResourceList *table; Cardinal count, ntyped_args = num_typed_args; XtCacheRef *Resrc = NULL; @@ -1065,6 +1064,8 @@ _XtGetSubresources(Widget w, /* Widget "parent" of subobject _XtAllocError(NULL); } else { + XrmResourceList *table; + /* Get full name, class of subobject */ GetNamesAndClasses(w, names, classes); count -= 2; diff --git a/src/Selection.c b/src/Selection.c index a38d5c3..32984b3 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -1714,7 +1714,7 @@ GetSelectionValues(Widget widget, req.ctx = ctx; req.event.time = time; ctx->ref_count++; - for (i = 0, j = 0; count; count--, i++, j++) { + for (i = 0, j = 0; count > 0; count--, i++, j++) { if (j >= num_callbacks) j = 0; diff --git a/src/SetValues.c b/src/SetValues.c index a50faab..a326b0f 100644 --- a/src/SetValues.c +++ b/src/SetValues.c @@ -151,8 +151,6 @@ CallConstraintSetValues(ConstraintWidgetClass class, XtSetValuesFunc set_values; if ((WidgetClass) class != constraintWidgetClass) { - ConstraintWidgetClass superclass; - if (class == NULL) { XtAppErrorMsg(XtWidgetToApplicationContext(current), "invalidClass", "constraintSetValue", @@ -161,6 +159,8 @@ CallConstraintSetValues(ConstraintWidgetClass class, NULL, NULL); } else { + ConstraintWidgetClass superclass; + LOCK_PROCESS; superclass = (ConstraintWidgetClass) class->core_class.superclass; UNLOCK_PROCESS; diff --git a/src/TMaction.c b/src/TMaction.c index 5e843b5..accd20c 100644 --- a/src/TMaction.c +++ b/src/TMaction.c @@ -574,7 +574,6 @@ void _XtBindActions(Widget widget, XtTM tm) { XtTranslations xlations = tm->translations; - TMSimpleStateTree stateTree; int globalUnbound = 0; Cardinal i; TMBindData bindData = (TMBindData) tm->proc_table; @@ -587,6 +586,8 @@ _XtBindActions(Widget widget, XtTM tm) return; for (i = 0; i < xlations->numStateTrees; i++) { + TMSimpleStateTree stateTree; + stateTree = (TMSimpleStateTree) xlations->stateTreeTbl[i]; if (bindData->simple.isComplex) { complexBindProcs = TMGetComplexBindEntry(bindData, i); diff --git a/src/TMparse.c b/src/TMparse.c index 5beade0..1cb75c5 100644 --- a/src/TMparse.c +++ b/src/TMparse.c @@ -1011,6 +1011,7 @@ ParseKeySym(register String str, */ (*str == '(' && *(str + 1) >= '0' && *(str + 1) <= '9')) { keySymName = keySymNamebuf; /* just so we can stackfree it later */ + keySymName[0] = '\0'; /* no detail */ event->event.eventCode = 0L; event->event.eventCodeMask = 0L; diff --git a/src/TMprint.c b/src/TMprint.c index 1208cbf..f4f4444 100644 --- a/src/TMprint.c +++ b/src/TMprint.c @@ -870,8 +870,7 @@ _XtPrintEventSeq(register EventSeqPtr eventSeq, Display *dpy) modMatch = TMGetModifierMatch(_XtGetModifierIndex(&eventSeqs[j]->event)); PrintEvent(sb, typeMatch, modMatch, dpy); - if (j < i) - *sb->current++ = ','; + *sb->current++ = ','; } UNLOCK_PROCESS; return sb->start; |