Compare commits
No commits in common. 'i8c' and 'c9' have entirely different histories.
@ -1 +1 @@
|
|||||||
SOURCES/libXt-1.1.5.tar.bz2
|
SOURCES/libXt-1.2.0.tar.bz2
|
||||||
|
@ -1 +1 @@
|
|||||||
c79e2c4f7de5259a2ade458817a139b66a043d59 SOURCES/libXt-1.1.5.tar.bz2
|
f6b5ed799bc2e8d721e5407a09c2a8f570963f1b SOURCES/libXt-1.2.0.tar.bz2
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
From 1d555838d03f191d5f21268868a4ea180c2b24f2 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Walter Harms <wharms@bfs.de>
|
|
||||||
Date: Tue, 8 Jan 2019 21:25:00 +0100
|
|
||||||
Subject: [PATCH 1/9] no need to check XFree arguments
|
|
||||||
|
|
||||||
---
|
|
||||||
src/TMstate.c | 5 ++---
|
|
||||||
src/VarCreate.c | 19 +++++++------------
|
|
||||||
src/VarGet.c | 16 ++++------------
|
|
||||||
3 files changed, 13 insertions(+), 27 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/TMstate.c b/src/TMstate.c
|
|
||||||
index 4a634b4..9763fc0 100644
|
|
||||||
--- a/src/TMstate.c
|
|
||||||
+++ b/src/TMstate.c
|
|
||||||
@@ -742,8 +742,7 @@ static void FreeContext(
|
|
||||||
context->numMatches = 0;
|
|
||||||
else if (*contextPtr)
|
|
||||||
{
|
|
||||||
- if ((*contextPtr)->matches)
|
|
||||||
- XtFree ((char *) ((*contextPtr)->matches));
|
|
||||||
+ XtFree ((char *) ((*contextPtr)->matches));
|
|
||||||
XtFree((char *)*contextPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2062,7 +2061,7 @@ static Boolean ComposeTranslations(
|
|
||||||
dest->core.tm.proc_table =
|
|
||||||
(XtActionProc *) MakeBindData(newBindings, numNewBindings, bindData);
|
|
||||||
|
|
||||||
- if (bindData) XtFree((char *)bindData);
|
|
||||||
+ XtFree((char *)bindData);
|
|
||||||
|
|
||||||
dest->core.tm.translations = newTable;
|
|
||||||
|
|
||||||
diff --git a/src/VarCreate.c b/src/VarCreate.c
|
|
||||||
index 0fba379..4f5058c 100644
|
|
||||||
--- a/src/VarCreate.c
|
|
||||||
+++ b/src/VarCreate.c
|
|
||||||
@@ -79,9 +79,8 @@ _XtVaCreateWidget(
|
|
||||||
widget = _XtCreateWidget(name, widget_class, parent, (ArgList)NULL,
|
|
||||||
(Cardinal)0, typed_args, num_args);
|
|
||||||
|
|
||||||
- if (typed_args != NULL) {
|
|
||||||
- XtFree((XtPointer)typed_args);
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
+ XtFree((XtPointer)typed_args);
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
@@ -165,9 +164,8 @@ XtVaAppCreateShell(
|
|
||||||
_XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
|
|
||||||
widget = _XtAppCreateShell((String)name, (String)class, widget_class,
|
|
||||||
display, (ArgList)NULL, (Cardinal)0, typed_args, num_args);
|
|
||||||
- if (typed_args != NULL) {
|
|
||||||
- XtFree((XtPointer)typed_args);
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
+ XtFree((XtPointer)typed_args);
|
|
||||||
|
|
||||||
va_end(var);
|
|
||||||
UNLOCK_APP(app);
|
|
||||||
@@ -199,9 +197,8 @@ XtVaCreatePopupShell(
|
|
||||||
_XtVaToTypedArgList(var, total_count, &typed_args, &num_args);
|
|
||||||
widget = _XtCreatePopupShell((String)name, widget_class, parent,
|
|
||||||
(ArgList)NULL, (Cardinal)0, typed_args, num_args);
|
|
||||||
- if (typed_args != NULL) {
|
|
||||||
- XtFree((XtPointer)typed_args);
|
|
||||||
- }
|
|
||||||
+
|
|
||||||
+ XtFree((XtPointer)typed_args);
|
|
||||||
|
|
||||||
va_end(var);
|
|
||||||
UNLOCK_APP(app);
|
|
||||||
@@ -254,9 +251,7 @@ XtVaSetSubvalues(XtPointer base, XtResourceList resources, Cardinal num_resource
|
|
||||||
|
|
||||||
XtSetSubvalues(base, resources, num_resources, args, num_args);
|
|
||||||
|
|
||||||
- if (num_args != 0) {
|
|
||||||
- XtFree((XtPointer)args);
|
|
||||||
- }
|
|
||||||
+ XtFree((XtPointer)args);
|
|
||||||
|
|
||||||
va_end(var);
|
|
||||||
}
|
|
||||||
diff --git a/src/VarGet.c b/src/VarGet.c
|
|
||||||
index 7b4cea6..ccd4d10 100644
|
|
||||||
--- a/src/VarGet.c
|
|
||||||
+++ b/src/VarGet.c
|
|
||||||
@@ -86,9 +86,7 @@ XtVaGetSubresources(
|
|
||||||
_XtGetSubresources(widget, base, name, class, resources, num_resources,
|
|
||||||
NULL, 0, args, num_args);
|
|
||||||
|
|
||||||
- if (num_args != 0) {
|
|
||||||
- XtFree((XtPointer)args);
|
|
||||||
- }
|
|
||||||
+ XtFree((XtPointer)args);
|
|
||||||
|
|
||||||
va_end(var);
|
|
||||||
UNLOCK_APP(app);
|
|
||||||
@@ -116,9 +114,7 @@ XtVaGetApplicationResources(Widget widget, XtPointer base, XtResourceList resour
|
|
||||||
_XtGetApplicationResources(widget, base, resources, num_resources,
|
|
||||||
NULL, 0, args, num_args);
|
|
||||||
|
|
||||||
- if (num_args != 0) {
|
|
||||||
- XtFree((XtPointer)args);
|
|
||||||
- }
|
|
||||||
+ XtFree((XtPointer)args);
|
|
||||||
|
|
||||||
va_end(var);
|
|
||||||
UNLOCK_APP(app);
|
|
||||||
@@ -273,9 +269,7 @@ XtVaGetValues(Widget widget, ...)
|
|
||||||
}
|
|
||||||
va_end(var);
|
|
||||||
|
|
||||||
- if (resources != (XtResourceList)NULL) {
|
|
||||||
- XtFree((XtPointer)resources);
|
|
||||||
- }
|
|
||||||
+ XtFree((XtPointer)resources);
|
|
||||||
|
|
||||||
if (total_count != typed_count) {
|
|
||||||
XtGetValues(widget, args, count);
|
|
||||||
@@ -307,7 +301,5 @@ XtVaGetSubvalues(XtPointer base,XtResourceList resources, Cardinal num_resource
|
|
||||||
|
|
||||||
XtGetSubvalues(base, resources, num_resources, args, num_args);
|
|
||||||
|
|
||||||
- if (num_args != 0) {
|
|
||||||
- XtFree((XtPointer)args);
|
|
||||||
- }
|
|
||||||
+ XtFree((XtPointer)args);
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -0,0 +1,100 @@
|
|||||||
|
From f3079e509c5cf60042ae2261499ee13b6b02498a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Adam Jackson <ajax@redhat.com>
|
||||||
|
Date: Thu, 6 Feb 2020 13:45:35 -0500
|
||||||
|
Subject: [PATCH] xt: Work around a compiler issue with gcc 10
|
||||||
|
|
||||||
|
GRABEXT() is used to look up a pointer that sometimes lives just past
|
||||||
|
the end of an XtServerGrabRec. Whether it's really there or not depends
|
||||||
|
on XtServerGrabRec::hasExt. In a couple of places, we build those
|
||||||
|
structs on the stack and pass them to other functions; such structs
|
||||||
|
always have hasExt == 0, so GRABEXT would never get called in practice.
|
||||||
|
However, there exists a bug in gcc 10 - more or less difficult to hit,
|
||||||
|
depending on your compiler options and architecture - where it would not
|
||||||
|
notice that the dereference after GRABEXT is dead code, at which point
|
||||||
|
it looks like you're dereferencing one past the end of the array, which
|
||||||
|
is illegal, and you you get:
|
||||||
|
|
||||||
|
PassivGrab.c:292:35: error: array subscript 0 is outside array bounds
|
||||||
|
of 'XtServerGrabRec[1]' {aka 'struct _XtServerGrabRec[1]'}
|
||||||
|
[-Werror=array-bounds]
|
||||||
|
|
||||||
|
As a completely stupid workaround, build those on-stack structs as
|
||||||
|
arrays of two, so that the (dead) dereference looks like it's pointing
|
||||||
|
into the dummy member of the array. This is almost certainly a compiler
|
||||||
|
bug and I don't encourage merging this patch upstream, but if you need
|
||||||
|
to build libXt with gcc 10 absolutely right this second, here it is.
|
||||||
|
|
||||||
|
For details on the gcc issue, see:
|
||||||
|
|
||||||
|
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93582
|
||||||
|
---
|
||||||
|
src/PassivGrab.c | 24 ++++++++++++------------
|
||||||
|
1 file changed, 12 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/PassivGrab.c b/src/PassivGrab.c
|
||||||
|
index bece0d9..b174d40 100644
|
||||||
|
--- a/src/PassivGrab.c
|
||||||
|
+++ b/src/PassivGrab.c
|
||||||
|
@@ -553,7 +553,7 @@ XtServerGrabPtr _XtCheckServerGrabsOnWidget (
|
||||||
|
_XtBoolean isKeyboard)
|
||||||
|
{
|
||||||
|
register XtServerGrabPtr grab;
|
||||||
|
- XtServerGrabRec tempGrab;
|
||||||
|
+ XtServerGrabRec tempGrab[2];
|
||||||
|
XtServerGrabPtr *passiveListPtr;
|
||||||
|
XtPerWidgetInput pwi;
|
||||||
|
|
||||||
|
@@ -577,13 +577,13 @@ XtServerGrabPtr _XtCheckServerGrabsOnWidget (
|
||||||
|
/* Take only the lower thirteen bits as modifier state. The X Keyboard
|
||||||
|
* Extension may be representing keyboard group state in two upper bits.
|
||||||
|
*/
|
||||||
|
- tempGrab.widget = widget;
|
||||||
|
- tempGrab.keybut = (KeyCode) event->xkey.keycode; /* also xbutton.button */
|
||||||
|
- tempGrab.modifiers = event->xkey.state & 0x1FFF; /*also xbutton.state*/
|
||||||
|
- tempGrab.hasExt = False;
|
||||||
|
+ tempGrab[0].widget = widget;
|
||||||
|
+ tempGrab[0].keybut = (KeyCode) event->xkey.keycode; /* also xbutton.button */
|
||||||
|
+ tempGrab[0].modifiers = event->xkey.state & 0x1FFF; /*also xbutton.state*/
|
||||||
|
+ tempGrab[0].hasExt = False;
|
||||||
|
|
||||||
|
for (grab = *passiveListPtr; grab; grab = grab->next) {
|
||||||
|
- if (GrabMatchesSecond(&tempGrab, grab))
|
||||||
|
+ if (GrabMatchesSecond(tempGrab, grab))
|
||||||
|
return (grab);
|
||||||
|
}
|
||||||
|
return (XtServerGrabPtr)NULL;
|
||||||
|
@@ -775,17 +775,17 @@ void UngrabKeyOrButton (
|
||||||
|
Modifiers modifiers,
|
||||||
|
Boolean isKeyboard)
|
||||||
|
{
|
||||||
|
- XtServerGrabRec tempGrab;
|
||||||
|
+ XtServerGrabRec tempGrab[2];
|
||||||
|
XtPerWidgetInput pwi;
|
||||||
|
|
||||||
|
XtCheckSubclass(widget, coreWidgetClass,
|
||||||
|
"in XtUngrabKey or XtUngrabButton");
|
||||||
|
|
||||||
|
/* Build a temporary grab list entry */
|
||||||
|
- tempGrab.widget = widget;
|
||||||
|
- tempGrab.modifiers = (unsigned short) modifiers;
|
||||||
|
- tempGrab.keybut = (KeyCode) keyOrButton;
|
||||||
|
- tempGrab.hasExt = False;
|
||||||
|
+ tempGrab[0].widget = widget;
|
||||||
|
+ tempGrab[0].modifiers = (unsigned short) modifiers;
|
||||||
|
+ tempGrab[0].keybut = (KeyCode) keyOrButton;
|
||||||
|
+ tempGrab[0].hasExt = False;
|
||||||
|
|
||||||
|
LOCK_PROCESS;
|
||||||
|
pwi = _XtGetPerWidgetInput(widget, FALSE);
|
||||||
|
@@ -817,7 +817,7 @@ void UngrabKeyOrButton (
|
||||||
|
|
||||||
|
/* Delete all entries which are encompassed by the specified grab. */
|
||||||
|
DeleteServerGrabFromList(isKeyboard ? &pwi->keyList : &pwi->ptrList,
|
||||||
|
- &tempGrab);
|
||||||
|
+ tempGrab);
|
||||||
|
}
|
||||||
|
|
||||||
|
void XtGrabKey (
|
||||||
|
--
|
||||||
|
2.23.0
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
From 7eeaf69c224d6b7625d9214ba23df7e5e9d50d3c Mon Sep 17 00:00:00 2001
|
|
||||||
From: Walter Harms <wharms@bfs.de>
|
|
||||||
Date: Tue, 8 Jan 2019 22:26:25 +0100
|
|
||||||
Subject: [PATCH 2/9] no need to check args for free
|
|
||||||
|
|
||||||
---
|
|
||||||
src/Alloc.c | 2 +-
|
|
||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/src/Alloc.c b/src/Alloc.c
|
|
||||||
index c9ffce8..754881b 100644
|
|
||||||
--- a/src/Alloc.c
|
|
||||||
+++ b/src/Alloc.c
|
|
||||||
@@ -214,7 +214,7 @@ char *XtCalloc(
|
|
||||||
void XtFree(
|
|
||||||
char *ptr)
|
|
||||||
{
|
|
||||||
- if (ptr != NULL) Xfree(ptr);
|
|
||||||
+ free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* __XtMalloc(
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
|||||||
From e91a7c6e2be7fc5bb7eb5b8e9d28b9bcc36f446b Mon Sep 17 00:00:00 2001
|
|
||||||
From: Walter Harms <wharms@bfs.de>
|
|
||||||
Date: Fri, 11 Jan 2019 22:54:47 +0100
|
|
||||||
Subject: [PATCH 3/9] resolv:shadows a global declaration
|
|
||||||
|
|
||||||
---
|
|
||||||
util/makestrs.c | 14 +++++++-------
|
|
||||||
1 file changed, 7 insertions(+), 7 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/util/makestrs.c b/util/makestrs.c
|
|
||||||
index 5764849..488c9bb 100644
|
|
||||||
--- a/util/makestrs.c
|
|
||||||
+++ b/util/makestrs.c
|
|
||||||
@@ -88,7 +88,7 @@ static int solaris_abi_names = FALSE;
|
|
||||||
* commandline. Needed to separate source and build directories.
|
|
||||||
*/
|
|
||||||
static char* includedir = NULL;
|
|
||||||
-static FILE *ifopen(const char *file, const char *mode)
|
|
||||||
+static FILE *ifopen(const char *myfile, const char *mode)
|
|
||||||
{
|
|
||||||
#ifndef HAVE_ASPRINTF
|
|
||||||
size_t len;
|
|
||||||
@@ -97,13 +97,13 @@ static FILE *ifopen(const char *file, const char *mode)
|
|
||||||
FILE *ret;
|
|
||||||
|
|
||||||
if (includedir == NULL)
|
|
||||||
- return fopen(file, mode);
|
|
||||||
+ return fopen(myfile, mode);
|
|
||||||
|
|
||||||
#ifdef HAVE_ASPRINTF
|
|
||||||
- if (asprintf(&buffer, "%s/%s", includedir, file) == -1)
|
|
||||||
+ if (asprintf(&buffer, "%s/%s", includedir, myfile) == -1)
|
|
||||||
return NULL;
|
|
||||||
#else
|
|
||||||
- len = strlen(file) + strlen(includedir) + 1;
|
|
||||||
+ len = strlen(myfile) + strlen(includedir) + 1;
|
|
||||||
buffer = (char*)malloc(len + 1);
|
|
||||||
if (buffer == NULL)
|
|
||||||
return NULL;
|
|
||||||
@@ -622,7 +622,7 @@ static void DoLine(char *buf)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void IntelABIIndexEntries (File *file)
|
|
||||||
+static void IntelABIIndexEntries (File *myfile)
|
|
||||||
{
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
@@ -635,7 +635,7 @@ static void IntelABIIndexEntries (File *file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void DefaultIndexEntries (File *file)
|
|
||||||
+static void DefaultIndexEntries (File *myfile)
|
|
||||||
{
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
@@ -649,7 +649,7 @@ static void DefaultIndexEntries (File *file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-static void IndexEntries (File *file, int abi)
|
|
||||||
+static void IndexEntries (File *myfile, int abi)
|
|
||||||
{
|
|
||||||
switch (abi) {
|
|
||||||
case X_SPARC_ABI:
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
|||||||
From 94a56091c648b4d2c922b781a9d5031c45aa1908 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Thomas E. Dickey" <dickey@invisible-island.net>
|
|
||||||
Date: Tue, 12 Mar 2019 04:34:28 -0400
|
|
||||||
Subject: [PATCH 4/9] fix build when XT_GEO_TATTLER is defined That turns on a
|
|
||||||
debugging feature (activated by a resource setting). Its use of <stdarg.h>
|
|
||||||
was incorrect. Also fix compiler warnings in the related file.
|
|
||||||
|
|
||||||
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
|
|
||||||
---
|
|
||||||
include/X11/IntrinsicI.h | 1 +
|
|
||||||
src/Intrinsic.c | 16 ++++++++--------
|
|
||||||
2 files changed, 9 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/X11/IntrinsicI.h b/include/X11/IntrinsicI.h
|
|
||||||
index 845ab48..6e2396b 100644
|
|
||||||
--- a/include/X11/IntrinsicI.h
|
|
||||||
+++ b/include/X11/IntrinsicI.h
|
|
||||||
@@ -196,6 +196,7 @@ extern void _XtGClistFree(Display *dpy, XtPerDisplay pd);
|
|
||||||
extern void _XtGeoTab (int);
|
|
||||||
extern void _XtGeoTrace (
|
|
||||||
Widget widget,
|
|
||||||
+ const char *,
|
|
||||||
...
|
|
||||||
) _X_ATTRIBUTE_PRINTF(2,3);
|
|
||||||
|
|
||||||
diff --git a/src/Intrinsic.c b/src/Intrinsic.c
|
|
||||||
index 7119b09..450dce7 100644
|
|
||||||
--- a/src/Intrinsic.c
|
|
||||||
+++ b/src/Intrinsic.c
|
|
||||||
@@ -85,13 +85,14 @@ in this Software without prior written authorization from The Open Group.
|
|
||||||
#include <direct.h> /* for _getdrives() */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
String XtCXtToolkitError = "XtToolkitError";
|
|
||||||
|
|
||||||
Boolean XtIsSubclass(
|
|
||||||
Widget widget,
|
|
||||||
- WidgetClass widgetClass)
|
|
||||||
+ WidgetClass myWidgetClass)
|
|
||||||
{
|
|
||||||
register WidgetClass w;
|
|
||||||
Boolean retval = FALSE;
|
|
||||||
@@ -100,7 +101,7 @@ Boolean XtIsSubclass(
|
|
||||||
LOCK_APP(app);
|
|
||||||
LOCK_PROCESS;
|
|
||||||
for (w = widget->core.widget_class; w != NULL; w = w->core_class.superclass)
|
|
||||||
- if (w == widgetClass) {
|
|
||||||
+ if (w == myWidgetClass) {
|
|
||||||
retval = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@@ -128,7 +129,7 @@ Boolean _XtCheckSubclassFlag(
|
|
||||||
|
|
||||||
Boolean _XtIsSubclassOf(
|
|
||||||
Widget object,
|
|
||||||
- WidgetClass widgetClass,
|
|
||||||
+ WidgetClass myWidgetClass,
|
|
||||||
WidgetClass superClass,
|
|
||||||
_XtXtEnum flag)
|
|
||||||
{
|
|
||||||
@@ -139,7 +140,7 @@ Boolean _XtIsSubclassOf(
|
|
||||||
} else {
|
|
||||||
register WidgetClass c = object->core.widget_class;
|
|
||||||
while (c != superClass) {
|
|
||||||
- if (c == widgetClass) {
|
|
||||||
+ if (c == myWidgetClass) {
|
|
||||||
UNLOCK_PROCESS;
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
@@ -1566,14 +1567,13 @@ _XtGeoTab (int direction) /* +1 or -1 */
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
-_XtGeoTrace (Widget widget, ...)
|
|
||||||
+_XtGeoTrace (Widget widget, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
- char *fmt;
|
|
||||||
int i ;
|
|
||||||
+
|
|
||||||
if (IsTattled(widget)) {
|
|
||||||
- va_start(args, widget);
|
|
||||||
- fmt = va_arg(args, char *);
|
|
||||||
+ va_start(args, fmt);
|
|
||||||
for (i=0; i<n_tab; i++) printf(" ");
|
|
||||||
(void) vprintf(fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,378 +0,0 @@
|
|||||||
From 6c0cca42baebb5c681f5ee7f940da8d0a1b2613d Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Thomas E. Dickey" <dickey@invisible-island.net>
|
|
||||||
Date: Fri, 15 Mar 2019 20:06:26 -0400
|
|
||||||
Subject: [PATCH 5/9] fix bug introduced by commit
|
|
||||||
57c8b133bbcf38a9a1e345eabeeabe2a3e07c1c8, which modified util/makestrs.c to
|
|
||||||
avoid a shadowing warning of a function parameter versus global variable, but
|
|
||||||
overlooked use of the parameter within the functions. That caused all of the
|
|
||||||
resource strings in Shell.h to have the same value.
|
|
||||||
|
|
||||||
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
|
|
||||||
---
|
|
||||||
util/makestrs.c | 122 ++++++++++++++++++++++++++++++------------------
|
|
||||||
1 file changed, 76 insertions(+), 46 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/util/makestrs.c b/util/makestrs.c
|
|
||||||
index 488c9bb..e626dee 100644
|
|
||||||
--- a/util/makestrs.c
|
|
||||||
+++ b/util/makestrs.c
|
|
||||||
@@ -35,7 +35,7 @@ typedef struct _TableEnt {
|
|
||||||
struct _TableEnt* next;
|
|
||||||
char* left;
|
|
||||||
char* right;
|
|
||||||
- int offset;
|
|
||||||
+ size_t offset;
|
|
||||||
} TableEnt;
|
|
||||||
|
|
||||||
typedef struct _Table {
|
|
||||||
@@ -44,7 +44,7 @@ typedef struct _Table {
|
|
||||||
TableEnt* tableentcurrent;
|
|
||||||
TableEnt** tableenttail;
|
|
||||||
char* name;
|
|
||||||
- int offset;
|
|
||||||
+ size_t offset;
|
|
||||||
} Table;
|
|
||||||
|
|
||||||
typedef struct _File {
|
|
||||||
@@ -108,7 +108,7 @@ static FILE *ifopen(const char *myfile, const char *mode)
|
|
||||||
if (buffer == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
- snprintf(buffer, len + 1, "%s/%s", includedir, file);
|
|
||||||
+ snprintf(buffer, len + 1, "%s/%s", includedir, myfile);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = fopen(buffer, mode);
|
|
||||||
@@ -123,7 +123,7 @@ static void WriteHeaderProlog (FILE *f, File *phile)
|
|
||||||
TableEnt* te;
|
|
||||||
|
|
||||||
(void) fprintf (f, "#ifdef %s\n", featurestr);
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
for (te = t->tableent; te; te = te->next) {
|
|
||||||
if (strcmp (te->left, "RAtom") == 0) {
|
|
||||||
(void) fprintf (f,
|
|
||||||
@@ -135,6 +135,7 @@ static void WriteHeaderProlog (FILE *f, File *phile)
|
|
||||||
prefixstr, te->left, te->right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ }
|
|
||||||
(void) fprintf (f, "%s", "#else\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -148,10 +149,12 @@ static void IntelABIWriteHeader (FILE *f, File *phile)
|
|
||||||
for (t = phile->table; t; t = t->next) {
|
|
||||||
(void) fprintf (f, "%s %sConst char %s[];\n",
|
|
||||||
externrefstr, conststr ? conststr : fileprotstr, t->name);
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
(void) fprintf (f,
|
|
||||||
- "#ifndef %s%s\n#define %s%s ((char*)&%s[%d])\n#endif\n",
|
|
||||||
- prefixstr, te->left, prefixstr, te->left, t->name, te->offset);
|
|
||||||
+ "#ifndef %s%s\n#define %s%s ((char*)&%s[%lu])\n#endif\n",
|
|
||||||
+ prefixstr, te->left, prefixstr, te->left, t->name,
|
|
||||||
+ (unsigned long) te->offset);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
|
||||||
@@ -162,10 +165,12 @@ static void SPARCABIWriteHeader (FILE *f, File *phile)
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
(void) fprintf (f, "#define %s%s \"%s\"\n",
|
|
||||||
prefixstr, te->left, te->right);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FunctionWriteHeader (FILE *f, File *phile)
|
|
||||||
@@ -179,12 +184,14 @@ static void FunctionWriteHeader (FILE *f, File *phile)
|
|
||||||
externrefstr, conststr ? conststr : fileprotstr,
|
|
||||||
phile->table->name);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
(void) fprintf (f,
|
|
||||||
- "#ifndef %s%s\n#define %s%s (%s(%d))\n#endif\n",
|
|
||||||
+ "#ifndef %s%s\n#define %s%s (%s(%lu))\n#endif\n",
|
|
||||||
prefixstr, te->left, prefixstr, te->left, phile->table->name,
|
|
||||||
- te->offset);
|
|
||||||
+ (unsigned long) te->offset);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
|
||||||
}
|
|
||||||
@@ -196,13 +203,15 @@ static void ArrayperWriteHeader (FILE *f, File *phile)
|
|
||||||
|
|
||||||
WriteHeaderProlog (f, phile);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
(void) fprintf (f,
|
|
||||||
"#ifndef %s%s\n%s %sConst char %s%s[];\n#endif\n",
|
|
||||||
prefixstr, te->left,
|
|
||||||
externrefstr, conststr ? conststr : fileprotstr,
|
|
||||||
prefixstr, te->left);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
|
||||||
}
|
|
||||||
@@ -218,12 +227,14 @@ static void DefaultWriteHeader (FILE *f, File *phile)
|
|
||||||
externrefstr, conststr ? conststr : fileprotstr,
|
|
||||||
phile->table->name);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
(void) fprintf (f,
|
|
||||||
- "#ifndef %s%s\n#define %s%s ((char*)&%s[%d])\n#endif\n",
|
|
||||||
+ "#ifndef %s%s\n#define %s%s ((char*)&%s[%lu])\n#endif\n",
|
|
||||||
prefixstr, te->left, prefixstr, te->left, phile->table->name,
|
|
||||||
- te->offset);
|
|
||||||
+ (unsigned long) te->offset);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
|
|
||||||
(void) fprintf (f, "#endif /* %s */\n", featurestr);
|
|
||||||
}
|
|
||||||
@@ -232,7 +243,7 @@ static void CopyTmplProlog (FILE *tmpl, FILE *f)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
static const char* magic_string = X_MAGIC_STRING;
|
|
||||||
- int magic_string_len = strlen (magic_string);
|
|
||||||
+ size_t magic_string_len = strlen (magic_string);
|
|
||||||
|
|
||||||
while (fgets (buf, sizeof buf, tmpl)) {
|
|
||||||
if (strncmp (buf, magic_string, magic_string_len) == 0) {
|
|
||||||
@@ -316,7 +327,7 @@ static void WriteSourceLine (TableEnt *te, int abi, int fudge)
|
|
||||||
(void) printf ("%s", "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
-static const char* const_string = "%s %sConst char %s[] = {\n";
|
|
||||||
+#define const_string "%s %sConst char %s[] = {\n"
|
|
||||||
|
|
||||||
static void IntelABIWriteSource (int abi)
|
|
||||||
{
|
|
||||||
@@ -329,8 +340,9 @@ static void IntelABIWriteSource (int abi)
|
|
||||||
for (t = phile->table; t; t = t->next) {
|
|
||||||
(void) printf (const_string, externdefstr,
|
|
||||||
conststr ? conststr : "", t->name);
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
WriteSourceLine (te, abi, 0);
|
|
||||||
+ }
|
|
||||||
(void) printf ("%s\n\n", "};");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -347,17 +359,21 @@ static void IntelABIBCWriteSource (int abi)
|
|
||||||
(void) printf (const_string, externdefstr,
|
|
||||||
conststr ? conststr : "", phile->table->name);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
(void) printf ("%s\n\n", "};");
|
|
||||||
|
|
||||||
if (phile->table->next) {
|
|
||||||
(void) printf (const_string, externdefstr,
|
|
||||||
conststr ? conststr : "", phile->table->next->name);
|
|
||||||
- for (t = phile->table->next; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table->next; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
WriteSourceLine (te, abi, 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
(void) printf ("%s\n\n", "};");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -374,9 +390,11 @@ static void FunctionWriteSource (int abi)
|
|
||||||
(void) printf ("static %sConst char _%s[] = {\n",
|
|
||||||
conststr ? conststr : "", phile->table->name);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
(void) printf ("%s\n\n", "};");
|
|
||||||
|
|
||||||
(void) printf ("%sConst char* %s(index)\n int index;\n{\n return &_%s[index];\n}\n\n",
|
|
||||||
@@ -394,7 +412,7 @@ static void ArrayperWriteSource (int abi)
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
for (te = t->tableent; te; te = te->next) {
|
|
||||||
if (strcmp (te->left, "RAtom") == 0) {
|
|
||||||
if (done_atom) return;
|
|
||||||
@@ -405,6 +423,7 @@ static void ArrayperWriteSource (int abi)
|
|
||||||
prefixstr,
|
|
||||||
te->left, te->right);
|
|
||||||
}
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -419,9 +438,11 @@ static void DefaultWriteSource (int abi)
|
|
||||||
(void) printf (const_string, externdefstr, conststr ? conststr : "",
|
|
||||||
phile->table->name);
|
|
||||||
|
|
||||||
- for (t = phile->table; t; t = t->next)
|
|
||||||
- for (te = t->tableent; te; te = te->next)
|
|
||||||
+ for (t = phile->table; t; t = t->next) {
|
|
||||||
+ for (te = t->tableent; te; te = te->next) {
|
|
||||||
WriteSourceLine (te, abi, t->next ? 1 : 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
(void) printf ("%s\n\n", "};");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -457,7 +478,10 @@ static void WriteSource(char *tagline, int abi)
|
|
||||||
|
|
||||||
(*sourceproc[abi])(abi);
|
|
||||||
|
|
||||||
- if (tmpl) CopyTmplEpilog (tmpl, stdout);
|
|
||||||
+ if (tmpl) {
|
|
||||||
+ CopyTmplEpilog (tmpl, stdout);
|
|
||||||
+ fclose(tmpl);
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoLine(char *buf)
|
|
||||||
@@ -586,9 +610,9 @@ static void DoLine(char *buf)
|
|
||||||
{
|
|
||||||
char* right;
|
|
||||||
TableEnt* tableent;
|
|
||||||
- int llen;
|
|
||||||
- int rlen;
|
|
||||||
- int len;
|
|
||||||
+ size_t llen;
|
|
||||||
+ size_t rlen;
|
|
||||||
+ size_t len;
|
|
||||||
|
|
||||||
if ((right = strchr(buf, ' ')))
|
|
||||||
*right++ = 0;
|
|
||||||
@@ -602,7 +626,8 @@ static void DoLine(char *buf)
|
|
||||||
llen = len = strlen(buf) + 1;
|
|
||||||
rlen = strlen(right) + 1;
|
|
||||||
if (right != buf + 1) len += rlen;
|
|
||||||
- if ((tableent = (TableEnt*)malloc(sizeof(TableEnt) + len)) == NULL)
|
|
||||||
+ tableent = (TableEnt*)calloc(sizeof(TableEnt) + len, 1);
|
|
||||||
+ if (tableent == NULL)
|
|
||||||
exit(1);
|
|
||||||
tableent->left = (char *)(tableent + 1);
|
|
||||||
strcpy(tableent->left, buf);
|
|
||||||
@@ -627,11 +652,12 @@ static void IntelABIIndexEntries (File *myfile)
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
|
|
||||||
- for (t = file->table; t; t = t->next)
|
|
||||||
+ for (t = myfile->table; t; t = t->next) {
|
|
||||||
for (te = t->tableent; te; te = te->next) {
|
|
||||||
te->offset = t->offset;
|
|
||||||
t->offset += strlen (te->right);
|
|
||||||
t->offset++;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -639,13 +665,14 @@ static void DefaultIndexEntries (File *myfile)
|
|
||||||
{
|
|
||||||
Table* t;
|
|
||||||
TableEnt* te;
|
|
||||||
- int offset = 0;
|
|
||||||
+ size_t offset = 0;
|
|
||||||
|
|
||||||
- for (t = file->table; t; t = t->next)
|
|
||||||
+ for (t = myfile->table; t; t = t->next) {
|
|
||||||
for (te = t->tableent; te; te = te->next) {
|
|
||||||
te->offset = offset;
|
|
||||||
offset += strlen (te->right);
|
|
||||||
offset++;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -656,10 +683,10 @@ static void IndexEntries (File *myfile, int abi)
|
|
||||||
break;
|
|
||||||
case X_INTEL_ABI:
|
|
||||||
case X_INTEL_ABI_BC:
|
|
||||||
- IntelABIIndexEntries (file);
|
|
||||||
+ IntelABIIndexEntries (myfile);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
- DefaultIndexEntries (file);
|
|
||||||
+ DefaultIndexEntries (myfile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -669,12 +696,12 @@ static char* DoComment (char *line)
|
|
||||||
char* tag;
|
|
||||||
char* eol;
|
|
||||||
char* ret;
|
|
||||||
- int len;
|
|
||||||
+ size_t len;
|
|
||||||
|
|
||||||
/* assume that the first line with two '$' in it is the RCS tag line */
|
|
||||||
if ((tag = strchr (line, '$')) == NULL) return NULL;
|
|
||||||
if ((eol = strchr (tag + 1, '$')) == NULL) return NULL;
|
|
||||||
- len = eol - tag;
|
|
||||||
+ len = (size_t)(eol - tag);
|
|
||||||
if ((ret = malloc (len)) == NULL)
|
|
||||||
exit (1);
|
|
||||||
(void) strncpy (ret, tag + 1, len - 1);
|
|
||||||
@@ -684,7 +711,7 @@ static char* DoComment (char *line)
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
- int len, i;
|
|
||||||
+ size_t len;
|
|
||||||
char* tagline = NULL;
|
|
||||||
File* phile;
|
|
||||||
FILE *f;
|
|
||||||
@@ -698,6 +725,7 @@ int main(int argc, char *argv[])
|
|
||||||
|
|
||||||
f = stdin;
|
|
||||||
if (argc > 1) {
|
|
||||||
+ int i;
|
|
||||||
for (i = 1; i < argc; i++) {
|
|
||||||
if (strcmp (argv[i], "-f") == 0) {
|
|
||||||
if (++i < argc)
|
|
||||||
@@ -706,10 +734,12 @@ int main(int argc, char *argv[])
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (strcmp (argv[i], "-i") == 0) {
|
|
||||||
- if (++i < argc)
|
|
||||||
+ if (++i < argc) {
|
|
||||||
includedir = argv[i];
|
|
||||||
- else
|
|
||||||
+ } else {
|
|
||||||
+ if (f != 0 && f != stdin) fclose(f);
|
|
||||||
return 1;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
if (strcmp (argv[i], "-sparcabi") == 0)
|
|
||||||
abi = X_SPARC_ABI;
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,206 +0,0 @@
|
|||||||
From 15ce56425b5e5b89486481fdf7a8b077639f3c78 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Thomas E. Dickey" <dickey@invisible-island.net>
|
|
||||||
Date: Sun, 17 Mar 2019 20:59:21 -0400
|
|
||||||
Subject: [PATCH 6/9] Use standard size_t type in the casts for
|
|
||||||
length-parameter of memcpy, memmove and bzero. When the library was written
|
|
||||||
(1989), none of those had been standardized, and the source-code used "(int)"
|
|
||||||
casts to help with K&R compilers. The cleanup done in the previous update
|
|
||||||
used binary-compare to validate, which does not work for these because the
|
|
||||||
compiler is recording the cast's effect.
|
|
||||||
|
|
||||||
This change reduces the number of gcc warnings from 163 to 128.
|
|
||||||
|
|
||||||
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
|
|
||||||
---
|
|
||||||
include/X11/IntrinsicI.h | 6 +++---
|
|
||||||
src/Create.c | 6 +++---
|
|
||||||
src/Resources.c | 24 ++++++++++++------------
|
|
||||||
src/SetValues.c | 8 ++++----
|
|
||||||
4 files changed, 22 insertions(+), 22 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/X11/IntrinsicI.h b/include/X11/IntrinsicI.h
|
|
||||||
index 6e2396b..c028701 100644
|
|
||||||
--- a/include/X11/IntrinsicI.h
|
|
||||||
+++ b/include/X11/IntrinsicI.h
|
|
||||||
@@ -110,14 +110,14 @@ SOFTWARE.
|
|
||||||
|
|
||||||
#define XtMemmove(dst, src, size) \
|
|
||||||
if ((char *)(dst) != (char *)(src)) { \
|
|
||||||
- (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \
|
|
||||||
+ (void) memcpy((char *) (dst), (char *) (src), (size_t) (size)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define XtBZero(dst, size) \
|
|
||||||
- bzero((char *) (dst), (int) (size))
|
|
||||||
+ bzero((char *) (dst), (size_t) (size))
|
|
||||||
|
|
||||||
#define XtMemcmp(b1, b2, size) \
|
|
||||||
- memcmp((char *) (b1), (char *) (b2), (int) (size))
|
|
||||||
+ memcmp((char *) (b1), (char *) (b2), (size_t) (size))
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************
|
|
||||||
diff --git a/src/Create.c b/src/Create.c
|
|
||||||
index da00192..bbea9ce 100644
|
|
||||||
--- a/src/Create.c
|
|
||||||
+++ b/src/Create.c
|
|
||||||
@@ -412,14 +412,14 @@ xtCreate(
|
|
||||||
wsize = widget_class->core_class.widget_size;
|
|
||||||
csize = 0;
|
|
||||||
req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
|
|
||||||
- (void) memmove ((char *) req_widget, (char *) widget, (int) wsize);
|
|
||||||
+ (void) memmove ((char *) req_widget, (char *) widget, (size_t) wsize);
|
|
||||||
CallInitialize (XtClass(widget), req_widget, widget, args, num_args);
|
|
||||||
if (parent_constraint_class != NULL) {
|
|
||||||
csize = parent_constraint_class->constraint_class.constraint_size;
|
|
||||||
if (csize) {
|
|
||||||
req_constraints = XtStackAlloc(csize, constraint_cache);
|
|
||||||
(void) memmove((char*)req_constraints, widget->core.constraints,
|
|
||||||
- (int)csize);
|
|
||||||
+ (size_t)csize);
|
|
||||||
req_widget->core.constraints = req_constraints;
|
|
||||||
} else req_widget->core.constraints = NULL;
|
|
||||||
CallConstraintInitialize(parent_constraint_class, req_widget, widget,
|
|
||||||
@@ -778,7 +778,7 @@ _XtCreateHookObj(Screen* screen)
|
|
||||||
CompileCallbacks(hookobj);
|
|
||||||
wsize = hookObjectClass->core_class.widget_size;
|
|
||||||
req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
|
|
||||||
- (void) memmove ((char *) req_widget, (char *) hookobj, (int) wsize);
|
|
||||||
+ (void) memmove ((char *) req_widget, (char *) hookobj, (size_t) wsize);
|
|
||||||
CallInitialize (hookObjectClass, req_widget, hookobj,
|
|
||||||
(ArgList)NULL, (Cardinal) 0);
|
|
||||||
XtStackFree((XtPointer)req_widget, widget_cache);
|
|
||||||
diff --git a/src/Resources.c b/src/Resources.c
|
|
||||||
index 9e0f065..456da7a 100644
|
|
||||||
--- a/src/Resources.c
|
|
||||||
+++ b/src/Resources.c
|
|
||||||
@@ -110,7 +110,7 @@ void _XtCopyFromArg(
|
|
||||||
register unsigned int size)
|
|
||||||
{
|
|
||||||
if (size > sizeof(XtArgVal))
|
|
||||||
- (void) memmove((char *) dst, (char *) src, (int) size);
|
|
||||||
+ (void) memmove((char *) dst, (char *) src, (size_t) size);
|
|
||||||
else {
|
|
||||||
union {
|
|
||||||
long longval;
|
|
||||||
@@ -133,7 +133,7 @@ void _XtCopyFromArg(
|
|
||||||
else if (size == sizeof(char*)) u.charptr = (char*)src;
|
|
||||||
else p = (char*)&src;
|
|
||||||
|
|
||||||
- (void) memmove(dst, p, (int) size);
|
|
||||||
+ (void) memmove(dst, p, (size_t) size);
|
|
||||||
}
|
|
||||||
} /* _XtCopyFromArg */
|
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ void _XtCopyToArg(
|
|
||||||
XtPointer ptr;
|
|
||||||
} u;
|
|
||||||
if (size <= sizeof(XtArgVal)) {
|
|
||||||
- (void) memmove((char*)&u, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)&u, (char*)src, (size_t)size );
|
|
||||||
if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
|
|
||||||
#ifdef LONG64
|
|
||||||
else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
|
|
||||||
@@ -167,10 +167,10 @@ void _XtCopyToArg(
|
|
||||||
else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
|
|
||||||
else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
|
|
||||||
else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
|
|
||||||
- else (void) memmove((char*)dst, (char*)src, (int)size );
|
|
||||||
+ else (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
- (void) memmove((char*)dst, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
||||||
#else
|
|
||||||
XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError,
|
|
||||||
"NULL ArgVal in XtGetValues", (String*) NULL, (Cardinal*) NULL);
|
|
||||||
@@ -178,7 +178,7 @@ void _XtCopyToArg(
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* proper GetValues semantics: argval is pointer to destination */
|
|
||||||
- (void) memmove((char*)*dst, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)*dst, (char*)src, (size_t)size );
|
|
||||||
}
|
|
||||||
} /* _XtCopyToArg */
|
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ static void CopyToArg(
|
|
||||||
XtPointer ptr;
|
|
||||||
} u;
|
|
||||||
if (size <= sizeof(XtArgVal)) {
|
|
||||||
- (void) memmove((char*)&u, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)&u, (char*)src, (size_t)size );
|
|
||||||
if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
|
|
||||||
#ifdef LONG64
|
|
||||||
else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
|
|
||||||
@@ -211,14 +211,14 @@ static void CopyToArg(
|
|
||||||
else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
|
|
||||||
else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
|
|
||||||
else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
|
|
||||||
- else (void) memmove((char*)dst, (char*)src, (int)size );
|
|
||||||
+ else (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
- (void) memmove((char*)dst, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* proper GetValues semantics: argval is pointer to destination */
|
|
||||||
- (void) memmove((char*)*dst, (char*)src, (int)size );
|
|
||||||
+ (void) memmove((char*)*dst, (char*)src, (size_t)size );
|
|
||||||
}
|
|
||||||
} /* CopyToArg */
|
|
||||||
|
|
||||||
@@ -519,8 +519,8 @@ static XtCacheRef *GetResources(
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mark each resource as not found on arg list */
|
|
||||||
- bzero((char *) found, (int) (num_resources * sizeof(Boolean)));
|
|
||||||
- bzero((char *) typed, (int) (num_resources * sizeof(int)));
|
|
||||||
+ bzero((char *) found, (size_t) (num_resources * sizeof(Boolean)));
|
|
||||||
+ bzero((char *) typed, (size_t) (num_resources * sizeof(int)));
|
|
||||||
|
|
||||||
/* Copy the args into the resources, mark each as found */
|
|
||||||
{
|
|
||||||
diff --git a/src/SetValues.c b/src/SetValues.c
|
|
||||||
index e432ec7..f274000 100644
|
|
||||||
--- a/src/SetValues.c
|
|
||||||
+++ b/src/SetValues.c
|
|
||||||
@@ -224,7 +224,7 @@ void XtSetValues(
|
|
||||||
UNLOCK_PROCESS;
|
|
||||||
oldw = (Widget) XtStackAlloc(widgetSize, oldwCache);
|
|
||||||
reqw = (Widget) XtStackAlloc (widgetSize, reqwCache);
|
|
||||||
- (void) memmove((char *) oldw, (char *) w, (int) widgetSize);
|
|
||||||
+ (void) memmove((char *) oldw, (char *) w, (size_t) widgetSize);
|
|
||||||
|
|
||||||
/* Set resource values */
|
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ void XtSetValues(
|
|
||||||
wc->core_class.num_resources, args, num_args);
|
|
||||||
UNLOCK_PROCESS;
|
|
||||||
|
|
||||||
- (void) memmove ((char *) reqw, (char *) w, (int) widgetSize);
|
|
||||||
+ (void) memmove ((char *) reqw, (char *) w, (size_t) widgetSize);
|
|
||||||
|
|
||||||
hasConstraints = (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)));
|
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ void XtSetValues(
|
|
||||||
oldw->core.constraints = XtStackAlloc(constraintSize, oldcCache);
|
|
||||||
reqw->core.constraints = XtStackAlloc(constraintSize, reqcCache);
|
|
||||||
(void) memmove((char *) oldw->core.constraints,
|
|
||||||
- (char *) w->core.constraints, (int) constraintSize);
|
|
||||||
+ (char *) w->core.constraints, (size_t) constraintSize);
|
|
||||||
|
|
||||||
/* Set constraint values */
|
|
||||||
LOCK_PROCESS;
|
|
||||||
@@ -262,7 +262,7 @@ void XtSetValues(
|
|
||||||
cwc->constraint_class.num_resources, args, num_args);
|
|
||||||
UNLOCK_PROCESS;
|
|
||||||
(void) memmove((char *) reqw->core.constraints,
|
|
||||||
- (char *) w->core.constraints, (int) constraintSize);
|
|
||||||
+ (char *) w->core.constraints, (size_t) constraintSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Inform widget of changes, then inform parent of changes */
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
|||||||
From a35bef8c333f3fcf12d66e38ad769bc5f1df16a3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
Date: Thu, 11 Apr 2019 17:26:58 +0200
|
|
||||||
Subject: [PATCH 7/9] Fix leaks detected by covscan
|
|
||||||
|
|
||||||
The following leaks are reported by covscan:
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/ResConfig.c:542: alloc_arg: "_get_part" allocates memory that is stored into "part".
|
|
||||||
libXt-20190411/src/ResConfig.c:544: noescape: Resource "part" is not freed or pointed-to in "_match_resource_to_widget".
|
|
||||||
libXt-20190411/src/ResConfig.c:560: leaked_storage: Variable "part" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/TMgrab.c:108: alloc_arg: "XtKeysymToKeycodeList" allocates memory that is stored into "keycodes".
|
|
||||||
libXt-20190411/src/TMgrab.c:115: var_assign: Assigning: "keycodeP" = "keycodes".
|
|
||||||
libXt-20190411/src/TMgrab.c:124: leaked_storage: Variable "keycodeP" going out of scope leaks the storage it points to.
|
|
||||||
libXt-20190411/src/TMgrab.c:124: leaked_storage: Variable "keycodes" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/TMparse.c:1544: alloc_fn: Storage is returned from allocation function "XtMalloc".
|
|
||||||
libXt-20190411/src/TMparse.c:1544: var_assign: Assigning: "event" = storage returned from "XtMalloc(88U)".
|
|
||||||
libXt-20190411/src/TMparse.c:1549: noescape: Resource "event" is not freed or pointed-to in "ParseQuotedStringEvent".
|
|
||||||
libXt-20190411/src/TMparse.c:1555: leaked_storage: Variable "event" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/TMparse.c:1779: alloc_fn: Storage is returned from allocation function "XtMalloc".
|
|
||||||
libXt-20190411/src/TMparse.c:1779: var_assign: Assigning: "action" = storage returned from "XtMalloc(32U)".
|
|
||||||
libXt-20190411/src/TMparse.c:1784: noescape: Resource "action" is not freed or pointed-to in "ParseAction".
|
|
||||||
libXt-20190411/src/TMparse.c:1785: leaked_storage: Variable "action" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
In addition to this legitimate leaks, covscan can get confused by
|
|
||||||
the allocated memory in XtKeysymToKeycodeList:
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/TMgrab.c:108: alloc_arg: "XtKeysymToKeycodeList" allocates memory that is stored into "keycodes".
|
|
||||||
libXt-20190411/src/TMgrab.c:114: leaked_storage: Variable "keycodes" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
---
|
|
||||||
src/ResConfig.c | 1 +
|
|
||||||
src/TMgrab.c | 10 ++++++++--
|
|
||||||
src/TMparse.c | 6 +++++-
|
|
||||||
3 files changed, 14 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/ResConfig.c b/src/ResConfig.c
|
|
||||||
index 5a7f6d2..bd6792c 100644
|
|
||||||
--- a/src/ResConfig.c
|
|
||||||
+++ b/src/ResConfig.c
|
|
||||||
@@ -557,6 +557,7 @@ _set_and_search (
|
|
||||||
} else
|
|
||||||
_search_child (w, local_index, remainder,
|
|
||||||
resource, value, last_token, last_part);
|
|
||||||
+ XtFree (part);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (token == '*') {
|
|
||||||
diff --git a/src/TMgrab.c b/src/TMgrab.c
|
|
||||||
index 08cb486..4e7d20d 100644
|
|
||||||
--- a/src/TMgrab.c
|
|
||||||
+++ b/src/TMgrab.c
|
|
||||||
@@ -105,13 +105,17 @@ static void GrabAllCorrectKeys(
|
|
||||||
careOn |= modMatch->modifiers;
|
|
||||||
careMask |= modMatch->modifierMask;
|
|
||||||
|
|
||||||
+ keycodes = NULL;
|
|
||||||
XtKeysymToKeycodeList(
|
|
||||||
dpy,
|
|
||||||
(KeySym)typeMatch->eventCode,
|
|
||||||
&keycodes,
|
|
||||||
&keycount
|
|
||||||
);
|
|
||||||
- if (keycount == 0) return;
|
|
||||||
+ if (keycount == 0) {
|
|
||||||
+ XtFree((char *)keycodes);
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
for (keycodeP = keycodes; keycount--; keycodeP++) {
|
|
||||||
if (modMatch->standard) {
|
|
||||||
/* find standard modifiers that produce this keysym */
|
|
||||||
@@ -120,8 +124,10 @@ static void GrabAllCorrectKeys(
|
|
||||||
Modifiers modifiers_return;
|
|
||||||
XtTranslateKeycode( dpy, *keycodeP, (Modifiers)0,
|
|
||||||
&modifiers_return, &keysym );
|
|
||||||
- if (careOn & modifiers_return)
|
|
||||||
+ if (careOn & modifiers_return) {
|
|
||||||
+ XtFree((char *)keycodes);
|
|
||||||
return;
|
|
||||||
+ }
|
|
||||||
if (keysym == typeMatch->eventCode) {
|
|
||||||
XtGrabKey(widget, *keycodeP, careOn,
|
|
||||||
grabP->owner_events,
|
|
||||||
diff --git a/src/TMparse.c b/src/TMparse.c
|
|
||||||
index df94181..086f53d 100644
|
|
||||||
--- a/src/TMparse.c
|
|
||||||
+++ b/src/TMparse.c
|
|
||||||
@@ -1551,6 +1551,7 @@ static String ParseEventSeq(
|
|
||||||
XtCXtToolkitError,
|
|
||||||
"... probably due to non-Latin1 character in quoted string",
|
|
||||||
(String*)NULL, (Cardinal*)NULL);
|
|
||||||
+ XtFree((char *)event);
|
|
||||||
return PanicModeRecovery(str);
|
|
||||||
}
|
|
||||||
*nextEvent = event;
|
|
||||||
@@ -1781,7 +1782,10 @@ static String ParseActionSeq(
|
|
||||||
action->next = NULL;
|
|
||||||
|
|
||||||
str = ParseAction(str, action, &quark, error);
|
|
||||||
- if (*error) return PanicModeRecovery(str);
|
|
||||||
+ if (*error) {
|
|
||||||
+ XtFree((char *)action);
|
|
||||||
+ return PanicModeRecovery(str);
|
|
||||||
+ }
|
|
||||||
|
|
||||||
action->idx = _XtGetQuarkIndex(parseTree, quark);
|
|
||||||
ScanWhitespace(str);
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
From a9e6eecdd61b43367d5b7873532952db54b1b124 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
Date: Thu, 11 Apr 2019 17:27:12 +0200
|
|
||||||
Subject: [PATCH 8/9] dummy fix for covscan
|
|
||||||
|
|
||||||
covscan seems lost here:
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/Intrinsic.c:1074: alloc_fn: Storage is returned from allocation function "__XtMalloc".
|
|
||||||
libXt-20190411/src/Intrinsic.c:1074: var_assign: Assigning: "buf2" = storage returned from "__XtMalloc(4096U)".
|
|
||||||
libXt-20190411/src/Intrinsic.c:1110: leaked_storage: Variable "buf2" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Error: USE_AFTER_FREE (CWE-416):
|
|
||||||
libXt-20190411/src/Intrinsic.c:1113: alias: Assigning: "buf" = "buf2". Now both point to the same storage.
|
|
||||||
libXt-20190411/src/Intrinsic.c:1108: freed_arg: "XtFree" frees "buf2".
|
|
||||||
libXt-20190411/src/Intrinsic.c:1110: use_after_free: Using freed pointer "buf".
|
|
||||||
|
|
||||||
Both are false positive, but we can make it understand where it
|
|
||||||
is wrong.
|
|
||||||
|
|
||||||
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
---
|
|
||||||
src/Intrinsic.c | 12 ++++++++----
|
|
||||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/Intrinsic.c b/src/Intrinsic.c
|
|
||||||
index 450dce7..3a16d5e 100644
|
|
||||||
--- a/src/Intrinsic.c
|
|
||||||
+++ b/src/Intrinsic.c
|
|
||||||
@@ -1070,8 +1070,9 @@ String XtFindFile(
|
|
||||||
int len;
|
|
||||||
Boolean firstTime = TRUE;
|
|
||||||
|
|
||||||
- buf = buf1 = __XtMalloc((unsigned)PATH_MAX);
|
|
||||||
+ buf1 = __XtMalloc((unsigned)PATH_MAX);
|
|
||||||
buf2 = __XtMalloc((unsigned)PATH_MAX);
|
|
||||||
+ buf = buf1;
|
|
||||||
|
|
||||||
if (predicate == NULL) predicate = TestFile;
|
|
||||||
|
|
||||||
@@ -1105,9 +1106,12 @@ String XtFindFile(
|
|
||||||
#ifdef XNL_DEBUG
|
|
||||||
printf("File found.\n");
|
|
||||||
#endif /* XNL_DEBUG */
|
|
||||||
- if (buf == buf1) XtFree(buf2);
|
|
||||||
- else XtFree(buf1);
|
|
||||||
- return buf;
|
|
||||||
+ if (buf == buf1) {
|
|
||||||
+ XtFree(buf2);
|
|
||||||
+ return buf1;
|
|
||||||
+ }
|
|
||||||
+ XtFree(buf1);
|
|
||||||
+ return buf2;
|
|
||||||
}
|
|
||||||
if (buf == buf1)
|
|
||||||
buf = buf2;
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
|||||||
From fa2acae4f13209aaefa5a38d046aca3da545fe63 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
Date: Thu, 11 Apr 2019 17:21:17 +0200
|
|
||||||
Subject: [PATCH 9/9] Fix covscan complain
|
|
||||||
|
|
||||||
covscan gets confused by the test before the XtFree.
|
|
||||||
|
|
||||||
Error: RESOURCE_LEAK (CWE-772):
|
|
||||||
libXt-20190411/src/Event.c:743: alloc_fn: Storage is returned from allocation function "__XtMalloc".
|
|
||||||
libXt-20190411/src/Event.c:743: var_assign: Assigning: "proc" = storage returned from "__XtMalloc((Cardinal)((size_t)numprocs * 16UL))".
|
|
||||||
libXt-20190411/src/Event.c:745: var_assign: Assigning: "closure" = "proc".
|
|
||||||
libXt-20190411/src/Event.c:776: leaked_storage: Variable "closure" going out of scope leaks the storage it points to.
|
|
||||||
libXt-20190411/src/Event.c:776: leaked_storage: Variable "proc" going out of scope leaks the storage it points to.
|
|
||||||
|
|
||||||
Mixing static arrays and dynamic ones was a good idea
|
|
||||||
in the 90s when malloc was expensive, but now, we should
|
|
||||||
probably make the code clearer by just allocating the
|
|
||||||
memory when needed.
|
|
||||||
|
|
||||||
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
|
|
||||||
---
|
|
||||||
src/Event.c | 17 +++++------------
|
|
||||||
1 file changed, 5 insertions(+), 12 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/Event.c b/src/Event.c
|
|
||||||
index 11823d6..c01b65d 100644
|
|
||||||
--- a/src/Event.c
|
|
||||||
+++ b/src/Event.c
|
|
||||||
@@ -725,8 +725,6 @@ static Boolean CallEventHandlers(
|
|
||||||
register XtEventRec *p;
|
|
||||||
XtEventHandler *proc;
|
|
||||||
XtPointer *closure;
|
|
||||||
- XtEventHandler procs[EHMAXSIZE];
|
|
||||||
- XtPointer closures[EHMAXSIZE];
|
|
||||||
Boolean cont_to_disp = True;
|
|
||||||
int i, numprocs;
|
|
||||||
|
|
||||||
@@ -739,14 +737,10 @@ static Boolean CallEventHandlers(
|
|
||||||
(p->has_type_specifier && event->type == EXT_TYPE(p)))
|
|
||||||
numprocs++;
|
|
||||||
}
|
|
||||||
- if (numprocs > EHMAXSIZE) {
|
|
||||||
- proc = (XtEventHandler *)__XtMalloc(numprocs * (sizeof(XtEventHandler) +
|
|
||||||
- sizeof(XtPointer)));
|
|
||||||
- closure = (XtPointer *)(proc + numprocs);
|
|
||||||
- } else {
|
|
||||||
- proc = procs;
|
|
||||||
- closure = closures;
|
|
||||||
- }
|
|
||||||
+ proc = (XtEventHandler *)__XtMalloc(numprocs * (sizeof(XtEventHandler) +
|
|
||||||
+ sizeof(XtPointer)));
|
|
||||||
+ closure = (XtPointer *)(proc + numprocs);
|
|
||||||
+
|
|
||||||
numprocs = 0;
|
|
||||||
for (p=widget->core.event_table; p; p = p->next) {
|
|
||||||
if ((!p->has_type_specifier && (mask & p->mask)) ||
|
|
||||||
@@ -771,8 +765,7 @@ static Boolean CallEventHandlers(
|
|
||||||
*/
|
|
||||||
for (i = 0; i < numprocs && cont_to_disp; i++)
|
|
||||||
(*(proc[i]))(widget, closure[i], event, &cont_to_disp);
|
|
||||||
- if (numprocs > EHMAXSIZE)
|
|
||||||
- XtFree((char *)proc);
|
|
||||||
+ XtFree((char *)proc);
|
|
||||||
return cont_to_disp;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.19.2
|
|
||||||
|
|
Loading…
Reference in new issue