[Monetdb-developers] [PATCH] Mx Io.c more specific errors
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.
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
#include +#include #if HAVE_UNISTD_H #include #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@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-developers
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@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 |
On 03-08-2006 13:51:58 +0200, Stefan Manegold wrote:
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
errno.h it's effect can be mimicked by "extern int errno;", but that is a bit dirty. It is necessary to be able to access the errno variable that at least all io related functions set.
On 2006-08-03 13:57, Fabian Groffen wrote:
On 03-08-2006 13:51:58 +0200, Stefan Manegold wrote:
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
errno.h it's effect can be mimicked by "extern int errno;", but that is a bit dirty. It is necessary to be able to access the errno variable that at least all io related functions set.
No, you can't use extern int errno; instead of including errno.h. errno could be declared in some weird way, especially in environments that allow multi-threaded programs, so that it *looks* like a simple int but is in fact something else. The C99 standard has this in a footnote: The macro errno need not be the identifier of an object. It might expand to a modifiable lvalue resulting from a function call (for example, *errno()). -- Sjoerd Mullender
On Thu, Aug 03, 2006 at 02:32:21PM +0200, Sjoerd Mullender wrote:
On 2006-08-03 13:57, Fabian Groffen wrote:
On 03-08-2006 13:51:58 +0200, Stefan Manegold wrote:
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
errno.h it's effect can be mimicked by "extern int errno;", but that is a bit dirty. It is necessary to be able to access the errno variable that at least all io related functions set.
indeed my fault, sorry --- and yes, we do include errno.h "blindly" without
checks or conditions, hence, it should also be available on windows:
========
MonetDB/src/common/monet_utils.mx:#include
No, you can't use extern int errno; instead of including errno.h. errno could be declared in some weird way, especially in environments that allow multi-threaded programs, so that it *looks* like a simple int but is in fact something else. The C99 standard has this in a footnote:
The macro errno need not be the identifier of an object. It might expand to a modifiable lvalue resulting from a function call (for example, *errno()).
-- Sjoerd Mullender
-- | Dr. Stefan Manegold | mailto:Stefan.Manegold@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 |
participants (3)
-
Fabian Groffen
-
Sjoerd Mullender
-
Stefan Manegold