* [binutils-gdb] libctf: fix testsuite bugs revealed by -Wall
@ 2024-06-19 14:51 Nick Alcock
0 siblings, 0 replies; only message in thread
From: Nick Alcock @ 2024-06-19 14:51 UTC (permalink / raw)
To: binutils-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b84ffc176d3ab90a5dd42e406f84b2207f2782ca
commit b84ffc176d3ab90a5dd42e406f84b2207f2782ca
Author: Nick Alcock <nick.alcock@oracle.com>
Date: Wed Jun 19 14:06:26 2024 +0100
libctf: fix testsuite bugs revealed by -Wall
Most of these are harmless, but some of the type confusions and especially
a missing ctf_strerror() on an error path were actual bugs that could
have resulted in test failures crashing rather than printing an error
message.
libctf/
* testsuite/libctf-lookup/enumerator-iteration.c: Fix type
confusion, signedness confusion and a missing ctf_errmsg().
* testsuite/libctf-regression/libctf-repeat-cu-main.c: Return 0 from
the test function.
* testsuite/libctf-regression/open-error-free.c: Fix signedness
confusion.
* testsuite/libctf-regression/zrewrite.c: Remove unused label.
Diff:
---
libctf/testsuite/libctf-lookup/enumerator-iteration.c | 15 +++++++--------
.../testsuite/libctf-regression/libctf-repeat-cu-main.c | 2 +-
libctf/testsuite/libctf-regression/open-error-free.c | 2 +-
libctf/testsuite/libctf-regression/zrewrite.c | 3 ---
4 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/libctf/testsuite/libctf-lookup/enumerator-iteration.c b/libctf/testsuite/libctf-lookup/enumerator-iteration.c
index e46dad6dc70..78cb5a3cc0d 100644
--- a/libctf/testsuite/libctf-lookup/enumerator-iteration.c
+++ b/libctf/testsuite/libctf-lookup/enumerator-iteration.c
@@ -23,8 +23,8 @@ print_constants (ctf_archive_t *ctf, const char *name)
{
char *foo;
- printf ("%s in %s has value %i\n", name,
- foo = ctf_type_aname (fp, type), val);
+ printf ("%s in %s has value %li\n", name,
+ foo = ctf_type_aname (fp, type), (long int) val);
free (foo);
ctf_dict_close (fp);
@@ -44,7 +44,6 @@ main (int argc, char *argv[])
int err;
ctf_id_t type;
ctf_next_t *i = NULL;
- const char *name;
int64_t val;
int counter = 0;
@@ -71,8 +70,8 @@ main (int argc, char *argv[])
{
char *foo;
- printf ("IENUMSAMPLE2_2 in %s has value %i\n",
- foo = ctf_type_aname (fp, type), val);
+ printf ("IENUMSAMPLE2_2 in %s has value %li\n",
+ foo = ctf_type_aname (fp, type), (long int) val);
free (foo);
if ((type = ctf_add_enum (fp, CTF_ADD_ROOT, "ie3")) == CTF_ERR)
@@ -117,13 +116,13 @@ main (int argc, char *argv[])
if (type != CTF_ERR)
{
char *foo;
- printf ("direct lookup: hidden lookup did not return ECTF_NOENUMNAM but rather %i in %s\n",
- val, foo = ctf_type_aname (fp, type));
+ printf ("direct lookup: hidden lookup did not return ECTF_NOENUMNAM but rather %li in %s\n",
+ (long int) val, foo = ctf_type_aname (fp, type));
free (foo);
}
else
printf ("direct lookup: hidden lookup did not return ECTF_NOENUMNAM but rather %s\n",
- ctf_errno (fp));
+ ctf_errmsg (ctf_errno (fp)));
}
ctf_dict_close (fp);
diff --git a/libctf/testsuite/libctf-regression/libctf-repeat-cu-main.c b/libctf/testsuite/libctf-regression/libctf-repeat-cu-main.c
index bfbaf0cc8dc..c1f2f6318c1 100644
--- a/libctf/testsuite/libctf-regression/libctf-repeat-cu-main.c
+++ b/libctf/testsuite/libctf-regression/libctf-repeat-cu-main.c
@@ -2,4 +2,4 @@ typedef short ret_t;
int a (void);
int b (void);
int c (void);
-int blah (void) { a(); b(); c(); }
+int blah (void) { a(); b(); c(); return 0; }
diff --git a/libctf/testsuite/libctf-regression/open-error-free.c b/libctf/testsuite/libctf-regression/open-error-free.c
index edc5f348d5f..7405cdb25f3 100644
--- a/libctf/testsuite/libctf-regression/open-error-free.c
+++ b/libctf/testsuite/libctf-regression/open-error-free.c
@@ -143,7 +143,7 @@ int main (void)
failure after we corrupt it: the leak is only observable if the dict gets
malloced, which only happens after that point.) */
- if ((written = ctf_write_mem (fp, &written_size, (size_t) -1)) == NULL)
+ if ((written = (char *) ctf_write_mem (fp, &written_size, (size_t) -1)) == NULL)
goto write_err;
ctf_dict_close (fp);
diff --git a/libctf/testsuite/libctf-regression/zrewrite.c b/libctf/testsuite/libctf-regression/zrewrite.c
index 5e061f10a5f..3ddc354d2e3 100644
--- a/libctf/testsuite/libctf-regression/zrewrite.c
+++ b/libctf/testsuite/libctf-regression/zrewrite.c
@@ -150,7 +150,4 @@ main (int argc, char *argv[])
write_stderr:
fprintf (stderr, "%s: cannot open for writing: %s\n", argv[0], strerror (errno));
return 1;
- read_err:
- fprintf (stderr, "%s: cannot read\n", argv[0]);
- return 1;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-06-19 14:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-19 14:51 [binutils-gdb] libctf: fix testsuite bugs revealed by -Wall Nick Alcock
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).