]> git.proxmox.com Git - grub2.git/commitdiff
* include/grub/misc.h (grub_strcat): Removed. All users changed to
authorVladimir Serbinenko <phcoder@gmail.com>
Fri, 1 Nov 2013 15:27:37 +0000 (16:27 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Fri, 1 Nov 2013 15:27:37 +0000 (16:27 +0100)
more appropriate functions.

ChangeLog
grub-core/fs/archelp.c
grub-core/gfxmenu/icon_manager.c
grub-core/lib/posix_wrap/string.h
grub-core/normal/completion.c
include/grub/misc.h

index 7c3b98f63356467d8eae6f7b0ff32a44273a62d9..05282bd03261509597a712df2493144bb6fc7aba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-01  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * include/grub/misc.h (grub_strcat): Removed. All users changed to
+       more appropriate functions.
+
 2013-11-01  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/kern/efi/efi.c (grub_efi_get_filename): Avoid inefficient
index 4a7ace117857f4078137605615e98a22766a4578..c85cbfac29ebbdce8938e6dbb62930cb9f3ef00b 100644 (file)
@@ -67,6 +67,7 @@ handle_symlink (struct grub_archelp_data *data,
   grub_size_t prefixlen;
   char *rest;
   char *linktarget;
+  grub_size_t linktarget_len;
 
   *restart = 0;
 
@@ -96,7 +97,8 @@ handle_symlink (struct grub_archelp_data *data,
     return grub_errno;
   if (linktarget[0] == '\0')
     return GRUB_ERR_NONE;
-  target = grub_malloc (grub_strlen (linktarget) + grub_strlen (*name) + 2);
+  linktarget_len = grub_strlen (linktarget);
+  target = grub_malloc (linktarget_len + grub_strlen (*name) + 2);
   if (!target)
     return grub_errno;
 
@@ -121,7 +123,7 @@ handle_symlink (struct grub_archelp_data *data,
       grub_memcpy (target, *name, prefixlen);
       target[prefixlen-1] = '/';
     }
-  grub_strcat (target, rest);
+  grub_strcpy (target + prefixlen + linktarget_len, rest);
   grub_dprintf ("archelp", "symlink redirected %s to %s\n",
                *name, target);
   grub_free (*name);
index 45e8f7dea129eb4b2799bf0abcf529d7dff4d5ef..ff49ab0e0f62f8cd8347e24b50cb3be384b34154 100644 (file)
@@ -137,23 +137,19 @@ static struct grub_video_bitmap *
 try_loading_icon (grub_gfxmenu_icon_manager_t mgr,
                   const char *dir, const char *class_name)
 {
-  char *path;
-  int l;
+  char *path, *ptr;
 
   path = grub_malloc (grub_strlen (dir) + grub_strlen (class_name)
                      + grub_strlen (icon_extension) + 3);
   if (! path)
     return 0;
 
-  grub_strcpy (path, dir);
-  l = grub_strlen (path);
-  if (path[l-1] != '/')
-    {
-      path[l] = '/';
-      path[l+1] = 0;
-    }
-  grub_strcat (path, class_name);
-  grub_strcat (path, icon_extension);
+  ptr = grub_stpcpy (path, dir);
+  if (path == ptr || ptr[-1] != '/')
+    *ptr++ = '/';
+  ptr = grub_stpcpy (ptr, class_name);
+  ptr = grub_stpcpy (ptr, icon_extension);
+  *ptr = '\0';
 
   struct grub_video_bitmap *raw_bitmap;
   grub_video_bitmap_load (&raw_bitmap, path);
index b508a51117e04eedfcd9b02cfa88a36dac7bdc5b..c4b9bf089e5e9f907f49338805f580149e65c902 100644 (file)
@@ -87,12 +87,6 @@ strncpy (char *dest, const char *src, grub_size_t n)
   return grub_strncpy (dest, src, n);
 }
 
-static inline char *
-strcat (char *dest, const char *src)
-{
-  return grub_strcat (dest, src);
-}
-
 static inline int
 strcoll (const char *s1, const char *s2)
 {
index 19b5410ccc575d98ef3231e50c66fda2ae41c841..2c9b9e9312a3d4de38fe9252ddb88709d5b271d3 100644 (file)
@@ -500,7 +500,7 @@ grub_normal_do_completion (char *buf, int *restore,
       *newstr = '\0';
 
       if (num_found == 1)
-       grub_strcat (ret, suffix);
+       grub_strcpy (newstr, suffix);
 
       if (*ret == '\0')
        {
index ed672fdf4eafc7f00a86de010dc75484327d761f..507811e68620480223d3daf7f3a274285b22ed5f 100644 (file)
@@ -87,23 +87,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n)
   return grub_memmove (dest, src, n);
 }
 
-static inline char *
-grub_strcat (char *dest, const char *src)
-{
-  char *p = dest;
-
-  while (*p)
-    p++;
-
-  while ((*p = *src) != '\0')
-    {
-      p++;
-      src++;
-    }
-
-  return dest;
-}
-
 /* Prototypes for aliases.  */
 #ifndef GRUB_UTIL
 #ifdef __APPLE__