From: Christoph Egger Subject: Re: libxl: build fix Date: Tue, 9 Nov 2010 12:39:51 +0100 Message-ID: <201011091239.51488.Christoph.Egger@amd.com> References: <201011051608.47100.Christoph.Egger@amd.com> <201011081753.00581.Christoph.Egger@amd.com> <19672.11522.721373.795832@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_HMT2MO62mqvaYsP" Return-path: In-Reply-To: <19672.11522.721373.795832@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --Boundary-00=_HMT2MO62mqvaYsP Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Monday 08 November 2010 18:01:54 Ian Jackson wrote: > Look at the code and you will see that it assumes that basename does > not modify its argument. I'm about to push a const-correctness fix > which will make this more obvious and cause your broken attempt at a > fix not to compile :-). I rebased my source tree and yes, it does not compile. > > > and the xl code, the version of > > > basename() expected by the libxl cpuid code is the GNU one, > > > not the POSIX one, and they have different semantics. I think we will > > > have to open code an implementation of basename. > > > > Can you imagine to make Xen tools prefer POSIX over GNU in general, > > please? > > I agree that the current code is a mistake. The POSIX basename is > irritating and we shouldn't use it. Simply open coding a search for a > '/' will be fine. Attached patch replaces basename with strrchr(3). Signed-off-by: Christoph Egger -- ---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632 --Boundary-00=_HMT2MO62mqvaYsP Content-Type: text/x-diff; charset="iso 8859-15"; name="xen_buildxl.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_buildxl.diff" Content-Description: xen_buildxl.diff diff -r fcdab7bf732b -r 35070850561e tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -5323,7 +5323,7 @@ int main_tmem_freeable(int argc, char ** int main_cpupoolcreate(int argc, char **argv) { - const const char *filename = NULL; + const char *filename = NULL; const char *p; char extra_config[1024]; int dryrun = 0; @@ -5430,7 +5430,7 @@ int main_cpupoolcreate(int argc, char ** if (!xlu_cfg_get_string (config, "name", &buf)) name = strdup(buf); else - name = basename(filename); + name = strrchr(filename, '/'); if (!libxl_name_to_cpupoolid(&ctx, name, &poolid)) { fprintf(stderr, "Pool name \"%s\" already exists\n", name); return -ERROR_FAIL; --Boundary-00=_HMT2MO62mqvaYsP Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_HMT2MO62mqvaYsP--