From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 172083858D20; Tue, 16 Apr 2024 23:56:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 172083858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713311767; bh=A08CnClr6FvD48jCSMOGNVOue27iI4J6z0fu28J4ePc=; h=From:To:Subject:Date:From; b=OR2SuOK/5lT1OzQikxGi1aAW4oyhinBbUxJNoXdgeVuFBH/u0TP4PVOD8Szkjgbsc RaJATg7OUS42hXEmHrlZl28tSqoC/DRSeCdWCL3IHbTvqo0txgT3TLdvH2f+d+1Fve XsxIypKIECH6vX4U5Q1I+q0aiSMFTCkWce39m6bU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] libctf warnings X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 20bf7711bce2188c1af985a87df23c4653c2cc7a X-Git-Newrev: 59497587af9e1c5f029ab0bb106103dab30a5f5d Message-Id: <20240416235607.172083858D20@sourceware.org> Date: Tue, 16 Apr 2024 23:56:06 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D59497587af9e= 1c5f029ab0bb106103dab30a5f5d commit 59497587af9e1c5f029ab0bb106103dab30a5f5d Author: Alan Modra Date: Tue Apr 9 08:53:35 2024 +0930 libctf warnings =20 Seen with every compiler I have if using -fno-inline: home/alan/src/binutils-gdb/libctf/ctf-create.c: In function =E2=80=98ct= f_add_encoded=E2=80=99: /home/alan/src/binutils-gdb/libctf/ctf-create.c:555:3: warning: =E2=80= =98encoding=E2=80=99 may be used uninitialized [-Wmaybe-uninitialized] 555 | memcpy (dtd->dtd_vlen, &encoding, sizeof (encoding)); =20 Seen with gcc-4.9 and probably others at lower optimisation levels: home/alan/src/binutils-gdb/libctf/ctf-serialize.c: In function 'symtype= tab_density': /home/alan/src/binutils-gdb/libctf/ctf-serialize.c:211:18: warning: 'sy= m' may be used uninitialized in this function [-Wmaybe-uninitialized] if (*max < sym->st_symidx) =20 Seen with gcc-4.5 and probably others at lower optimisation levels: /home/alan/src/binutils-gdb/libctf/ctf-types.c:1649:21: warning: 'tp' m= ay be used uninitialized in this function /home/alan/src/binutils-gdb/libctf/ctf-link.c:765:16: warning: 'parent_= i' may be used uninitialized in this function =20 Also with gcc-4.5: In file included from /home/alan/src/binutils-gdb/libctf/ctf-endian.h:2= 5:0, from /home/alan/src/binutils-gdb/libctf/ctf-archive.c:= 24: /home/alan/src/binutils-gdb/libctf/swap.h:70:0: warning: "_Static_asser= t" redefined /usr/include/sys/cdefs.h:568:0: note: this is the location of the previ= ous definition =20 * swap.h (_Static_assert): Don't define if already defined. * ctf-serialize.c (symtypetab_density): Merge two CTF_SYMTYPETAB_FORCE_INDEXED blocks. * ctf-create.c (ctf_add_encoded): Avoid "encoding" may be used uninitialized warning. * ctf-link.c (ctf_link_deduplicating_open_inputs): Avoid "parent_i" may be used uninitialized warning. * ctf-types.c (ctf_type_rvisit): Avoid "tp" may be used uninitialized warning. Diff: --- libctf/ctf-create.c | 4 ++++ libctf/ctf-link.c | 2 +- libctf/ctf-serialize.c | 8 +++----- libctf/ctf-types.c | 2 +- libctf/swap.h | 2 ++ 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index d0255e5ba7f..21fbad714a9 100644 --- a/libctf/ctf-create.c +++ b/libctf/ctf-create.c @@ -551,6 +551,10 @@ ctf_add_encoded (ctf_dict_t *fp, uint32_t flag, case CTF_K_FLOAT: encoding =3D CTF_FP_DATA (ep->cte_format, ep->cte_offset, ep->cte_bi= ts); break; + default: + /* ctf_assert is opaque with -fno-inline. This dead code avoids + a warning about "encoding" being used uninitialized. */ + return CTF_ERR; } memcpy (dtd->dtd_vlen, &encoding, sizeof (encoding)); =20 diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c index d5433b9d9bd..360bc1a0e63 100644 --- a/libctf/ctf-link.c +++ b/libctf/ctf-link.c @@ -762,7 +762,7 @@ ctf_link_deduplicating_open_inputs (ctf_dict_t *fp, ctf= _dynhash_t *cu_names, ctf_link_input_t *one_input; ctf_dict_t *one_fp; ctf_dict_t *parent_fp =3D NULL; - uint32_t parent_i; + uint32_t parent_i =3D 0; ctf_next_t *j =3D NULL; =20 /* If we are processing CU names, get the real input. All the inputs diff --git a/libctf/ctf-serialize.c b/libctf/ctf-serialize.c index 8645f32ab20..11cbe75601e 100644 --- a/libctf/ctf-serialize.c +++ b/libctf/ctf-serialize.c @@ -202,17 +202,15 @@ symtypetab_density (ctf_dict_t *fp, ctf_dict_t *symfp= , ctf_dynhash_t *symhash, } =20 ctf_dynhash_remove (linker_known, name); - } - *unpadsize +=3D sizeof (uint32_t); - (*count)++; =20 - if (!(flags & CTF_SYMTYPETAB_FORCE_INDEXED)) - { if (*max < sym->st_symidx) *max =3D sym->st_symidx; } else (*max)++; + + *unpadsize +=3D sizeof (uint32_t); + (*count)++; } if (err !=3D ECTF_NEXT_END) { diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index 6dc723d61ea..0eaafa13619 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -1646,7 +1646,7 @@ ctf_type_rvisit (ctf_dict_t *fp, ctf_id_t type, ctf_v= isit_f *func, { ctf_dict_t *ofp =3D fp; ctf_id_t otype =3D type; - const ctf_type_t *tp; + const ctf_type_t *tp =3D NULL; const ctf_dtdef_t *dtd; unsigned char *vlen; ssize_t size, increment, vbytes; diff --git a/libctf/swap.h b/libctf/swap.h index d004dc14348..2e2b6973531 100644 --- a/libctf/swap.h +++ b/libctf/swap.h @@ -67,8 +67,10 @@ bswap_64 (uint64_t v) /* < C11? define away static assertions. */ =20 #if !defined (__STDC_VERSION__) || __STDC_VERSION__ < 201112L +#ifndef _Static_assert #define _Static_assert(cond, err) #endif +#endif =20 /* Swap the endianness of something. */