Stifle GCC false positive

When deserializing SkRRects we copy the raw data then recreate a little
more analysis stored at the end of the struct that is not serialized.

GCC worries we've not copied enough, but we have.  We can stifle the
warning by casting the pointer to void* before calling memcpy().

Change-Id: I3ae0007927611d4fc84ced8d12f62e0fa23ee3ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/258267
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Mike Klein 2019-12-05 11:07:55 -06:00 committed by Skia Commit-Bot
parent 9b849047b8
commit 1713fcc5b4

View File

@ -553,8 +553,10 @@ size_t SkRRect::readFromMemory(const void* buffer, size_t length) {
return 0;
}
// The extra (void*) tells GCC not to worry that kSizeInMemory < sizeof(SkRRect).
SkRRect raw;
memcpy(&raw, buffer, kSizeInMemory);
memcpy((void*)&raw, buffer, kSizeInMemory);
this->setRectRadii(raw.fRect, raw.fRadii);
return kSizeInMemory;
}