]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: fix compile error on i386
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 Aug 2024 02:40:20 +0000 (11:40 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 1 Aug 2024 08:49:40 +0000 (10:49 +0200)
Fixes the following error:
===
In file included from ../src/basic/macro.h:13,
                 from ../src/basic/dirent-util.h:8,
                 from ../src/journal/journalctl-misc.c:3:
../src/journal/journalctl-misc.c: In function 'show_log_ids':
../src/journal/journalctl-misc.c:107:22: error: comparison is always true due to limited range of data type [-Werror=type-limits]
  107 |         assert(n_ids < INT64_MAX);
      |                      ^
../src/fundamental/macro-fundamental.h:70:44: note: in definition of macro '_unlikely_'
   70 | #define _unlikely_(x) (__builtin_expect(!!(x), 0))
      |                                            ^
../src/basic/macro.h:165:22: note: in expansion of macro 'assert_message_se'
  165 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/journal/journalctl-misc.c:107:9: note: in expansion of macro 'assert'
  107 |         assert(n_ids < INT64_MAX);
      |         ^~~~~~
cc1: all warnings being treated as errors
===

Follow-up for 0a8c1f6212a874b542a57ed5416e7d3575d2da93.

src/journal/journalctl-misc.c

index 01fb83807a9c1b3a22de93903ec8cb51a6216959..5a1f31122184eaf1ed009c4035493e8c6395ac15 100644 (file)
@@ -104,7 +104,7 @@ static int show_log_ids(const LogId *ids, size_t n_ids, const char *name) {
 
         assert(ids);
         assert(n_ids > 0);
-        assert(n_ids < INT64_MAX);
+        assert((uint64_t) INT64_MAX - n_ids > 0);
         assert(name);
 
         table = table_new("idx", name, "first entry", "last entry");