|
|
cf0dd1 |
From 15ce56425b5e5b89486481fdf7a8b077639f3c78 Mon Sep 17 00:00:00 2001
|
|
|
cf0dd1 |
From: "Thomas E. Dickey" <dickey@invisible-island.net>
|
|
|
cf0dd1 |
Date: Sun, 17 Mar 2019 20:59:21 -0400
|
|
|
cf0dd1 |
Subject: [PATCH 6/9] Use standard size_t type in the casts for
|
|
|
cf0dd1 |
length-parameter of memcpy, memmove and bzero. When the library was written
|
|
|
cf0dd1 |
(1989), none of those had been standardized, and the source-code used "(int)"
|
|
|
cf0dd1 |
casts to help with K&R compilers. The cleanup done in the previous update
|
|
|
cf0dd1 |
used binary-compare to validate, which does not work for these because the
|
|
|
cf0dd1 |
compiler is recording the cast's effect.
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
This change reduces the number of gcc warnings from 163 to 128.
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
|
|
|
cf0dd1 |
---
|
|
|
cf0dd1 |
include/X11/IntrinsicI.h | 6 +++---
|
|
|
cf0dd1 |
src/Create.c | 6 +++---
|
|
|
cf0dd1 |
src/Resources.c | 24 ++++++++++++------------
|
|
|
cf0dd1 |
src/SetValues.c | 8 ++++----
|
|
|
cf0dd1 |
4 files changed, 22 insertions(+), 22 deletions(-)
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
diff --git a/include/X11/IntrinsicI.h b/include/X11/IntrinsicI.h
|
|
|
cf0dd1 |
index 6e2396b..c028701 100644
|
|
|
cf0dd1 |
--- a/include/X11/IntrinsicI.h
|
|
|
cf0dd1 |
+++ b/include/X11/IntrinsicI.h
|
|
|
cf0dd1 |
@@ -110,14 +110,14 @@ SOFTWARE.
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
#define XtMemmove(dst, src, size) \
|
|
|
cf0dd1 |
if ((char *)(dst) != (char *)(src)) { \
|
|
|
cf0dd1 |
- (void) memcpy((char *) (dst), (char *) (src), (int) (size)); \
|
|
|
cf0dd1 |
+ (void) memcpy((char *) (dst), (char *) (src), (size_t) (size)); \
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
#define XtBZero(dst, size) \
|
|
|
cf0dd1 |
- bzero((char *) (dst), (int) (size))
|
|
|
cf0dd1 |
+ bzero((char *) (dst), (size_t) (size))
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
#define XtMemcmp(b1, b2, size) \
|
|
|
cf0dd1 |
- memcmp((char *) (b1), (char *) (b2), (int) (size))
|
|
|
cf0dd1 |
+ memcmp((char *) (b1), (char *) (b2), (size_t) (size))
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/****************************************************************
|
|
|
cf0dd1 |
diff --git a/src/Create.c b/src/Create.c
|
|
|
cf0dd1 |
index da00192..bbea9ce 100644
|
|
|
cf0dd1 |
--- a/src/Create.c
|
|
|
cf0dd1 |
+++ b/src/Create.c
|
|
|
cf0dd1 |
@@ -412,14 +412,14 @@ xtCreate(
|
|
|
cf0dd1 |
wsize = widget_class->core_class.widget_size;
|
|
|
cf0dd1 |
csize = 0;
|
|
|
cf0dd1 |
req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
|
|
|
cf0dd1 |
- (void) memmove ((char *) req_widget, (char *) widget, (int) wsize);
|
|
|
cf0dd1 |
+ (void) memmove ((char *) req_widget, (char *) widget, (size_t) wsize);
|
|
|
cf0dd1 |
CallInitialize (XtClass(widget), req_widget, widget, args, num_args);
|
|
|
cf0dd1 |
if (parent_constraint_class != NULL) {
|
|
|
cf0dd1 |
csize = parent_constraint_class->constraint_class.constraint_size;
|
|
|
cf0dd1 |
if (csize) {
|
|
|
cf0dd1 |
req_constraints = XtStackAlloc(csize, constraint_cache);
|
|
|
cf0dd1 |
(void) memmove((char*)req_constraints, widget->core.constraints,
|
|
|
cf0dd1 |
- (int)csize);
|
|
|
cf0dd1 |
+ (size_t)csize);
|
|
|
cf0dd1 |
req_widget->core.constraints = req_constraints;
|
|
|
cf0dd1 |
} else req_widget->core.constraints = NULL;
|
|
|
cf0dd1 |
CallConstraintInitialize(parent_constraint_class, req_widget, widget,
|
|
|
cf0dd1 |
@@ -778,7 +778,7 @@ _XtCreateHookObj(Screen* screen)
|
|
|
cf0dd1 |
CompileCallbacks(hookobj);
|
|
|
cf0dd1 |
wsize = hookObjectClass->core_class.widget_size;
|
|
|
cf0dd1 |
req_widget = (Widget) XtStackAlloc(wsize, widget_cache);
|
|
|
cf0dd1 |
- (void) memmove ((char *) req_widget, (char *) hookobj, (int) wsize);
|
|
|
cf0dd1 |
+ (void) memmove ((char *) req_widget, (char *) hookobj, (size_t) wsize);
|
|
|
cf0dd1 |
CallInitialize (hookObjectClass, req_widget, hookobj,
|
|
|
cf0dd1 |
(ArgList)NULL, (Cardinal) 0);
|
|
|
cf0dd1 |
XtStackFree((XtPointer)req_widget, widget_cache);
|
|
|
cf0dd1 |
diff --git a/src/Resources.c b/src/Resources.c
|
|
|
cf0dd1 |
index 9e0f065..456da7a 100644
|
|
|
cf0dd1 |
--- a/src/Resources.c
|
|
|
cf0dd1 |
+++ b/src/Resources.c
|
|
|
cf0dd1 |
@@ -110,7 +110,7 @@ void _XtCopyFromArg(
|
|
|
cf0dd1 |
register unsigned int size)
|
|
|
cf0dd1 |
{
|
|
|
cf0dd1 |
if (size > sizeof(XtArgVal))
|
|
|
cf0dd1 |
- (void) memmove((char *) dst, (char *) src, (int) size);
|
|
|
cf0dd1 |
+ (void) memmove((char *) dst, (char *) src, (size_t) size);
|
|
|
cf0dd1 |
else {
|
|
|
cf0dd1 |
union {
|
|
|
cf0dd1 |
long longval;
|
|
|
cf0dd1 |
@@ -133,7 +133,7 @@ void _XtCopyFromArg(
|
|
|
cf0dd1 |
else if (size == sizeof(char*)) u.charptr = (char*)src;
|
|
|
cf0dd1 |
else p = (char*)&src;
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
- (void) memmove(dst, p, (int) size);
|
|
|
cf0dd1 |
+ (void) memmove(dst, p, (size_t) size);
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
} /* _XtCopyFromArg */
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
@@ -158,7 +158,7 @@ void _XtCopyToArg(
|
|
|
cf0dd1 |
XtPointer ptr;
|
|
|
cf0dd1 |
} u;
|
|
|
cf0dd1 |
if (size <= sizeof(XtArgVal)) {
|
|
|
cf0dd1 |
- (void) memmove((char*)&u, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)&u, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
|
|
|
cf0dd1 |
#ifdef LONG64
|
|
|
cf0dd1 |
else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
|
|
|
cf0dd1 |
@@ -167,10 +167,10 @@ void _XtCopyToArg(
|
|
|
cf0dd1 |
else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
|
|
|
cf0dd1 |
else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
|
|
|
cf0dd1 |
else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
|
|
|
cf0dd1 |
- else (void) memmove((char*)dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ else (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
else
|
|
|
cf0dd1 |
- (void) memmove((char*)dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
#else
|
|
|
cf0dd1 |
XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError,
|
|
|
cf0dd1 |
"NULL ArgVal in XtGetValues", (String*) NULL, (Cardinal*) NULL);
|
|
|
cf0dd1 |
@@ -178,7 +178,7 @@ void _XtCopyToArg(
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
else {
|
|
|
cf0dd1 |
/* proper GetValues semantics: argval is pointer to destination */
|
|
|
cf0dd1 |
- (void) memmove((char*)*dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)*dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
} /* _XtCopyToArg */
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
@@ -202,7 +202,7 @@ static void CopyToArg(
|
|
|
cf0dd1 |
XtPointer ptr;
|
|
|
cf0dd1 |
} u;
|
|
|
cf0dd1 |
if (size <= sizeof(XtArgVal)) {
|
|
|
cf0dd1 |
- (void) memmove((char*)&u, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)&u, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
if (size == sizeof(long)) *dst = (XtArgVal)u.longval;
|
|
|
cf0dd1 |
#ifdef LONG64
|
|
|
cf0dd1 |
else if (size == sizeof(int)) *dst = (XtArgVal)u.intval;
|
|
|
cf0dd1 |
@@ -211,14 +211,14 @@ static void CopyToArg(
|
|
|
cf0dd1 |
else if (size == sizeof(char)) *dst = (XtArgVal)u.charval;
|
|
|
cf0dd1 |
else if (size == sizeof(char*)) *dst = (XtArgVal)u.charptr;
|
|
|
cf0dd1 |
else if (size == sizeof(XtPointer)) *dst = (XtArgVal)u.ptr;
|
|
|
cf0dd1 |
- else (void) memmove((char*)dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ else (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
else
|
|
|
cf0dd1 |
- (void) memmove((char*)dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
else {
|
|
|
cf0dd1 |
/* proper GetValues semantics: argval is pointer to destination */
|
|
|
cf0dd1 |
- (void) memmove((char*)*dst, (char*)src, (int)size );
|
|
|
cf0dd1 |
+ (void) memmove((char*)*dst, (char*)src, (size_t)size );
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
} /* CopyToArg */
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
@@ -519,8 +519,8 @@ static XtCacheRef *GetResources(
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/* Mark each resource as not found on arg list */
|
|
|
cf0dd1 |
- bzero((char *) found, (int) (num_resources * sizeof(Boolean)));
|
|
|
cf0dd1 |
- bzero((char *) typed, (int) (num_resources * sizeof(int)));
|
|
|
cf0dd1 |
+ bzero((char *) found, (size_t) (num_resources * sizeof(Boolean)));
|
|
|
cf0dd1 |
+ bzero((char *) typed, (size_t) (num_resources * sizeof(int)));
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/* Copy the args into the resources, mark each as found */
|
|
|
cf0dd1 |
{
|
|
|
cf0dd1 |
diff --git a/src/SetValues.c b/src/SetValues.c
|
|
|
cf0dd1 |
index e432ec7..f274000 100644
|
|
|
cf0dd1 |
--- a/src/SetValues.c
|
|
|
cf0dd1 |
+++ b/src/SetValues.c
|
|
|
cf0dd1 |
@@ -224,7 +224,7 @@ void XtSetValues(
|
|
|
cf0dd1 |
UNLOCK_PROCESS;
|
|
|
cf0dd1 |
oldw = (Widget) XtStackAlloc(widgetSize, oldwCache);
|
|
|
cf0dd1 |
reqw = (Widget) XtStackAlloc (widgetSize, reqwCache);
|
|
|
cf0dd1 |
- (void) memmove((char *) oldw, (char *) w, (int) widgetSize);
|
|
|
cf0dd1 |
+ (void) memmove((char *) oldw, (char *) w, (size_t) widgetSize);
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/* Set resource values */
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
@@ -233,7 +233,7 @@ void XtSetValues(
|
|
|
cf0dd1 |
wc->core_class.num_resources, args, num_args);
|
|
|
cf0dd1 |
UNLOCK_PROCESS;
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
- (void) memmove ((char *) reqw, (char *) w, (int) widgetSize);
|
|
|
cf0dd1 |
+ (void) memmove ((char *) reqw, (char *) w, (size_t) widgetSize);
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
hasConstraints = (XtParent(w) != NULL && !XtIsShell(w) && XtIsConstraint(XtParent(w)));
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
@@ -253,7 +253,7 @@ void XtSetValues(
|
|
|
cf0dd1 |
oldw->core.constraints = XtStackAlloc(constraintSize, oldcCache);
|
|
|
cf0dd1 |
reqw->core.constraints = XtStackAlloc(constraintSize, reqcCache);
|
|
|
cf0dd1 |
(void) memmove((char *) oldw->core.constraints,
|
|
|
cf0dd1 |
- (char *) w->core.constraints, (int) constraintSize);
|
|
|
cf0dd1 |
+ (char *) w->core.constraints, (size_t) constraintSize);
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/* Set constraint values */
|
|
|
cf0dd1 |
LOCK_PROCESS;
|
|
|
cf0dd1 |
@@ -262,7 +262,7 @@ void XtSetValues(
|
|
|
cf0dd1 |
cwc->constraint_class.num_resources, args, num_args);
|
|
|
cf0dd1 |
UNLOCK_PROCESS;
|
|
|
cf0dd1 |
(void) memmove((char *) reqw->core.constraints,
|
|
|
cf0dd1 |
- (char *) w->core.constraints, (int) constraintSize);
|
|
|
cf0dd1 |
+ (char *) w->core.constraints, (size_t) constraintSize);
|
|
|
cf0dd1 |
}
|
|
|
cf0dd1 |
|
|
|
cf0dd1 |
/* Inform widget of changes, then inform parent of changes */
|
|
|
cf0dd1 |
--
|
|
|
cf0dd1 |
2.19.2
|
|
|
cf0dd1 |
|