From: Stefan Kangas <stefan@marxist.se>
To: 45562@debbugs.gnu.org
Subject: bug#45562: [PATCH] Fix "comparison always the same" warnings found by lgtm
Date: Thu, 31 Dec 2020 00:33:06 -0800 [thread overview]
Message-ID: <CADwFkmkAZNpPewVUPz0xwu6ytaL7_wsGfG=-+1fP1pUsoCVacg@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2020-12-31 8:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-31 8:33 Stefan Kangas [this message]
2020-12-31 14:12 ` bug#45562: [PATCH] Fix "comparison always the same" warnings found by lgtm 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADwFkmkAZNpPewVUPz0xwu6ytaL7_wsGfG=-+1fP1pUsoCVacg@mail.gmail.com' \
--to=stefan@marxist.se \
--cc=45562@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).