Applied Rafal Krypa's patch to fix gcc 4.3.2 build problems.
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Sep 2008 07:46:32 +0000 (07:46 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Sep 2008 07:46:32 +0000 (07:46 +0000)
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@149 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

AUTHORS [new file with mode: 0644]
src/platform-linux.cc
src/utils.cc

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..820aa04
--- /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 <email address>
+
+Google Inc.
+
+RenĂ© Rebe <rene@exactcode.de>
+Rafal Krypa <rafal@krypa.net>
index e19faad..8b643fa 100644 (file)
@@ -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
 }
 
index 48ccc31..2f1c75a 100644 (file)
@@ -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) {