From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: Re: [PATCH v3 1/5] libxl: allow libxl__exec to take a parameter containing the env variables Date: Mon, 23 Apr 2012 16:37:50 +0100 Message-ID: <20373.30542.669565.492586@mariner.uk.xensource.com> References: <1334928211-29856-1-git-send-email-roger.pau@citrix.com> <1334928211-29856-2-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1334928211-29856-2-git-send-email-roger.pau@citrix.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: Roger Pau Monne Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org Roger Pau Monne writes ("[Xen-devel] [PATCH v3 1/5] libxl: allow libxl__exec to take a parameter containing the env variables"): > Add another parameter to libxl__exec call that contains the > environment variables to use when performing the execvp call. This looks OK to me. However, shouldn't this be const char** ? > struct termios termattr; > + char *env[] = {"TERM", "vt100", NULL}; We don't compile with -Wwrite-strings but if we did this would trigger. Also it needs spaces inside { } I think. > + if (env != NULL) { > + for (int i = 0; env[i] != NULL && env[i+1] != NULL; i += 2) { > + setenv(env[i], env[i+1], 1); setenv can fail. If it does you should probably check errno and probably call libxl__alloc_failed. > +/* > + * env should be passed using the following format, > + * > + * env[0]: name of env variable > + * env[1]: value of env variable You need to mention that it may have more than one setting! Ian.