Add (void*) casts to memcpy/memset invocations to appease GCC 8.

A lot of these classes are not *technically* "trivially copyable"
for one reason or another, but in all of these cases it seems
OK to me to use memcpy/memset on them. Adding a cast to void*
tells GCC that "I know what I'm doing here" and shuts up the
warning.
This commit is contained in:
Augustin Cavalier 2019-05-24 14:21:37 -04:00
parent 38b015579f
commit 1705656eac
10 changed files with 116 additions and 115 deletions

View File

@ -554,7 +554,7 @@ namespace agg
if(sl_len)
{
memset(mix_buffer + sl_start - min_x,
memset((void*)(mix_buffer + sl_start - min_x),
0,
sl_len * sizeof(color_type));

View File

@ -72,7 +72,7 @@ struct ValuePieceLocation {
bool Copy(const ValuePieceLocation& other)
{
memcpy(this, &other, sizeof(ValuePieceLocation));
memcpy((void*)this, (void*)&other, sizeof(ValuePieceLocation));
if (type == VALUE_PIECE_LOCATION_IMPLICIT) {
void* tempValue = malloc(size);
if (tempValue == NULL) {

View File

@ -69,14 +69,15 @@ _BTextViewSupportBuffer_<T>::InsertItemsAt(int32 inNumItems,
int32 logSize = fItemCount * sizeof(T);
if ((logSize + delta) >= fBufferCount) {
fBufferCount = logSize + delta + (fExtraCount * sizeof(T));
fBuffer = (T*)realloc(fBuffer, fBufferCount);
fBuffer = (T*)realloc((void*)fBuffer, fBufferCount);
if (fBuffer == NULL)
debugger("InsertItemsAt(): reallocation failed");
}
T* loc = fBuffer + inAtIndex;
memmove(loc + inNumItems, loc, (fItemCount - inAtIndex) * sizeof(T));
memcpy(loc, inItem, delta);
memmove((void*)(loc + inNumItems), (void*)loc,
(fItemCount - inAtIndex) * sizeof(T));
memcpy((void*)loc, (void*)inItem, delta);
fItemCount += inNumItems;
}

View File

@ -198,11 +198,11 @@ SavePalette::SavePalette(int mode)
{
if (IsValid()) {
if (fMode == WEB_SAFE_PALETTE) {
memcpy(pal, wsp, sizeof(rgb_color) * 256);
memcpy((void*)pal, wsp, sizeof(rgb_color) * 256);
fSize = 216;
} else if (fMode == BEOS_SYSTEM_PALETTE) {
color_map* map = (color_map*)system_colors();
memcpy(pal, map->color_list, sizeof(rgb_color) * 256);
memcpy((void*)pal, map->color_list, sizeof(rgb_color) * 256);
fSize = 256;
} else if (fMode == GREYSCALE_PALETTE) {
for (int i = 0; i < 256; i++) {

View File

@ -57,7 +57,7 @@ TransformPointsBox::TransformPointsBox(CanvasView* view,
fPoints[i].point_out.x, fPoints[i].point_out.y);
bounds = bounds | dummy;
} else {
memset(&fPoints[i], 0, sizeof(control_point));
memset((void*)&fPoints[i], 0, sizeof(control_point));
}
}
}

View File

@ -353,7 +353,7 @@ BVariant::_SetTo(const BVariant& other)
other.fReferenceable->AcquireReference();
}
memcpy(this, &other, sizeof(BVariant));
memcpy((void*)this, (void*)&other, sizeof(BVariant));
}

View File

@ -474,7 +474,7 @@ OpenHashElementArray<Element>::Add()
memcpy(newData, fData, fSize * sizeof(Element));
free(fData);
*/
Element *newData = (Element*)realloc(fData,
Element *newData = (Element*)realloc((void*)fData,
(size_t)newSize * sizeof(Element));
if (!newData)
return NULL;

View File

@ -788,7 +788,7 @@ BPoseView::SavePoseLocations(BRect* frameIfDesktop)
extendedPoseInfo = (ExtendedPoseInfo*)
new char [size];
memset(extendedPoseInfo, 0, size);
memset((void*)extendedPoseInfo, 0, size);
extendedPoseInfo->fWorkspaces = 0xffffffff;
extendedPoseInfo->fInvisible = false;
extendedPoseInfo->fShowFromBootOnly = false;

View File

@ -145,7 +145,7 @@ VectorPath::VectorPath(BMessage* archive)
if (archive->GetInfo("point", &typeFound, &countFound) >= B_OK
&& typeFound == B_POINT_TYPE
&& _SetPointCount(countFound)) {
memset(fPath, 0, fAllocCount * sizeof(control_point));
memset((void*)fPath, 0, fAllocCount * sizeof(control_point));
BPoint point;
BPoint pointIn;
@ -1073,7 +1073,7 @@ VectorPath::_SetPointCount(int32 count)
fPath = obj_new(control_point, fAllocCount);
if (fPath != NULL) {
memset(fPath + fPointCount, 0,
memset((void*)(fPath + fPointCount), 0,
(fAllocCount - fPointCount) * sizeof(control_point));
}
}

View File

@ -842,7 +842,7 @@ KeyboardLayout::_InitFrom(const char* data)
state.mode = kKeyShape;
break;
case kKeyShape:
memset(&key, 0, sizeof(Key));
memset((void*)&key, 0, sizeof(Key));
if (!_GetShape(state, term.String(), key))
return B_BAD_VALUE;