From e54b8f536be47253a2874b6e7dda012718d9b3eb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 1 Nov 2013 16:27:37 +0100 Subject: [PATCH] * include/grub/misc.h (grub_strcat): Removed. All users changed to more appropriate functions. --- ChangeLog | 5 +++++ grub-core/fs/archelp.c | 6 ++++-- grub-core/gfxmenu/icon_manager.c | 18 +++++++----------- grub-core/lib/posix_wrap/string.h | 6 ------ grub-core/normal/completion.c | 2 +- include/grub/misc.h | 17 ----------------- 6 files changed, 17 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c3b98f63..05282bd03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-11-01 Vladimir Serbinenko + + * include/grub/misc.h (grub_strcat): Removed. All users changed to + more appropriate functions. + 2013-11-01 Vladimir Serbinenko * grub-core/kern/efi/efi.c (grub_efi_get_filename): Avoid inefficient diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index 4a7ace117..c85cbfac2 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -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); diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c index 45e8f7dea..ff49ab0e0 100644 --- a/grub-core/gfxmenu/icon_manager.c +++ b/grub-core/gfxmenu/icon_manager.c @@ -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); diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h index b508a5111..c4b9bf089 100644 --- a/grub-core/lib/posix_wrap/string.h +++ b/grub-core/lib/posix_wrap/string.h @@ -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) { diff --git a/grub-core/normal/completion.c b/grub-core/normal/completion.c index 19b5410cc..2c9b9e931 100644 --- a/grub-core/normal/completion.c +++ b/grub-core/normal/completion.c @@ -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') { diff --git a/include/grub/misc.h b/include/grub/misc.h index ed672fdf4..507811e68 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -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__