libctf: fix signed/unsigned comparison confusion
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Mar 2021 15:10:05 +0000 (15:10 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 2 Mar 2021 15:10:08 +0000 (15:10 +0000)
Comparing an encoding's cte_bits to a ctf_type_size needs a cast:
one is a uint32_t and the other is an ssize_t.

libctf/ChangeLog
2021-03-02  Nick Alcock  <nick.alcock@oracle.com>

* ctf-dump.c (ctf_dump_format_type): Fix signed/unsigned confusion.

libctf/ChangeLog
libctf/ctf-dump.c

index 767d48c3599264f68c13322c98edad16f3c7ede1..f0a1754d5ec95a270ffc1f3187b6e2db598d3bab 100644 (file)
@@ -1,3 +1,7 @@
+2021-03-02  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-dump.c (ctf_dump_format_type): Fix signed/unsigned confusion.
+
 2021-03-02  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-dedup.c (ctf_dedup): Pass on errors from ctf_dedup_hash_type.
index 758d28d76d58a816292b5aafc35b97c15fc08bbc..788355d9db145f52decbb37d978672aacd38a0d7 100644 (file)
@@ -144,7 +144,7 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
 
       if (ctf_type_encoding (fp, id, &ep) == 0)
        {
-         if (ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
+         if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
              && flag & CTF_FT_BITFIELD)
            {
              if (asprintf (&bit, ":%i", ep.cte_bits) < 0)
@@ -154,7 +154,7 @@ ctf_dump_format_type (ctf_dict_t *fp, ctf_id_t id, int flag)
              bit = NULL;
            }
 
-         if (ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
+         if ((ssize_t) ep.cte_bits != ctf_type_size (fp, id) * CHAR_BIT
              || ep.cte_offset != 0)
            {
              const char *slice = "";