Subject: [PATCH] Fix "comparison always the same" warnings found by lgtm

From: Stefan Kangas <[email-masked]>
Date: Thu, 31 Dec 2020 00:33:06 -0800

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/
From 340206865383b0764a7d07cc7771f4fb8773b302 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
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