From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26363 invoked by alias); 28 Jul 2009 04:21:27 -0000 Received: (qmail 26353 invoked by uid 22791); 28 Jul 2009 04:21:26 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.gmx.net (HELO mail.gmx.net) (213.165.64.20) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Tue, 28 Jul 2009 04:21:20 +0000 Received: (qmail 24492 invoked by uid 0); 28 Jul 2009 04:21:17 -0000 Received: from 141.74.1.1 by www171.gmx.net with HTTP; Tue, 28 Jul 2009 06:21:15 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-1" Date: Tue, 28 Jul 2009 04:21:00 -0000 From: "Martin Ettl" Message-ID: <20090728042115.158890@gmx.net> MIME-Version: 1.0 Subject: found redundant code in file natSystemProperties.cc To: java@gcc.gnu.org Content-Transfer-Encoding: 8bit Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org X-SW-Source: 2009-07/txt/msg00079.txt.bz2 Hello friends, i have checked the sources of gcc-4.4.1 with the static code analysis tool cppcheck. It brought up an issue in file gcc-4.4.1/libjava/gnu/classpath/natSystemProperties.cc at line 278. Lets take a look at the sourcecode: // ... while (buffer != NULL) { if (getcwd (buffer, buflen) != NULL) { SET ("user.dir", buffer); break; } if (errno != ERANGE) break; buflen = 2 * buflen; char *orig_buf = buffer; buffer = (char *) realloc (buffer, buflen); if (buffer == NULL) free (orig_buf); } 278 if (buffer != NULL) free (buffer); .... Here the line 278 is redundant, because it is safe to deallocate a NULL-Pointer! In other words, the if-statement can be removed. Best regards Ettl Martin -- Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02