[Monetdb-developers] [PATCH] Mx Io.c more specific errors

Stefan Manegold Stefan.Manegold at cwi.nl
Thu Aug 3 13:51:58 CEST 2006


Hi,

I'd stongly vote for checking your changes in --- detailed and informative
error messages are more than "handy" for both developers (debugging!) and
users --- in case there are any Windows related problems, we should find and
solve them, not try to avoid them.

I'm not sure about the error.h (it's never used (directly) in the whole
MonetDB related code base), 
but there surely seems to be a strerror on Windows --- at least our
Windows-specific config headers say so:
========
./MonetDB/configure.ag:AC_CHECK_FUNCS(strcspn strdup strstr strtod strtof strtol strerror strcasecmp strncasecmp)
./MonetDB/NT/monetdb_config.h.in:/* Define to 1 if you have the `strerror' function. */
./MonetDB/NT/monetdb_config.h.in:#define HAVE_STRERROR 1
./MonetDB/NT/monetdb_config.h.in:/* Define to 1 if you have the `strerror' function. */
./MonetDB/NT/monetdb_config.h.in:#define HAVE_STRERROR 1
./MonetDB/src/gdk/gdk_utils.mx:         char *osmsg = strerror(err);
./sql/NT/winconfig.h:/* Define to 1 if you have the `strerror' function. */
./sql/NT/winconfig.h:#define HAVE_STRERROR 1
========

Stefan


On Thu, Aug 03, 2006 at 11:29:35AM +0200, Fabian Groffen wrote:
> Hi devs,
> 
> I ran into a problem with Mx, where IoWriteToFile seemed to have a
> problem but didn't tell exactly what.  With the attached patch, I was
> able to figure out what the problem was.  I don't like to commit it, as
> the Mx code is completely unknown to me.  Also, I have no ideas on the
> effects on this highly portable piece of code on Windows.  If someone
> considers it useful to commit, please do.

> --- Io.c
> +++ Io.c
> @@ -25,6 +25,7 @@
>  #include "MxFcnDef.h"
>  #include <sys/types.h>
>  #include <sys/stat.h>
> +#include <errno.h>
>  #if HAVE_UNISTD_H
>  #include <unistd.h>
>  #endif
> @@ -204,7 +205,7 @@
>  			    (p != fname + 2 || fname[1] != ':') &&
>  #endif
>  			    stat(fname, &buf) < 0 && mkdir(fname, S_IRWXU) < 0)
> -				Fatal("fmustopen:", "Can't create directory %s\n", fname);
> +				Fatal("fmustopen:", "Can't create directory %s:%s\n", fname, strerror(errno));
>  			*p = DIR_SEP;
>  		}
>  	}
> @@ -230,12 +231,12 @@
>  	if ((f->f_mode & m) == m) {
>  		ofile = fmustopen(f->f_tmp, "a");
>  		if (ofile == NULL)
> -			Fatal("IoWriteFile", "can't append to:%s", f->f_tmp);
> +			Fatal("IoWriteFile", "can't append to %s: %s", f->f_tmp, strerror(errno));
>  	} else {
>  		f->f_mode |= m;
>  		ofile = fmustopen(f->f_tmp, "w");
>  		if (ofile == NULL)
> -			Fatal("IoWriteFile", "can't create:%s", f->f_tmp);
> +			Fatal("IoWriteFile", "can't create %s: %s", f->f_tmp, strerror(errno));
>  		if (disclaimer)
>  			insertDisclaimer(ofile, f->f_tmp);
>  	}

> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Monetdb-developers mailing list
> Monetdb-developers at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-developers


-- 
| Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
| CWI,  P.O.Box 94079 | http://www.cwi.nl/~manegold/  |
| 1090 GB Amsterdam   | Tel.: +31 (20) 592-4212       |
| The Netherlands     | Fax : +31 (20) 592-4312       |




More information about the developers-list mailing list