Fix two warnings.

1) size_t >= 0 is always true, and trigger a warning. This is fixed
in the code because I feel such warning is useful to catch bugs.

2) extra statements from TRACE. Also fixed.

Bug: chromium:1064305
Change-Id: I487ff38f6947554fd175a19148c6f2aaaf56ed37
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19300
Commit-Queue: Zhenyao Mo <zmo@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Zhenyao Mo 2020-04-10 19:04:42 +00:00 committed by Commit Bot service account
parent 4f86505544
commit 8619cbe237
2 changed files with 21 additions and 26 deletions

View File

@ -81,15 +81,12 @@ namespace dawn_native {
// Allocate(size=8, alignment=4) will be satified by using F1. // Allocate(size=8, alignment=4) will be satified by using F1.
// Allocate(size=8, alignment=16) will be satisified by using F2. // Allocate(size=8, alignment=16) will be satisified by using F2.
// //
for (size_t currLevel = allocationBlockLevel; currLevel >= 0; currLevel--) { for (size_t ii = 0; ii <= allocationBlockLevel; ++ii) {
size_t currLevel = allocationBlockLevel - ii;
BuddyBlock* freeBlock = mFreeLists[currLevel].head; BuddyBlock* freeBlock = mFreeLists[currLevel].head;
if (freeBlock && (freeBlock->mOffset % alignment == 0)) { if (freeBlock && (freeBlock->mOffset % alignment == 0)) {
return currLevel; return currLevel;
} }
if (currLevel == 0) {
break;
}
} }
return kInvalidOffset; // No free block exists at any level. return kInvalidOffset; // No free block exists at any level.
} }

View File

@ -675,8 +675,7 @@
// event if the category is enabled. // event if the category is enabled.
#define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \ #define INTERNAL_TRACE_EVENT_ADD(platform, phase, category, name, flags, ...) \
do { \ do { \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category) \
::dawn_platform::TraceCategory::category); \
if (*INTERNALTRACEEVENTUID(catstatic)) { \ if (*INTERNALTRACEEVENTUID(catstatic)) { \
dawn_platform::TraceEvent::addTraceEvent( \ dawn_platform::TraceEvent::addTraceEvent( \
platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \ platform, phase, INTERNALTRACEEVENTUID(catstatic), name, \
@ -688,7 +687,7 @@
// event if the category is enabled. Also adds the end event when the scope // event if the category is enabled. Also adds the end event when the scope
// ends. // ends.
#define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \ #define INTERNAL_TRACE_EVENT_ADD_SCOPED(platform, category, name, ...) \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category); \ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category) \
dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \ dawn_platform::TraceEvent::TraceEndOnScopeClose INTERNALTRACEEVENTUID(profileScope); \
if (*INTERNALTRACEEVENTUID(catstatic)) { \ if (*INTERNALTRACEEVENTUID(catstatic)) { \
dawn_platform::TraceEvent::addTraceEvent( \ dawn_platform::TraceEvent::addTraceEvent( \
@ -702,8 +701,7 @@
// event if the category is enabled. // event if the category is enabled.
#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(platform, phase, category, name, id, flags, ...) \ #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(platform, phase, category, name, id, flags, ...) \
do { \ do { \
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, \ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(platform, ::dawn_platform::TraceCategory::category) \
::dawn_platform::TraceCategory::category); \
if (*INTERNALTRACEEVENTUID(catstatic)) { \ if (*INTERNALTRACEEVENTUID(catstatic)) { \
unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \ unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \
dawn_platform::TraceEvent::TraceID traceEventTraceID(id, &traceEventFlags); \ dawn_platform::TraceEvent::TraceID traceEventTraceID(id, &traceEventFlags); \