From: Ian Jackson Subject: Re: [PATCH 2/2] tools/console: xenconsole tolerate tty errors Date: Tue, 18 Mar 2014 17:58:54 +0000 Message-ID: <21288.35166.479652.469692@mariner.uk.xensource.com> References: <1395073457-2584-1-git-send-email-ian.jackson@eu.citrix.com> <1395073457-2584-3-git-send-email-ian.jackson@eu.citrix.com> <1395163676.11824.44.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395163676.11824.44.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: George Dunlap , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [PATCH 2/2] tools/console: xenconsole tolerate tty errors"): > On Mon, 2014-03-17 at 16:24 +0000, Ian Jackson wrote: > > Since 28d386fc4341 (XSA-57), libxl writes an empty value for the > > console tty node, with read-only permission for the guest, when > > setting up pv console "frontends". (The actual tty value is later set > > by xenconsoled.) Writing an empty node is not strictly necessary to > > stop the frontend from writing dangerous values here, but it is a good > > belt-and-braces approach. ... > > if (pty_path != NULL) { > > - pty_fd = open(pty_path, O_RDWR | O_NOCTTY); > > - if (pty_fd == -1) > > - err(errno, "Could not open tty `%s'", pty_path); > > + if (pty_path[0] != '\0') { > > Can the top-level condition not be > if ( pty_path != NULL && pty_path[0] != '\0' ) > avoiding the reindent? That would leak pty_path. I could move free(pty_path) out of the if, though. I think that would be better. Ian.