From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13222 invoked by alias); 15 Jan 2006 21:38:20 -0000 Received: (qmail 13214 invoked by uid 22791); 15 Jan 2006 21:38:19 -0000 X-Spam-Check-By: sourceware.org Received: from nitzan.inter.net.il (HELO nitzan.inter.net.il) (192.114.186.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 15 Jan 2006 21:38:18 +0000 Received: from HOME-C4E4A596F7 (IGLD-84-228-138-7.inter.net.il [84.228.138.7]) by nitzan.inter.net.il (MOS 3.7.3-GA) with ESMTP id CLW66322 (AUTH halo1); Sun, 15 Jan 2006 23:38:13 +0200 (IST) Date: Sun, 15 Jan 2006 21:38:00 -0000 Message-Id: From: Eli Zaretskii To: Mark Kettenis CC: gdb-patches@sourceware.org In-reply-to: <200601152023.k0FKNeRn028527@elgar.sibelius.xs4all.nl> (message from Mark Kettenis on Sun, 15 Jan 2006 21:23:40 +0100 (CET)) Subject: Re: [RFC] Fix compiler warnings in osabi.c Reply-to: Eli Zaretskii References: <200601102222.k0AMMNSq000979@elgar.sibelius.xs4all.nl> <200601152023.k0FKNeRn028527@elgar.sibelius.xs4all.nl> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00187.txt.bz2 > Date: Sun, 15 Jan 2006 21:23:40 +0100 (CET) > From: Mark Kettenis > CC: gdb-patches@sourceware.org > > It's a reasonable request, although I'd prefer to keep the literal as > is. The compiler should optimize away sizeof("FreeBSD") anyway. So I > committed the attached. The compiler will probably optimize, allright, but we now have the same string in two places in the sources, which creates a window, albeit a small one, for discrepancies. > Index: ChangeLog > from Mark Kettenis > > * osabi.c (generic_elf_osabi_sniffer): Use memcmp instead of > strcmp to compare string to a byte buffer. > > Index: osabi.c > =================================================================== > RCS file: /cvs/src/src/gdb/osabi.c,v > retrieving revision 1.34 > diff -u -p -r1.34 osabi.c > --- osabi.c 17 Dec 2005 22:34:01 -0000 1.34 > +++ osabi.c 15 Jan 2006 20:19:28 -0000 > @@ -546,7 +546,8 @@ generic_elf_osabi_sniffer (bfd *abfd) > /* The FreeBSD folks have been naughty; they stored the string > "FreeBSD" in the padding of the e_ident field of the ELF > header to "brand" their ELF binaries in FreeBSD 3.x. */ > - if (strcmp (&elf_elfheader (abfd)->e_ident[8], "FreeBSD") == 0) > + if (memcmp (&elf_elfheader (abfd)->e_ident[8], > + "FreeBSD", sizeof ("FreeBSD") == 0) > osabi = GDB_OSABI_FREEBSD_ELF; > } > >