Changeset: c683938ff13b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c683938ff13b
Modified Files:
tools/mserver/mserver5.c
Branch: Dec2011
Log Message:
modpath: don't use dirname twice on the same pointer
At least on Darwin, dirname apparently does a copy to a static location,
and hence valgrind complains that the strpy has equal source and
destination pointers. Avoid doing this (even though it shouldn't harm
in this case), and simply use strrchr to eat away the two last
components of the path.
diffs (37 lines):
diff --git a/tools/mserver/mserver5.c b/tools/mserver/mserver5.c
--- a/tools/mserver/mserver5.c
+++ b/tools/mserver/mserver5.c
@@ -440,15 +440,25 @@ main(int argc, char **av)
struct stat sb;
char *binpath = get_bin_path();
if (binpath != NULL) {
- binpath = dirname(binpath);
- binpath = dirname(binpath);
- for (i = 0; libdirs[i] != NULL; i++) {
- snprintf(prmodpath, sizeof(prmodpath),
"%s%c%s%cmonetdb5",
- binpath, DIR_SEP, libdirs[i],
DIR_SEP);
- if (stat(prmodpath, &sb) == 0) {
- modpath = prmodpath;
- break;
+ char *p = strrchr(binpath, '/');
+ if (p != NULL)
+ *p = '\0';
+ p = strrchr(binpath, '/');
+ if (p != NULL) {
+ *p = '\0';
+ for (i = 0; libdirs[i] != NULL; i++) {
+ snprintf(prmodpath, sizeof(prmodpath),
"%s%c%s%cmonetdb5",
+ binpath, DIR_SEP,
libdirs[i], DIR_SEP);
+ if (stat(prmodpath, &sb) == 0) {
+ modpath = prmodpath;
+ break;
+ }
}
+ } else {
+ printf("#warning: unusable binary location, "
+ "please use --set
monet_mod_path=/path/to/... to "
+ "allow finding modules\n");
+ fflush(NULL);
}
} else {
printf("#warning: unable to determine binary location, "
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list