From 9790a7b36b7704f6f490368778bff16302bb7cb6 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Mon, 5 Jan 2015 12:29:15 -0800 Subject: Cap id size returned by GrScratchKey::GenerateResourceType kkinnunen@ has been seeing compiler warnings on GrScratchKey::GenerateResourceType (https://codereview.chromium.org/833913002/ - Cast the scratch resource key in order to fix a warning)(presumably due to the unsigned/signed comparison in kInvalidResourceType == type). This CL limits the returned id to its effective range to, hopefully, clarify the whole int32_t -> uint32_t conversion & wrapping problem. Review URL: https://codereview.chromium.org/827923006 --- src/gpu/GrResourceCache2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gpu/GrResourceCache2.cpp') diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp index ccfe382733..1db96ec1cc 100644 --- a/src/gpu/GrResourceCache2.cpp +++ b/src/gpu/GrResourceCache2.cpp @@ -22,7 +22,7 @@ GrScratchKey::ResourceType GrScratchKey::GenerateResourceType() { static int32_t gType = kInvalidResourceType + 1; int32_t type = sk_atomic_inc(&gType); - if (kInvalidResourceType == type) { + if (type > SK_MaxU16) { SkFAIL("Too many Resource Types"); } -- cgit v1.2.3