From: <n-...@us...> - 2010-11-19 01:49:38
|
Revision: 4926 http://gfarm.svn.sourceforge.net/gfarm/?rev=4926&view=rev Author: n-soda Date: 2010-11-19 01:49:32 +0000 (Fri, 19 Nov 2010) Log Message: ----------- fix the following problems, both pointed out by tbaba@-san: * return value of gfarm_path_dir_skip() shouldn't be freed. * fix the following warning: {{{ warning: assignment discards qualifiers from pointer target type }}} Modified Paths: -------------- gfarm_v2/trunk/gftool/gfpath/gfpath.c Modified: gfarm_v2/trunk/gftool/gfpath/gfpath.c =================================================================== --- gfarm_v2/trunk/gftool/gfpath/gfpath.c 2010-11-18 20:11:31 UTC (rev 4925) +++ gfarm_v2/trunk/gftool/gfpath/gfpath.c 2010-11-19 01:49:32 UTC (rev 4926) @@ -20,7 +20,8 @@ { gfarm_error_t e; int ch, mode = 0; - char *path, *s; + const char *s; + char *path, *allocated = NULL; if (argc > 0) program_name = basename(argv[0]); @@ -51,20 +52,17 @@ switch (mode) { case 'd': - s = gfarm_url_dir(path); + s = allocated = gfarm_url_dir(path); break; case 'B': s = gfarm_path_dir_skip(path); break; case 'D': - s = gfarm_path_dir(path); + s = allocated = gfarm_path_dir(path); break; default: usage(); /*NOTREACHED*/ -#ifdef __GNUC__ /* workaround gcc warning: may be used uninitialized */ - s = NULL; -#endif } if (s == NULL) { fprintf(stderr, "%s: no memory for \"%s\"\n", @@ -72,7 +70,7 @@ exit(1); } printf("%s\n", s); - free(s); + free(allocated); e = gfarm_terminate(); if (e != GFARM_ERR_NO_ERROR) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |