From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25161 invoked by alias); 8 Aug 2007 22:08:40 -0000 Received: (qmail 25085 invoked by uid 22791); 8 Aug 2007 22:08:39 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 08 Aug 2007 22:08:33 +0000 Received: (qmail 11811 invoked from network); 8 Aug 2007 22:08:31 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Aug 2007 22:08:31 -0000 To: msnyder@sonic.net Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] solib_open, memory leak References: <21906.12.7.175.2.1186283848.squirrel@webmail.sonic.net> <18682.12.7.175.2.1186597784.squirrel@webmail.sonic.net> <22684.12.7.175.2.1186610277.squirrel@webmail.sonic.net> From: Jim Blandy Date: Wed, 08 Aug 2007 22:08:00 -0000 In-Reply-To: <22684.12.7.175.2.1186610277.squirrel@webmail.sonic.net> (msnyder@sonic.net's message of "Wed, 8 Aug 2007 14:57:57 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00166.txt.bz2 msnyder@sonic.net writes: > [Jim:] >> The code clearly deserves a comment like: >> >> /* We try to find the library in various ways. After each >> attempt, either found_file >= 0 and temp_pathname is a malloc'd >> string, or found_file < 0 and temp_pathname does not point to >> storage that needs to be freed. */ >> >> In that light, it seems clearer to me to just put: >> >> if (found_file < 0) >> temp_pathname = NULL; >> else >> temp_pathname = xstrdup (temp_pathname); >> >> immediately after the open, to make it obvious that the rule is >> followed there. >> > [...] >> Don't you want those new lines to replace the two that followed them, >> not just precede them? > > Yes, thanks. How about this? Poifect.