From patchwork Fri Jan 4 19:00:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 209519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 501A72C0080 for ; Sat, 5 Jan 2013 06:00:32 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1357930833; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Subject:Date:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=ybRAoX3 PsKDqLLHG6hdy2zp6wH8=; b=AzrTBXF8IrSHiZMvLE6I4POA5PGwvyehUcGpZSf Fm5C03SoLXRMKmxJLA4pw9BOfKfkHRhQNWPunvsYGIXF2JBzJBOcu5BJGxZj+IAj U10mbfT7rBlswTK8WHPOcKgpfORWdF1gjXjX6UjIi547w0xHGvCRgVR4u9ZBWoQ0 HiIk= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:X-Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=NqmObmZFIlUmsn94PzfOniPfo/UkYwUH61bcIVmOP1JxbEVTwvatTrbTtL+FSJ 6GOulwwyj7EST6eGb4td/EVVyd220S31i0S8T/ED2dYFqN5XWCR7NxHIwUbH+w6f g2aEQdxzVJx6ERKOxy/SRSM+KUhYSE86IegZm1H53Gvsw=; Received: (qmail 30948 invoked by alias); 4 Jan 2013 19:00:24 -0000 Received: (qmail 30934 invoked by uid 22791); 4 Jan 2013 19:00:22 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_CP, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-gg0-f170.google.com (HELO mail-gg0-f170.google.com) (209.85.161.170) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Jan 2013 19:00:13 +0000 Received: by mail-gg0-f170.google.com with SMTP id l1so2645631ggn.29 for ; Fri, 04 Jan 2013 11:00:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=plyvo/LtN9fH18AaEyrJtG3Hg9QwKgZuB/vRNi34pQc=; b=mDg45XaTdux9nCyfpop8WxDiRK24qz9SN8S3CbrrPzR/qTL5c3jEyYxyI0JV65H2FO ovsigV/RDqgCUhumwpUyhyCoxmgBGZHfgJx/Vd3dhAkf34X4bz1XrUPEpoS3GIMAwRl+ w6P5sdyoK0EB+K4ug86wkuZi9+0qzzaiWdPbASXKj3W3gTjR1N/k6s6Wz+ghv0GxZB8e ltEGro6hU46QCZJnl45IWTc/pzY+aGbHIx13nqclkP8egQfLXlGHSXwp6Zpcsw7aQGY+ o2GBTW0nlsYuIjFohSNp+WXJl2j7NId3FMVO5waG50sZh3/xEACrZxHNWZtzwEUZ472s ZWNg== X-Received: by 10.101.141.11 with SMTP id t11mr7868378ann.70.1357326013120; Fri, 04 Jan 2013 11:00:13 -0800 (PST) Received: from iant-glaptop.google.com ([2620:0:1000:3204:5086:5550:98a6:9e82]) by mx.google.com with ESMTPS id q15sm13781458anl.13.2013.01.04.11.00.11 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Jan 2013 11:00:12 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: libiberty patch committed: Minor optimization (PR 54800) Date: Fri, 04 Jan 2013 11:00:10 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQncaEvzwPpXdf8ThXBn/hyf88aM3UgpigO5IfvSKk2JdWsNJhE62mQ9j9uABHYUOe0BRItgPUDMOtQfZ1H/X4wMj3kBipuvh0yD4+AfoWvD6M+y8Wdz4VH+3NAiLxyb+VBYzbZ1JnX20LQZ6MBZkVzDu5ccWtMJzfVtTsWbVehgmOkH7Bv5Ec1r/cvVVH6mQ81G5zvpACqXcQ5DxM6a2WqURjAkPA== X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org PR 54800 points out a minor optimization uncovered by cppcheck. This optimization is not important, but we might as well fix it in case cppcheck comes up with something useful. Tested by Iain Sandoe (thanks!). Committed to mainline. Ian 2013-01-04 Ian Lance Taylor PR other/54800 * simple-object-mach-o.c (simple_object_mach_o_segment): Don't bother to zero out a buffer we are about to set anyhow. Index: simple-object-mach-o.c =================================================================== --- simple-object-mach-o.c (revision 194911) +++ simple-object-mach-o.c (working copy) @@ -1,5 +1,5 @@ /* simple-object-mach-o.c -- routines to manipulate Mach-O object files. - Copyright 2010, 2011 Free Software Foundation, Inc. + Copyright 2010, 2011, 2013 Free Software Foundation, Inc. Written by Ian Lance Taylor, Google. This program is free software; you can redistribute it and/or modify it @@ -701,12 +701,13 @@ simple_object_mach_o_segment (simple_obj /* Otherwise, make a name like __segment,__section as per the convention in mach-o asm. */ name = &namebuf[0]; - memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2); memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN); + namebuf[MACH_O_NAME_LEN] = '\0'; l = strlen (namebuf); namebuf[l] = ','; memcpy (namebuf + l + 1, (char *) sechdr + sectname_offset, MACH_O_NAME_LEN); + namebuf[l + 1 + MACH_O_NAME_LEN] = '\0'; } simple_object_mach_o_section_info (omr->is_big_endian, is_32, sechdr,