grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH]: grub: Fix handling of long printf arguments on 64-bit.


From: phcoder
Subject: Re: [PATCH]: grub: Fix handling of long printf arguments on 64-bit.
Date: Sun, 12 Apr 2009 14:46:52 +0200
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

David Miller wrote:
From: phcoder <address@hidden>
Date: Sat, 11 Apr 2009 21:10:26 +0200

I do not agree with having separate grub_itoa/grub_ltoa/grub_lltoa in
kernel where the size is critical. We should have only lltoa and use
it in all contexts.

I look forward to your patch implementing this improvement :-)



--

Regards
Vladimir 'phcoder' Serbinenko
diff --git a/ChangeLog b/ChangeLog
index 237c6f4..d701519 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-12  Vladimir Serbinenko         <address@hidden>
+
+       use grub_lltoa instead of grub_itoa and grub_ltoa for all purposes
+       
+       * kern/misc.c (grub_itoa): Removed function
+       (grub_ltoa): likewise
+       (grub_vsprintf): use grub_lltoa
+
 2009-04-12  David S. Miller  <address@hidden>
 
        * kern/misc.c (grub_ltoa): Fix cast when handling negative
diff --git a/kern/misc.c b/kern/misc.c
index 5a12535..70abb33 100644
--- a/kern/misc.c
+++ b/kern/misc.c
@@ -565,56 +565,6 @@ grub_reverse (char *str)
     }
 }
 
-static char *
-grub_itoa (char *str, int c, unsigned n)
-{
-  unsigned base = (c == 'x') ? 16 : 10;
-  char *p;
-  
-  if ((int) n < 0 && c == 'd')
-    {
-      n = (unsigned) (-((int) n));
-      *str++ = '-';
-    }
-
-  p = str;
-  do
-    {
-      unsigned d = n % base;
-      *p++ = (d > 9) ? d + 'a' - 10 : d + '0';
-    }
-  while (n /= base);
-  *p = 0;
-
-  grub_reverse (str);
-  return p;
-}
-
-static char *
-grub_ltoa (char *str, int c, unsigned long n)
-{
-  unsigned long base = (c == 'x') ? 16 : 10;
-  char *p;
-
-  if ((long) n < 0 && c == 'd')
-    {
-      n = (unsigned long) (-((long) n));
-      *str++ = '-';
-    }
-
-  p = str;
-  do
-    {
-      unsigned long d = n % base;
-      *p++ = (d > 9) ? d + 'a' - 10 : d + '0';
-    }
-  while (n /= base);
-  *p = 0;
-
-  grub_reverse (str);
-  return p;
-}
-
 /* Divide N by D, return the quotient, and store the remainder in *R.  */
 grub_uint64_t
 grub_divmod64 (grub_uint64_t n, grub_uint32_t d, grub_uint32_t *r)
@@ -818,12 +768,12 @@ grub_vsprintf (char *str, const char *fmt, va_list args)
              else if (longfmt)
                {
                  long l = va_arg (args, long);
-                 grub_ltoa (tmp, c, l);
+                 grub_lltoa (tmp, c, l);
                }
              else
                {
                  n = va_arg (args, int);
-                 grub_itoa (tmp, c, n);
+                 grub_lltoa (tmp, c, n);
                }
              if (! rightfill && grub_strlen (tmp) < format1)
                write_fill (zerofill, format1 - grub_strlen (tmp));

reply via email to

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