summaryrefslogtreecommitdiff
path: root/xpointer.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2022-09-01 01:18:30 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2022-09-01 02:33:57 +0200
commitad338ca737c4df5a4d1c28f8ee18b878572f2964 (patch)
tree99eb6d5585da39fc9d55cd0837209f8721c47452 /xpointer.c
parentaeb69fd3575a33eb2ffded18a444d8945bcbd741 (diff)
downloadlibxml2-ad338ca737c4df5a4d1c28f8ee18b878572f2964.tar.gz
Remove explicit integer casts
Remove explicit integer casts as final operation - in assignments - when passing arguments - when returning values Remove casts - to the same type - from certain range-bound values The main motivation is that these explicit casts don't change the result of operations and only render UBSan's implicit-conversion checks useless. Removing these casts allows UBSan to detect cases where truncation or sign-changes occur unexpectedly. Document some explicit casts as truncating and add a few missing ones.
Diffstat (limited to 'xpointer.c')
-rw-r--r--xpointer.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/xpointer.c b/xpointer.c
index 71807ac8..63177f5a 100644
--- a/xpointer.c
+++ b/xpointer.c
@@ -268,7 +268,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int indx) {
xmlXPtrErrMemory("allocating point");
return(NULL);
}
- memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+ memset(ret, 0 , sizeof(xmlXPathObject));
ret->type = XPATH_POINT;
ret->user = (void *) node;
ret->index = indx;
@@ -588,7 +588,7 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
xmlXPtrErrMemory("allocating locationset");
return(NULL);
}
- memset(ret, 0 , (size_t) sizeof(xmlLocationSet));
+ memset(ret, 0 , sizeof(xmlLocationSet));
if (val != NULL) {
ret->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
sizeof(xmlXPathObjectPtr));
@@ -598,7 +598,7 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
return(NULL);
}
memset(ret->locTab, 0 ,
- XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
+ XML_RANGESET_DEFAULT * sizeof(xmlXPathObjectPtr));
ret->locMax = XML_RANGESET_DEFAULT;
ret->locTab[ret->locNr++] = val;
}
@@ -640,7 +640,7 @@ xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
return;
}
memset(cur->locTab, 0 ,
- XML_RANGESET_DEFAULT * (size_t) sizeof(xmlXPathObjectPtr));
+ XML_RANGESET_DEFAULT * sizeof(xmlXPathObjectPtr));
cur->locMax = XML_RANGESET_DEFAULT;
} else if (cur->locNr == cur->locMax) {
xmlXPathObjectPtr *temp;
@@ -773,7 +773,7 @@ xmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end) {
xmlXPtrErrMemory("allocating locationset");
return(NULL);
}
- memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+ memset(ret, 0 , sizeof(xmlXPathObject));
ret->type = XPATH_LOCATIONSET;
if (end == NULL)
ret->user = xmlXPtrLocationSetCreate(xmlXPtrNewCollapsedRange(start));
@@ -800,7 +800,7 @@ xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set) {
xmlXPtrErrMemory("allocating locationset");
return(NULL);
}
- memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+ memset(ret, 0, sizeof(xmlXPathObject));
ret->type = XPATH_LOCATIONSET;
if (set != NULL) {
int i;
@@ -836,7 +836,7 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
xmlXPtrErrMemory("allocating locationset");
return(NULL);
}
- memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
+ memset(ret, 0, sizeof(xmlXPathObject));
ret->type = XPATH_LOCATIONSET;
ret->user = (void *) val;
return(ret);