bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Use standard constants in boot/


From: Flávio Cruz
Subject: [PATCH] Use standard constants in boot/
Date: Tue, 26 Aug 2008 15:24:59 +0100

Hey,

This patches changes 1 and 2's into STDOUT_FILENO and STDERR_FILENO,
respectively.

Index: boot/boot.c
===================================================================
RCS file: /cvsroot/hurd/hurd/boot/boot.c,v
retrieving revision 1.109
diff -u -r1.109 boot.c
--- boot/boot.c 14 Mar 2006 23:18:34 -0000      1.109
+++ boot/boot.c 26 Aug 2008 14:21:24 -0000
@@ -216,8 +216,8 @@

   if (fd == -1)
     {
-      write (2, file, strlen (file));
-      write (2, msg, sizeof msg - 1);
+      write (STDERR_FILENO, file, strlen (file));
+      write (STDERR_FILENO, msg, sizeof msg - 1);
       task_terminate (t);
       host_exit (1);
     }
@@ -305,14 +305,14 @@
   mach_port_t memobj;
   vm_address_t region;

-  write (2, filename, strlen (filename));
+  write (STDERR_FILENO, filename, strlen (filename));
   if (fd < 0)
     {
-      write (2, msg, sizeof msg - 1);
+      write (STDERR_FILENO, msg, sizeof msg - 1);
       host_exit (1);
     }
   else
-    write (2, msg + sizeof msg - 2, 1);
+    write (STDERR_FILENO, msg + sizeof msg - 2, 1);

   host_fstat (fd, &st);

@@ -321,7 +321,7 @@
   if (err)
     {
       static const char msg[] = "cannot create default-pager object\n";
-      write (2, msg, sizeof msg - 1);
+      write (STDERR_FILENO, msg, sizeof msg - 1);
       host_exit (1);
     }

@@ -348,13 +348,13 @@
   vm_address_t startpc, str_start;
   thread_t thread;

-  write (2, path, strlen (path));
+  write (STDERR_FILENO, path, strlen (path));
   for (i = 1; i < argc; ++i)
     {
-      write (2, " ", 1);
-      write (2, argv[i], strlen (argv[i]));
+      write (STDERR_FILENO, " ", 1);
+      write (STDERR_FILENO, argv[i], strlen (argv[i]));
     }
-  write (2, "\r\n", 2);
+  write (STDERR_FILENO, "\r\n", 2);

   startpc = load_image (task, path);
   arg_len = stringlen + (argc + 2) * sizeof (char *) + sizeof (integer_t);
@@ -561,7 +561,7 @@
     {
       static const char msg[] = "error setting variable";

-      write (2, msg, strlen (msg));
+      write (STDERR_FILENO, msg, strlen (msg));
       host_exit (1);
     }

@@ -585,7 +585,7 @@
            asprintf (&msg, "cannot set boot-script variable %s: %s\n",
                      word, boot_script_error_string (err));
            assert (msg);
-           write (2, msg, strlen (msg));
+           write (STDERR_FILENO, msg, strlen (msg));
            free (msg);
            host_exit (1);
          }
@@ -602,13 +602,13 @@
     fd = open (bootscript, O_RDONLY, 0);
     if (fd < 0)
       {
-       write (2, filemsg, sizeof (filemsg));
+       write (STDERR_FILENO, filemsg, sizeof (filemsg));
        host_exit (1);
       }
     p = buf = malloc (500);
     if (!buf)
       {
-       write (2, memmsg, sizeof (memmsg));
+       write (STDERR_FILENO, memmsg, sizeof (memmsg));
        host_exit (1);
       }
     len = 500;
@@ -628,7 +628,7 @@
            newbuf = realloc (buf, len);
            if (!newbuf)
              {
-               write (2, memmsg, sizeof (memmsg));
+               write (STDERR_FILENO, memmsg, sizeof (memmsg));
                host_exit (1);
              }
            p = newbuf + (p - buf);
@@ -649,10 +649,10 @@

            str = boot_script_error_string (err);
            i = strlen (str);
-           write (2, str, i);
-           write (2, " in `", 5);
-           write (2, line, strlen (line));
-           write (2, "'\n", 2);
+           write (STDERR_FILENO, str, i);
+           write (STDERR_FILENO, " in `", 5);
+           write (STDERR_FILENO, line, strlen (line));
+           write (STDERR_FILENO, "'\n", 2);
            host_exit (1);
          }
        if (p == buf + amt)
@@ -665,7 +665,7 @@
     {
       static const char msg[] = "Pausing. . .";
       char c;
-      write (2, msg, sizeof (msg) - 1);
+      write (STDERR_FILENO, msg, sizeof (msg) - 1);
       read (0, &c, 1);
     }

@@ -682,7 +682,7 @@
        char *str = boot_script_error_string (err);
        int i = strlen (str);

-       write (2, str, i);
+       write (STDERR_FILENO, str, i);
        host_exit (1);
       }
     free (buf);
@@ -998,7 +998,7 @@
        }
 #endif

-      *bytes_written = write (1, data, datalen);
+      *bytes_written = write (STDOUT_FILENO, data, datalen);

       return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS);
     }
@@ -1035,7 +1035,7 @@
        }
 #endif

-      *bytes_written = write (1, data, datalen);
+      *bytes_written = write (STDOUT_FILENO, data, datalen);

       return (*bytes_written == -1 ? D_IO_ERROR : D_SUCCESS);
     }
@@ -1311,7 +1311,7 @@
        {
        bye:
          restore_termstate ();
-         write (2, "bye\n", 4);
+         write (STDERR_FILENO, "bye\n", 4);
          host_exit (0);
        }
       else
@@ -1375,7 +1375,7 @@
     }
 #endif

-  *amtwritten = write (1, data, datalen);
+  *amtwritten = write (STDOUT_FILENO, data, datalen);
   return *amtwritten == -1 ? errno : 0;
 }

Index: boot/ux.c
===================================================================
RCS file: /cvsroot/hurd/hurd/boot/ux.c,v
retrieving revision 1.3
diff -u -r1.3 ux.c
--- boot/ux.c   29 Apr 1996 03:54:24 -0000      1.3
+++ boot/ux.c   26 Aug 2008 14:21:24 -0000
@@ -236,7 +236,7 @@
   void flush (const char *new)
     {
       if (p > q)
-       write (1, q, p - q);
+       write (STDOUT_FILENO, q, p - q);
       q = p = new;
     }

@@ -246,7 +246,7 @@
       {
        char *str = va_arg (ap, char *);
        flush (p + 2);
-       write (1, str, strlen (str));
+       write (STDOUT_FILENO, str, strlen (str));
       }
     else if (*p == '%' && p[1] == 'd')
       {
@@ -263,7 +263,7 @@
            }

        flush (p + 2);
-       write (1, b, e - b);
+       write (STDOUT_FILENO, b, e - b);
       }
     else
       p++;

Attachment: boot-use-stdconstants.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]