From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9399 invoked by alias); 24 Jul 2007 23:36:40 -0000 Received: (qmail 9391 invoked by uid 22791); 24 Jul 2007 23:36:39 -0000 X-Spam-Check-By: sourceware.org Received: from omta02ps.mx.bigpond.com (HELO omta02ps.mx.bigpond.com) (144.140.83.154) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 24 Jul 2007 23:36:37 +0000 Received: from oaamta02ps.mx.bigpond.com ([58.174.193.252]) by omta02ps.mx.bigpond.com with ESMTP id <20070724233633.KGDN14578.omta02ps.mx.bigpond.com@oaamta02ps.mx.bigpond.com>; Tue, 24 Jul 2007 23:36:33 +0000 Received: from bubble.grove.modra.org ([58.174.193.252]) by oaamta02ps.mx.bigpond.com with ESMTP id <20070724233633.LZRH27015.oaamta02ps.mx.bigpond.com@bubble.grove.modra.org>; Tue, 24 Jul 2007 23:36:33 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 3032C38709F; Wed, 25 Jul 2007 09:06:32 +0930 (CST) Date: Wed, 25 Jul 2007 00:11:00 -0000 From: Alan Modra To: msnyder@sonic.net Cc: binutils@sourceware.org Subject: Re: [PATCH] linker.c, null string Message-ID: <20070724233632.GG27905@bubble.grove.modra.org> Mail-Followup-To: msnyder@sonic.net, binutils@sourceware.org References: <12546.12.7.175.2.1185310570.squirrel@webmail.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <12546.12.7.175.2.1185310570.squirrel@webmail.sonic.net> User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00387.txt.bz2 On Tue, Jul 24, 2007 at 01:56:10PM -0700, msnyder@sonic.net wrote: > Shouldn't use NULL to denote an invalid string, because the pointer > will be passed to functions that will dereference it (Coverity). Actually, it won't ever be dereferenced. The function that is called, _bfd_generic_link_add_one_symbol, only uses "string" when handling warning and indirect symbols. > * linker.c (generic_link_add_symbol_list): Use an invalid string > rather than null, since the pointer will be dereferenced. So introducing another string constant is just bloat. We do like to fix warnings though. I'm committing the following. * linker.c (generic_link_add_symbol_list): Warning fix. Index: bfd/linker.c =================================================================== RCS file: /cvs/src/src/bfd/linker.c,v retrieving revision 1.59 diff -u -p -r1.59 linker.c --- bfd/linker.c 3 Jul 2007 14:26:42 -0000 1.59 +++ bfd/linker.c 24 Jul 2007 23:25:56 -0000 @@ -1316,7 +1316,7 @@ generic_link_add_symbol_list (bfd *abfd, struct generic_link_hash_entry *h; struct bfd_link_hash_entry *bh; - name = bfd_asymbol_name (p); + string = name = bfd_asymbol_name (p); if (((p->flags & BSF_INDIRECT) != 0 || bfd_is_ind_section (p->section)) && pp + 1 < ppend) @@ -1329,12 +1329,9 @@ generic_link_add_symbol_list (bfd *abfd, { /* The name of P is actually the warning string, and the next symbol is the one to warn about. */ - string = name; pp++; name = bfd_asymbol_name (*pp); } - else - string = NULL; bh = NULL; if (! (_bfd_generic_link_add_one_symbol -- Alan Modra Australia Development Lab, IBM