From 72ba45e2749df8561fe93bafdefbdc8eca56571f Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 12 Jul 2024 02:16:47 +0200 Subject: Restrict loop variable scope in `xpm_str_to_color_key` * src/image.c (xpm_str_to_color_key): Restrict scope of loop variable. --- src/image.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/image.c b/src/image.c index 3d761bd48be..b77c12b4cbc 100644 --- a/src/image.c +++ b/src/image.c @@ -6249,9 +6249,7 @@ static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"}; static int xpm_str_to_color_key (const char *s) { - int i; - - for (i = 0; i < ARRAYELTS (xpm_color_key_strings); i++) + for (int i = 0; i < ARRAYELTS (xpm_color_key_strings); i++) if (strcmp (xpm_color_key_strings[i], s) == 0) return i; return -1; -- cgit v1.2.1 From fcb4d89aaa7bf3ed77aaa4d6d5047a0ec2ed9225 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Mon, 15 Jul 2024 15:17:16 +0200 Subject: Prefer `memcpy` to `strcpy` in image.c * src/image.c (lookup_image, xpm_cache_color) (imagemagick_create_cache): Prefer 'memcpy' to 'strcpy'. --- src/image.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/image.c b/src/image.c index b77c12b4cbc..90e6312e128 100644 --- a/src/image.c +++ b/src/image.c @@ -3525,8 +3525,9 @@ lookup_image (struct frame *f, Lisp_Object spec, int face_id) img->face_font_size = font_size; img->face_font_height = face->font->height; img->face_font_width = face->font->average_width; - img->face_font_family = xmalloc (strlen (font_family) + 1); - strcpy (img->face_font_family, font_family); + size_t len = strlen (font_family) + 1; + img->face_font_family = xmalloc (len); + memcpy (img->face_font_family, font_family, len); img->load_failed_p = ! img->type->load_img (f, img); /* If we can't load the image, and we don't have a width and @@ -5544,15 +5545,13 @@ xpm_color_bucket (char *color_name) static struct xpm_cached_color * xpm_cache_color (struct frame *f, char *color_name, XColor *color, int bucket) { - size_t nbytes; - struct xpm_cached_color *p; - if (bucket < 0) bucket = xpm_color_bucket (color_name); - nbytes = FLEXSIZEOF (struct xpm_cached_color, name, strlen (color_name) + 1); - p = xmalloc (nbytes); - strcpy (p->name, color_name); + size_t len = strlen (color_name) + 1; + size_t nbytes = FLEXSIZEOF (struct xpm_cached_color, name, len); + struct xpm_cached_color *p = xmalloc (nbytes); + memcpy (p->name, color_name, len); p->color = *color; p->next = xpm_color_cache[bucket]; xpm_color_cache[bucket] = p; @@ -10867,13 +10866,13 @@ static struct animation_cache *animation_cache = NULL; static struct animation_cache * imagemagick_create_cache (char *signature) { + size_t len = strlen (signature) + 1; struct animation_cache *cache - = xmalloc (FLEXSIZEOF (struct animation_cache, signature, - strlen (signature) + 1)); + = xmalloc (FLEXSIZEOF (struct animation_cache, signature, len)); cache->wand = 0; cache->index = 0; cache->next = 0; - strcpy (cache->signature, signature); + memcpy (cache->signature, signature, len); return cache; } -- cgit v1.2.1 From 72c8e0df87b0776451f9065f3432a8ebecee974d Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 16 Jul 2024 02:00:52 +0200 Subject: Delete commented out code from `signal_or_quit` * src/eval.c (signal_or_quit): Delete code commented out since 2001. --- src/eval.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src') diff --git a/src/eval.c b/src/eval.c index 1e0628b4aa3..2161ab1e1ea 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1857,14 +1857,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool continuable) if (gc_in_progress || waiting_for_input) emacs_abort (); -#if 0 /* rms: I don't know why this was here, - but it is surely wrong for an error that is handled. */ -#ifdef HAVE_WINDOW_SYSTEM - if (display_hourglass_p) - cancel_hourglass (); -#endif -#endif - /* This hook is used by edebug. */ if (! NILP (Vsignal_hook_function) && !oom) -- cgit v1.2.1