From 1dba6feed0edab6a47f1e0c791b6ed9f278470c7 Mon Sep 17 00:00:00 2001 From: "ager@chromium.org" Date: Fri, 5 Sep 2008 07:46:32 +0000 Subject: [PATCH] Applied Rafal Krypa's patch to fix gcc 4.3.2 build problems. git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@149 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- AUTHORS | 9 +++++++++ src/platform-linux.cc | 23 +++++++++++++++-------- src/utils.cc | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..820aa04402 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,9 @@ +# Below is a list of people and organizations that have contributed +# to the v8 project. Names should be added to the list like so: +# +# Name/Organization + +Google Inc. + +René Rebe +Rafal Krypa diff --git a/src/platform-linux.cc b/src/platform-linux.cc index e19faad299..8b643fa566 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -256,7 +256,11 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, void* initial) { FILE* file = fopen(name, "w+"); if (file == NULL) return NULL; - fwrite(initial, size, 1, file); + int result = fwrite(initial, size, 1, file); + if (result < 1) { + fclose(file); + return NULL; + } void* memory = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); return new PosixMemoryMappedFile(file, memory, size); @@ -285,11 +289,14 @@ void OS::LogSharedLibraryAddresses() { addr_buffer[0] = '0'; addr_buffer[1] = 'x'; addr_buffer[10] = 0; - read(fd, addr_buffer + 2, 8); + int result = read(fd, addr_buffer + 2, 8); + if (result < 8) break; unsigned start = StringToLongLong(addr_buffer); - read(fd, addr_buffer + 2, 1); - if (addr_buffer[2] != '-') return; - read(fd, addr_buffer + 2, 8); + result = read(fd, addr_buffer + 2, 1); + if (result < 1) break; + if (addr_buffer[2] != '-') break; + result = read(fd, addr_buffer + 2, 8); + if (result < 8) break; unsigned end = StringToLongLong(addr_buffer); char buffer[MAP_LENGTH]; int bytes_read = -1; @@ -297,9 +304,8 @@ void OS::LogSharedLibraryAddresses() { bytes_read++; if (bytes_read >= MAP_LENGTH - 1) break; - int result = read(fd, buffer + bytes_read, 1); - // A read error means that -1 is returned. - if (result < 1) return; + result = read(fd, buffer + bytes_read, 1); + if (result < 1) break; } while (buffer[bytes_read] != '\n'); buffer[bytes_read] = 0; // There are 56 chars to ignore at this point in the line. @@ -309,6 +315,7 @@ void OS::LogSharedLibraryAddresses() { buffer[bytes_read] = 0; LOG(SharedLibraryEvent(buffer + 56, start, end)); } + close(fd); #endif } diff --git a/src/utils.cc b/src/utils.cc index 48ccc311f5..2f1c75a248 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -104,7 +104,7 @@ char* ReadLine(const char* prompt) { char line_buf[256]; int offset = 0; bool keep_going = true; - fprintf(stdout, prompt); + fprintf(stdout, "%s", prompt); fflush(stdout); while (keep_going) { if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) {