binutils-gdb/libctf/testsuite/libctf-lookup/enum-symbol.c
Nick Alcock e695879142 libctf, testsuite: fix various warnings in tests
These warnings are all off by default, but if they do fire you get
spurious ERRORs when running make check-libctf.

libctf/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* testsuite/libctf-lookup/enum-symbol.c: Remove unused label.
	* testsuite/libctf-lookup/conflicting-type-syms.c: Remove unused
	variables.
	* testsuite/libctf-regression/pptrtab.c: Likewise.
	* testsuite/libctf-regression/type-add-unnamed-struct.c: Likewise.
	* testsuite/libctf-writable/pptrtab.c: Likewise.
	* testsuite/libctf-writable/reserialize-strtab-corruption.c:
	Likewise.
	* testsuite/libctf-regression/nonstatic-var-section-ld-r.c: Fix
	format string.
	* testsuite/libctf-regression/nonstatic-var-section-ld.c:
	Likewise.
	* testsuite/libctf-regression/nonstatic-var-section-ld.lk: Adjust.
	* testsuite/libctf-writable/symtypetab-nonlinker-writeout.c: Fix
	initializer.
2021-09-27 20:31:26 +01:00

64 lines
1.5 KiB
C

#include "config.h"
#include <ctf-api.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (int argc, char *argv[])
{
ctf_archive_t *ctf;
ctf_dict_t *fp, *tmp_fp;
int err;
ctf_id_t type, tmp;
ctf_next_t *i = NULL;
const char *name;
int val;
if (argc != 2)
{
fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
exit(1);
}
if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
goto open_err;
/* Fish out the enumerator, then fish out all its enumerand/value pairs. */
if ((fp = ctf_arc_lookup_symbol_name (ctf, "primary1", &type, &err)) == NULL)
goto sym_err;
while ((name = ctf_enum_next (fp, type, &i, &val)) != NULL)
{
printf ("%s has value %i\n", name, val);
}
if (ctf_errno (fp) != ECTF_NEXT_END)
goto nerr;
/* Fish it out again to check the caching layer. */
if (((tmp_fp = ctf_arc_lookup_symbol_name (ctf, "primary1", &tmp, &err)) != fp)
|| (tmp != type))
goto sym_cache_err;
ctf_dict_close (tmp_fp);
ctf_dict_close (fp);
ctf_close (ctf);
return 0;
open_err:
fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
return 1;
sym_err:
fprintf (stderr, "%s: Symbol lookup error: %s\n", argv[0], ctf_errmsg (err));
return 1;
sym_cache_err:
fprintf (stderr, "%s: Symbol re-lookup error (caching bug): %s\n", argv[0],
ctf_errmsg (err));
return 1;
nerr:
fprintf (stderr, "iteration failed: %s\n", ctf_errmsg (ctf_errno (fp)));
return 1;
}