Skip to content

Commit

Permalink
v8: fix -Wsign-compare warning in Zone::New()
Browse files Browse the repository at this point in the history
Use unsigned types for size calculations.  Fixes a warning that was
drowning out everything else because zone-inl.h is included in every
source file:

		../deps/v8/src/zone-inl.h: In member function 'void* v8::internal::Zone::New(int)':
		../deps/v8/src/zone-inl.h:61:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
			 if (limit < position || size > limit - position) {

PR-URL: nodejs-private/node-private#62
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
bnoordhuis authored and rvagg committed Sep 27, 2016
1 parent fd8ac56 commit 88dcc7f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deps/v8/src/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 14
#define BUILD_NUMBER 5
#define PATCH_LEVEL 10
#define PATCH_LEVEL 11
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
Expand Down
10 changes: 5 additions & 5 deletions deps/v8/src/zone-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace v8 {
namespace internal {


inline void* Zone::New(int size) {
inline void* Zone::New(size_t size) {
ASSERT(scope_nesting_ > 0);
// Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignment);
Expand Down Expand Up @@ -72,7 +72,7 @@ inline void* Zone::New(int size) {


template <typename T>
T* Zone::NewArray(int length) {
T* Zone::NewArray(size_t length) {
return static_cast<T*>(New(length * sizeof(T)));
}

Expand All @@ -98,18 +98,18 @@ ZoneSplayTree<Config>::~ZoneSplayTree() {


void* ZoneObject::operator new(size_t size, Zone* zone) {
return zone->New(static_cast<int>(size));
return zone->New(size);
}

inline void* ZoneAllocationPolicy::New(size_t size) {
ASSERT(zone_);
return zone_->New(static_cast<int>(size));
return zone_->New(size);
}


template <typename T>
void* ZoneList<T>::operator new(size_t size, Zone* zone) {
return zone->New(static_cast<int>(size));
return zone->New(size);
}


Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class Zone {
~Zone() { DeleteKeptSegment(); }
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
// allocating new segments of memory on demand using malloc().
inline void* New(int size);
inline void* New(size_t size);

template <typename T>
inline T* NewArray(int length);
inline T* NewArray(size_t length);

// Deletes all objects and free all memory allocated in the Zone. Keeps one
// small (size <= kMaximumKeptSegmentSize) segment around if it finds one.
Expand Down

0 comments on commit 88dcc7f

Please sign in to comment.