All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Pelletier <subdino2004@yahoo.fr>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] use grub_size_t instead of int in kern/misc.c
Date: Sat, 02 Jul 2005 19:35:03 +0200	[thread overview]
Message-ID: <42C6D047.5050308@yahoo.fr> (raw)
In-Reply-To: <42C2B09C.1050007@yahoo.fr>

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

New version of the patch, made after a discussion with Okuji on irc.
The ftoa changes in previous version of this patch might be done later,
if someone confirms they are ok.

2005-07-02  Vincent Pelletier  <subdino2004@yahoo.fr>

    * kern/misc.c
      (grub_strncpy, grub_strncat, grub_strncmp, grub_strncasecmp):
      Changed argument type from int to grub_size_t.
      (grub_printf, grub_vprintf, grub_vsprintf, grub_sprintf): Changed
      return type from int to grub_size_t.
      (grub_strncasecmp): Make return value to also ignore case when we
      reach the end of one string.
    * include/grub/mish.h
      (grub_strncpy, grub_strncat, grub_strncmp,
      grub_strncasecmp, grub_printf, grub_vprintf, grub_sprintf,
      grub_vsprintf): Updated prototypes to match changes in
      kern/misc.c.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCxtBHFEQoKRQyjtURAsq3AKCTag1s0aqOATkdK54LYJ/K+ZQY2gCfeljo
Hiim/wgZjTV6Og9HTwMjItQ=
=UWpE
-----END PGP SIGNATURE-----

