From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id A263A385E448 for ; Tue, 9 Apr 2024 02:00:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A263A385E448 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A263A385E448 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712628002; cv=none; b=Rgk1RN3TdZO1rqHGs9M3K4C/JiPMuXPiMaqJU0nh9Lp6YO3m8WKVCkWOQsPUGbc2jXD3VI4yQGs5MYEXko6nYiWfa3KGU8IHmPXd97B7z5YpWaChbd05xrW59VDAJQ7wP0P4aPx3M7/ESFloaX+bVzHDPD2U2H24gANFherdq98= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712628002; c=relaxed/simple; bh=6tEMW6ZRh5uTpVDnLC+Xp3wZ4msEF4N1iDO/vHERK/I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=bgw+zseCDgfh8RfYZWh2IK2c9aqJr6N7FNVhAs+rsrTQFyp/Y1dTWGQWlBCRWbHpPlMHMLggh4f0tR91JNx6GCHa22/tN7fdx2hpvGc23YMkeeXNWkFjPZR0ymjQkM1QhANIb9314ZClf6tvw85zmnTlbJZM3s33nrhP61f5bWs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1e2c725e234so28253035ad.1 for ; Mon, 08 Apr 2024 19:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712627999; x=1713232799; darn=sourceware.org; h=content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=EKL+KTgX65x6ChpSHJ/NCj+SG9LgvJJ1Rgob4pn9VyE=; b=UkftzOPuzneTA5wrf64730P213zJ7S46zYCEzvWaYP5AJnLNd627i70FP4HBn3vOOm F8ulY4yRj6f5eRHlzTmWZtGpPAb/pm5FlpIVSyWIYwmlgU/jvJRPk1h+jXqj4RzSF8UL 1EuxfzMbRhyivSpnEAafdmBOlHyq+okspZG/XHCeh3zc9EEqfVTbtKFilqUJ/MItpL2x n/9MdFF1AL7PKKo2b26DJ64VXTIYJ+w+ZpgFUxQ3tHGk5YRtQ4mZPw0vUfcRNgbEwZGV ANs37GJ/UQMkIFmRphzhjvdLeOS/+bvzo4vmnjRlA3NdpYA94PpzsG50czcNwfy5Q+h2 NA8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712627999; x=1713232799; h=content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EKL+KTgX65x6ChpSHJ/NCj+SG9LgvJJ1Rgob4pn9VyE=; b=kPHUA2Y5KYkowdgtAicsP/lRJMp1Xc/TRgRfX+UoiHvuf+7j9Vm2ntT0+Tg9Nl3eQx oujmyO2C+aWOZDMRFSGgFVf+O3f7Rwg/rf6L1j42jp/IwR/51f/NLMgDypg2+Jvy2Rmz t6nOxiWJS7pS5LSBJ9QQXmWwXo6nxkKjuK9Q/50q1muHsqShd8aPfrViwzuy7u3oHdjG oxeWPmRD5cqDpFvFjCEEDOduL6G913FwGZSIlFTGDvVlDix7pXMTxne8Y3YyAh+/Hedm NVAHOLBgf78jbEZ6XgJeG9fgZBRub5x25GCVZ/ThdTjQdvcvr501T/73kVG/ljbRDiwo Z15w== X-Gm-Message-State: AOJu0YwtUbOdLjflU8CF+kJUm5rEWrtpn8XJCIXflVl7Cu7+SEuMPGgL tfkYZmbg2IPhkGGM0cfj4S5F4TnCcc6gt24c8619PEpVDWbE3coUTaD26xr6 X-Google-Smtp-Source: AGHT+IFZgKgbPooeiOEvCUYBb+Ix4Kxql1tvDyCswFMNn0z3bimXqbY6yTCHtuPgyU7j0X7FYnzteg== X-Received: by 2002:a17:902:cf01:b0:1e2:a5db:30d1 with SMTP id i1-20020a170902cf0100b001e2a5db30d1mr2034027plg.13.1712627999370; Mon, 08 Apr 2024 18:59:59 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id i13-20020a170902c94d00b001e2ba8605dfsm7705694pla.150.2024.04.08.18.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 18:59:58 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id ADCF21140063; Tue, 9 Apr 2024 11:29:56 +0930 (ACST) Date: Tue, 9 Apr 2024 11:29:56 +0930 From: Alan Modra To: binutils@sourceware.org Cc: Nick Alcock Subject: libctf warnings Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3033.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Seen with every compiler I have: home/alan/src/binutils-gdb/libctf/ctf-create.c: In function ‘ctf_add_encoded’: /home/alan/src/binutils-gdb/libctf/ctf-create.c:555:3: warning: ‘encoding’ may be used uninitialized [-Wmaybe-uninitialized] 555 | memcpy (dtd->dtd_vlen, &encoding, sizeof (encoding)); Seen with gcc-4.9 and probably others at lower optimisation levels: home/alan/src/binutils-gdb/libctf/ctf-serialize.c: In function 'symtypetab_density': /home/alan/src/binutils-gdb/libctf/ctf-serialize.c:211:18: warning: 'sym' may be used uninitialized in this function [-Wmaybe-uninitialized] if (*max < sym->st_symidx) 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' may 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 Also with gcc-4.5: In file included from /home/alan/src/binutils-gdb/libctf/ctf-endian.h:25:0, from /home/alan/src/binutils-gdb/libctf/ctf-archive.c:24: /home/alan/src/binutils-gdb/libctf/swap.h:70:0: warning: "_Static_assert" redefined /usr/include/sys/cdefs.h:568:0: note: this is the location of the previous definition * swap.h (_Static_assert): Undef before defining. * 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. I'll apply this in a few days unless Nick objects. diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c index d0255e5ba7f..99ff4882fd9 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 = CTF_FP_DATA (ep->cte_format, ep->cte_offset, ep->cte_bits); break; + default: + /* ctf_assert is opaque to compilers. This dead code avoids a + warning about "encoding" being used uninitialized. */ + return CTF_ERR; } memcpy (dtd->dtd_vlen, &encoding, sizeof (encoding)); 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 = NULL; - uint32_t parent_i; + uint32_t parent_i = 0; ctf_next_t *j = NULL; /* 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, } ctf_dynhash_remove (linker_known, name); - } - *unpadsize += sizeof (uint32_t); - (*count)++; - if (!(flags & CTF_SYMTYPETAB_FORCE_INDEXED)) - { if (*max < sym->st_symidx) *max = sym->st_symidx; } else (*max)++; + + *unpadsize += sizeof (uint32_t); + (*count)++; } if (err != 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_visit_f *func, { ctf_dict_t *ofp = fp; ctf_id_t otype = type; - const ctf_type_t *tp; + const ctf_type_t *tp = 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..2dd20a27390 100644 --- a/libctf/swap.h +++ b/libctf/swap.h @@ -67,6 +67,7 @@ bswap_64 (uint64_t v) /* < C11? define away static assertions. */ #if !defined (__STDC_VERSION__) || __STDC_VERSION__ < 201112L +#undef _Static_assert #define _Static_assert(cond, err) #endif -- Alan Modra Australia Development Lab, IBM