From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5845 invoked by alias); 5 Feb 2010 00:18:35 -0000 Received: (qmail 5832 invoked by uid 22791); 5 Feb 2010 00:18:34 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Feb 2010 00:18:28 +0000 Received: from vapier.localnet (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 1849A67B48; Fri, 5 Feb 2010 00:18:27 +0000 (UTC) From: Mike Frysinger To: Doug Evans Subject: Re: [patch] check return value of do_write in sim_load_file() Date: Fri, 05 Feb 2010 00:18:00 -0000 User-Agent: KMail/1.12.4 (Linux/2.6.32.6; KDE/4.3.4; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <201002040207.39493.vapier@gentoo.org> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3727438.asj57AJKQn"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201002041919.07122.vapier@gentoo.org> 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: 2010-02/txt/msg00153.txt.bz2 --nextPart3727438.asj57AJKQn Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 1795 On Thursday 04 February 2010 16:58:18 Doug Evans wrote: > On Wed, Feb 3, 2010 at 11:07 PM, Mike Frysinger wrote: > > if the do_write function (which is the real meat of sim_load_file()) > > fails, nothing is displayed in the load output to indicate a problem. = so > > check the return value before declaring everything peachy. > > > > 2010-02-04 Mike Frysinger > > > > * sim-load.c (sim_load_file): Check do_write() return value. > > > > RCS file: /cvs/src/src/sim/common/sim-load.c,v > > retrieving revision 1.14 > > diff -u -p -r1.14 sim-load.c > > --- sim/common/sim-load.c 1 Jan 2010 10:03:27 -0000 1.14 > > +++ sim/common/sim-load.c 4 Feb 2010 07:02:42 -0000 > > @@ -140,8 +140,10 @@ sim_load_file (sd, myname, callback, pro > > } > > data_count +=3D size; > > bfd_get_section_contents (result_bfd, s, buffer, 0, size); > > - do_write (sd, lma, buffer, size); > > - found_loadable_section =3D 1; > > + if (do_write (sd, lma, buffer, size) !=3D size) > > + eprintf (callback, "\tloading section failed\n"); > > + else > > + found_loadable_section =3D 1; > > free (buffer); > > } > > } >=20 > If there's an error loading a section I think it would be better to > fail the entire call. How about something like >=20 > if (do_write (sd, lma, buffer, size) !=3D size) > { > eprintf (callback, "%s: error loading section %s\n", > myname, bfd_get_section_name (result_bfd, s)); > /* Only close if we opened it. */ > if (prog_bfd =3D=3D NULL) > bfd_close (result_bfd); > free (buffer); > return NULL; > } that works for me too -mike --nextPart3727438.asj57AJKQn Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 836 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iQIcBAABAgAGBQJLa2P7AAoJEEFjO5/oN/WBlRIQALzr5a10yt5F+AQE+EB88vPm 15jcCLjAkc6AWtzdbvD60BTJ+9y1pCA0QwA8AcCXgeD6HeaXeIAV5sq8MXxdTShM xauiJgAOdTqR9YIOglqD9b/zvU6Zzu2QtCIkebWD6nFJDJAG8Pr6obM6/lA5bJpe 68h8AARj1X87SRma1w8cO/NXYdDhZTj6tm+P9WqqHWDDRcFSDnRoJsdhwHsYDGaf XbgZNl6gve1DPkTjmVPNaUVnXQusVZwKVIOK2sVSjNH2dNK4lLlMI9LsMcr/LFVC zd1a8Dh7IqeJwBAfZ83qBxqFQvjmbES5tcbWaI6LHctDJXFc7+Nk3sewWaUFs885 WBpLqQxaWOPDtC/6Pa7eLzI6abi/N2vqQn0F6zGmms4jE8M1pFu+7zrGSklK9ADr 0TYrsndU6n+x43+oj8GlwEUc1+szWut68bef/dpeCOdd1Gp7p/xCfryJuYf+2eZf YvbgJ8KFoLZOYv4j/KIfoSDIyiPAYNRZ/x24kmPBE1MMJrohPMmbrsnQtrr9/SRN mYY+LkcKtG/R3uxw289SL4WCI4gi8HAenMjKdFbMwkBKIo5li97/85Qy6ZUP29aP sbUMZm2tnQt20jU/fL5Z4KpBCxIJBb9uPV8h8pG4r0VjB9PeTyMJUifb6KaGyl0q q6DqImE7mr3dtekLlfw2 =fhqu -----END PGP SIGNATURE----- --nextPart3727438.asj57AJKQn--