[-- Attachment #2: misc.diff --]
[-- Type: text/plain, Size: 5634 bytes --]

Index: kern/misc.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/misc.c,v
retrieving revision 1.20
diff -u -p -r1.20 misc.c
--- kern/misc.c	23 Jun 2005 23:13:57 -0000	1.20
+++ kern/misc.c	2 Jul 2005 17:29:05 -0000
@@ -63,7 +63,7 @@ grub_strcpy (char *dest, const char *src
 }
 
 char *
-grub_strncpy (char *dest, const char *src, int c)
+grub_strncpy (char *dest, const char *src, grub_size_t c)
 {
   char *p = dest;
   
@@ -101,7 +101,7 @@ grub_strcat (char *dest, const char *src
 }
 
 char *
-grub_strncat (char *dest, const char *src, int c)
+grub_strncat (char *dest, const char *src, grub_size_t c)
 {
   char *p = dest;
 
@@ -115,11 +115,11 @@ grub_strncat (char *dest, const char *sr
   return dest;
 }
 
-int
+grub_size_t
 grub_printf (const char *fmt, ...)
 {
   va_list ap;
-  int ret;
+  grub_size_t ret;
   
   va_start (ap, fmt);
   ret = grub_vprintf (fmt, ap);
@@ -145,10 +145,10 @@ grub_real_dprintf(const char *file, cons
     }
 }
 
-int
+grub_size_t
 grub_vprintf (const char *fmt, va_list args)
 {
-  int ret;
+  grub_size_t ret;
 
   ret = grub_vsprintf (0, fmt, args);
   grub_refresh ();
@@ -191,9 +191,9 @@ grub_strcmp (const char *s1, const char 
 }
 
 int
-grub_strncmp (const char *s1, const char *s2, int c)
+grub_strncmp (const char *s1, const char *s2, grub_size_t c)
 {
-  int p = 1;
+  grub_size_t p = 1;
 
   while (*s1 && *s2 && p < c)
     {
@@ -209,9 +209,9 @@ grub_strncmp (const char *s1, const char
 }
 
 int
-grub_strncasecmp (const char *s1, const char *s2, int c)
+grub_strncasecmp (const char *s1, const char *s2, grub_size_t c)
 {
-  int p = 1;
+  grub_size_t p = 1;
 
   while (grub_tolower (*s1) && grub_tolower (*s2) && p < c)
     {
@@ -223,7 +223,7 @@ grub_strncasecmp (const char *s1, const 
       p++;
     }
 
-  return (int) *s1 - (int) *s2;
+  return (int) grub_tolower (*s1) - (int) grub_tolower (*s2);
 }
 
 char *
@@ -517,11 +517,11 @@ grub_ftoa (char *str, double f, int roun
   return str;
 }
 
-int
+grub_size_t
 grub_vsprintf (char *str, const char *fmt, va_list args)
 {
   char c;
-  int count = 0;
+  grub_size_t count = 0;
   auto void write_char (unsigned char ch);
   auto void write_str (const char *s);
   auto void write_fill (const char ch, int n);
@@ -729,11 +729,11 @@ grub_vsprintf (char *str, const char *fm
   return count;
 }
 
-int
+grub_size_t
 grub_sprintf (char *str, const char *fmt, ...)
 {
   va_list ap;
-  int ret;
+  grub_size_t ret;
   
   va_start (ap, fmt);
   ret = grub_vsprintf (str, fmt, ap);
Index: include/grub/misc.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/misc.h,v
retrieving revision 1.13
diff -u -p -r1.13 misc.h
--- include/grub/misc.h	9 May 2005 01:47:37 -0000	1.13
+++ include/grub/misc.h	2 Jul 2005 17:29:05 -0000
@@ -32,10 +32,10 @@
 
 void *EXPORT_FUNC(grub_memmove) (void *dest, const void *src, grub_size_t n);
 char *EXPORT_FUNC(grub_strcpy) (char *dest, const char *src);
-char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, int c);
+char *EXPORT_FUNC(grub_strncpy) (char *dest, const char *src, grub_size_t c);
 char *EXPORT_FUNC(grub_stpcpy) (char *dest, const char *src);
 char *EXPORT_FUNC(grub_strcat) (char *dest, const char *src);
-char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, int c);
+char *EXPORT_FUNC(grub_strncat) (char *dest, const char *src, grub_size_t c);
 
 /* Prototypes for aliases.  */
 void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n);
@@ -43,8 +43,8 @@ void *EXPORT_FUNC(memcpy) (void *dest, c
 
 int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n);
 int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2);
-int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, int c);
-int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, int c);
+int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t c);
+int EXPORT_FUNC(grub_strncasecmp) (const char *s1, const char *s2, grub_size_t c);
 char *EXPORT_FUNC(grub_strchr) (const char *s, int c);
 char *EXPORT_FUNC(grub_strrchr) (const char *s, int c);
 int EXPORT_FUNC(grub_strword) (const char *s, const char *w);
@@ -60,14 +60,14 @@ char *EXPORT_FUNC(grub_strdup) (const ch
 char *EXPORT_FUNC(grub_strndup) (const char *s, grub_size_t n);
 void *EXPORT_FUNC(grub_memset) (void *s, int c, grub_size_t n);
 grub_size_t EXPORT_FUNC(grub_strlen) (const char *s);
-int EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+grub_size_t EXPORT_FUNC(grub_printf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
 void EXPORT_FUNC(grub_real_dprintf) (const char *file,
                                      const int line,
                                      const char *condition,
                                      const char *fmt, ...) __attribute__ ((format (printf, 4, 5)));
-int EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
-int EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
-int EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
+grub_size_t EXPORT_FUNC(grub_vprintf) (const char *fmt, va_list args);
+grub_size_t EXPORT_FUNC(grub_sprintf) (char *str, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+grub_size_t EXPORT_FUNC(grub_vsprintf) (char *str, const char *fmt, va_list args);
 void EXPORT_FUNC(grub_stop) (void) __attribute__ ((noreturn));
 grub_uint8_t *EXPORT_FUNC(grub_utf16_to_utf8) (grub_uint8_t *dest,
 					       grub_uint16_t *src,

      parent reply	other threads:[~2005-07-02 18:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-29 14:30 [PATCH 1/2] Various cleanups in kern/misc.c Vincent Pelletier
2005-06-30 11:21 ` Rodrigo Steinmüller Wanderley
2005-06-30 11:51   ` Rodrigo Steinmüller Wanderley
2005-07-02 17:35 ` Vincent Pelletier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42C6D047.5050308@yahoo.fr \
    --to=subdino2004@yahoo.fr \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.