all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#45562: [PATCH] Fix "comparison always the same" warnings found by lgtm
@ 2020-12-31  8:33 Stefan Kangas
  2020-12-31 14:12 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Kangas @ 2020-12-31  8:33 UTC (permalink / raw)
  To: 45562

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

Severity: wishlist

The attached patch fixes some warnings found by lgtm.com.

Does it look okay?

Ref: https://lgtm.com/projects/g/emacs-mirror/emacs/

[-- Attachment #2: 0001-Fix-comparison-always-the-same-warnings-found-by-lgt.patch --]
[-- Type: text/x-diff, Size: 2685 bytes --]

From 340206865383b0764a7d07cc7771f4fb8773b302 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Thu, 31 Dec 2020 08:19:41 +0100
Subject: [PATCH] Fix "comparison always the same" warnings found by lgtm

* src/alloc.c (memory_full):
* src/buffer.c (init_buffer_once):
* src/fns.c (base64_decode_1):
* src/window.c (window_scroll_pixel_based):
* src/xfaces.c (merge_face_vectors): Fix warning "Comparison result is
always the same" found by lgtm dot com.
---
 src/alloc.c  | 2 +-
 src/buffer.c | 3 +--
 src/fns.c    | 2 --
 src/window.c | 2 +-
 src/xfaces.c | 2 +-
 5 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 0b387dd8c1..5386a142de 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4001,7 +4001,7 @@ memory_full (size_t nbytes)
 	  {
 	    if (i == 0)
 	      free (spare_memory[i]);
-	    else if (i >= 1 && i <= 4)
+	    else if (i <= 4)
 	      lisp_align_free (spare_memory[i]);
 	    else
 	      lisp_free (spare_memory[i]);
diff --git a/src/buffer.c b/src/buffer.c
index 9e44345616..8bca4977ca 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5238,8 +5238,7 @@ init_buffer_once (void)
   PDUMPER_REMEMBER_SCALAR (buffer_local_flags);
 
   /* Need more room? */
-  if (idx >= MAX_PER_BUFFER_VARS)
-    emacs_abort ();
+  eassert (idx < MAX_PER_BUFFER_VARS);
   last_per_buffer_idx = idx;
   PDUMPER_REMEMBER_SCALAR (last_per_buffer_idx);
 
diff --git a/src/fns.c b/src/fns.c
index 2de1d26dd3..f0cc164bc7 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3847,8 +3847,6 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t length,
       if (c == '=')
 	continue;
 
-      if (v1 < 0)
-	return -1;
       value += v1 - 1;
 
       c = value & 0xff;
diff --git a/src/window.c b/src/window.c
index 5db166e345..bfdbd426a6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5708,7 +5708,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
 		 && start_pos > BEGV)
 	    move_it_by_lines (&it, -1);
 	}
-      else if (dy > 0)
+      else /* if (dy > 0) */
 	{
 	  goal_y = it.current_y + dy;
 	  move_it_to (&it, ZV, -1, goal_y, -1, MOVE_TO_POS | MOVE_TO_Y);
diff --git a/src/xfaces.c b/src/xfaces.c
index 73a536b19c..ea0e9d6a28 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2228,7 +2228,7 @@ merge_face_vectors (struct window *w,
 	else if (i != LFACE_FONT_INDEX && ! EQ (to[i], from[i]))
 	  {
 	    to[i] = from[i];
-	    if (i >= LFACE_FAMILY_INDEX && i <= LFACE_SLANT_INDEX)
+	    if (i <= LFACE_SLANT_INDEX)
 	      font_clear_prop (to,
 	                       (i == LFACE_FAMILY_INDEX ? FONT_FAMILY_INDEX
 			        : i == LFACE_FOUNDRY_INDEX ? FONT_FOUNDRY_INDEX
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-21 11:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-31  8:33 bug#45562: [PATCH] Fix "comparison always the same" warnings found by lgtm Stefan Kangas
2020-12-31 14:12 ` Eli Zaretskii
2021-01-01 11:08   ` Lars Ingebrigtsen
2021-01-01 11:37     ` Unknown
2021-01-01 16:10       ` Stefan Kangas
2021-01-01 12:05     ` Eli Zaretskii
2021-01-01 16:21   ` Stefan Kangas
2021-01-01 16:38     ` Andreas Schwab
2021-07-21 11:30       ` Lars Ingebrigtsen
2021-01-01 18:17     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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.