diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2019-03-17 20:59:21 -0400 |
---|---|---|
committer | Adam Jackson <ajax@nwnk.net> | 2019-04-02 19:17:16 +0000 |
commit | 91c08f4d9cb915d5f7c3074db3e72ad15ec14c01 (patch) | |
tree | 9c85da7628cae03cc71f06c2cc51fbedc31f4106 | |
parent | 4004d85df9e81fc8bcddacae15a2715ccdd6627c (diff) |
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>
-rw-r--r-- | include/X11/IntrinsicI.h | 6 | ||||
-rw-r--r-- | src/Create.c | 6 | ||||
-rw-r--r-- | src/Resources.c | 24 | ||||
-rw-r--r-- | 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 c29ca9f..67537a1 100644 --- a/src/Create.c +++ b/src/Create.c @@ -411,14 +411,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, @@ -777,7 +777,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 c71a716..29cbbf0 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 */ |