From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5704 invoked by alias); 27 Jun 2013 20:21:45 -0000 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 Received: (qmail 5677 invoked by uid 89); 27 Jun 2013 20:21:40 -0000 X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 20:21:39 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5RKLcgS028878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Jun 2013 16:21:38 -0400 Received: from barimba (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5RKLaBU021724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 27 Jun 2013 16:21:37 -0400 From: Tom Tromey To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 04/16] push remote_desc into struct remote_state References: <1371835506-15691-1-git-send-email-tromey@redhat.com> <1371835506-15691-5-git-send-email-tromey@redhat.com> <51C880C5.6050307@redhat.com> Date: Thu, 27 Jun 2013 20:29:00 -0000 In-Reply-To: <51C880C5.6050307@redhat.com> (Pedro Alves's message of "Mon, 24 Jun 2013 18:24:21 +0100") Message-ID: <87bo6rmhin.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-06/txt/msg00860.txt.bz2 >>>>> "Pedro" == Pedro Alves writes: >> @@ -10194,8 +10202,9 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty) >> FILE *file; >> gdb_byte *buffer; >> ULONGEST offset; >> + struct remote_state *rs = get_remote_state (); >> >> - if (!remote_desc) >> + if (!rs->remote_desc) >> error (_("command can only be used with remote target")); Pedro> This looks conceptually fishy. Pedro> A rs == NULL check would be less surprising. After all, if Pedro> we were multi-target already, and not using the remote target, Pedro> get_remote_state would most naturally return NULL. Pedro> But if not using the remote target, we probably shouldn't Pedro> be getting here anyway. Pedro> remote_file_get could nowadays be using the target_fileio_XXX methods Pedro> instead of remote_hostio_XXX, and therefore the command could be Pedro> generalized to work with all targets. Pedro> Something to keep in mind, and file under fix-it-later... Not sure Pedro> we have tests for these commands that try them when not connected to Pedro> a remote target. Thanks Pedro. You saw the future quite accurately here. I did see crashes in this code after the multi-target conversion, precisely because I changed get_remote_state to return NULL when not connected; and this path is exercised by the test suite. So, a later patch will introduce the == NULL check as well. In this series, though, get_remote_state cannot return NULL. This may seem odd, but it is consistent with the state of the code before the series -- and I wanted to try to make this series obviously not behavior-changing. Tom