From: pegacorn Date: 2007-07-16T21:23:01+09:00 Subject: [ruby-dev:31239] Re: trunk: バグを指摘している警告(cygwin) From: pegacorn Date: Sat, 14 Jul 2007 20:00:01 +0900 Message-Id: <20070714.195544.63132606.subscriber.jp@gmail.com> /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > trunk で -Wall を付けてコンパイルしてみると、バグを指摘している警告が > いくつか見付かりました。 今度は、cygwin 環境で -Wall を付けてコンパイルしてみました。 gcc -g -O2 -Wall -I. -I.ext/include/i386-cygwin -I./include -I. -DRUBY_EXPORT -c dln.c dln.c: In function `conv_to_posix_path': dln.c:1615: warning: implicit declaration of function `cygwin32_conv_to_posix_path' gcc -g -O2 -Wall -I. -I.ext/include/i386-cygwin -I./include -I. -DRUBY_EXPORT -c file.c file.c: In function `rb_thread_flock': file.c:3102: warning: implicit declaration of function `GetLastError' gcc -g -O2 -Wall -I. -I.ext/include/i386-cygwin -I./include -I. -DRUBY_EXPORT -c ruby.c ruby.c: In function `ruby_push_include': ruby.c:190: warning: implicit declaration of function `conv_to_posix_path' gcc -g -O2 -Wall -I. -I.ext/include/i386-cygwin -I./include -I. -DRUBY_EXPORT -c ./missing/strftime.c ./missing/strftime.c: In function `strftime': ./missing/strftime.c:448: warning: int format, long int arg (arg 3) ./missing/strftime.c:448: warning: int format, long int arg (arg 4) compiling Win32API gcc -I. -I../../.ext/include/i386-cygwin -I../.././include -I../.././ext/Win32API -DRUBY_EXTCONF_H=\"extconf.h\" -g -O2 -Wall -c Win32API.c Win32API.c: In function `Win32API_initialize': Win32API.c:111: warning: int format, long int arg (arg 3) compiling socket gcc -I. -I../../.ext/include/i386-cygwin -I../.././include -I../.././ext/socket -DRUBY_EXTCONF_H=\"extconf.h\" -I. -g -O2 -Wall -c getnameinfo.c getnameinfo.c: In function `inet_ntop': getnameinfo.c:126: warning: implicit declaration of function `snprintf' compiling tk gcc -I. -I../../.ext/include/i386-cygwin -I../.././include -I../.././ext/tk -DRUBY_EXTCONF_H=\"extconf.h\" -D_WIN32 -DWITH_TCL_ENABLE_THREAD=0 -g -O2 -Wall -c tcltklib.c tcltklib.c: In function `eventloop_sleep': tcltklib.c:1262: warning: implicit declaration of function `is_ruby_native_thread' tcltklib.c: In function `ip_finalize': tcltklib.c:4411: warning: long unsigned int format, pointer arg (arg 3) compiling win32ole gcc -I. -I../../.ext/include/i386-cygwin -I../.././include -I../.././ext/win32ole -DRUBY_EXTCONF_H=\"extconf.h\" -g -O2 -Wall -c win32ole.c win32ole.c: In function `lcid_installed': win32ole.c:2644: warning: unsigned int format, LCID arg (arg 4) Index: dln.c =================================================================== --- dln.c (revision 12800) +++ dln.c (working copy) @@ -69,6 +69,10 @@ char *getenv(); #endif +#ifdef __CYGWIN32__ +#include +#endif + #if defined(__VMS) #pragma builtins #include @@ -1602,21 +1606,23 @@ #if defined(__CYGWIN32__) const char * -conv_to_posix_path(char *win32, char *posix, int len) +conv_to_posix_path(const char *win32, char *posix, int len) { - char *first = win32; - char *p = win32; + char *first; + char *p; char *dst = posix; + first = alloca(strlen(win32)+1); + strcpy(first, win32); + posix[0] = '\0'; - for (p = win32; *p; p++) + for (p = first; *p; p++) if (*p == ';') { *p = 0; cygwin32_conv_to_posix_path(first, posix); posix += strlen(posix); *posix++ = ':'; first = p + 1; - *p = ';'; } if (len < strlen(first)) fprintf(stderr, "PATH length too long: %s\n", first); Index: dln.h =================================================================== --- dln.h (revision 12800) +++ dln.h (working copy) @@ -31,6 +31,9 @@ char *dln_find_exe(const char*,const char*); char *dln_find_file(const char*,const char*); +#ifdef __CYGWIN32__ +const char *conv_to_posix_path(const char *, char *, int); +#endif #ifdef USE_DLN_A_OUT extern char *dln_argv0; Index: ext/socket/getnameinfo.c =================================================================== --- ext/socket/getnameinfo.c (revision 12800) +++ ext/socket/getnameinfo.c (working copy) @@ -62,6 +62,9 @@ #include #define snprintf _snprintf #endif +#ifdef __CYGWIN__ +#include +#endif #include #include Index: ext/tk/tcltklib.c =================================================================== --- ext/tk/tcltklib.c (revision 12800) +++ ext/tk/tcltklib.c (working copy) @@ -4408,13 +4408,13 @@ } if (Tcl_InterpDeleted(ip)) { - DUMP2("ip(%lx) is already deleted", ip); + DUMP2("ip(%p) is already deleted", ip); return; } #if TCL_NAMESPACE_DEBUG if (ip_null_namespace(ip)) { - DUMP2("ip(%lx) has null namespace", ip); + DUMP2("ip(%p) has null namespace", ip); return; } #endif Index: ext/Win32API/Win32API.c =================================================================== --- ext/Win32API/Win32API.c (revision 12800) +++ ext/Win32API/Win32API.c (working copy) @@ -108,7 +108,7 @@ } if (16 < RARRAY_LEN(a_import)) { - rb_raise(rb_eRuntimeError, "too many parameters: %d\n", RARRAY_LEN(a_import)); + rb_raise(rb_eRuntimeError, "too many parameters: %ld\n", RARRAY_LEN(a_import)); } rb_iv_set(self, "__import__", a_import); Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 12800) +++ ext/win32ole/win32ole.c (working copy) @@ -2641,7 +2641,7 @@ lcid_installed(LCID lcid) { g_lcid_installed = FALSE; - snprintf(g_lcid_to_check, sizeof(g_lcid_to_check), "%08x", lcid); + snprintf(g_lcid_to_check, sizeof(g_lcid_to_check), "%08lx", lcid); EnumSystemLocales(installed_lcid_proc, LCID_INSTALLED); return g_lcid_installed; } Index: file.c =================================================================== --- file.c (revision 12800) +++ file.c (working copy) @@ -66,6 +66,11 @@ #define lstat stat #endif +#ifdef __CYGWIN__ +#include +#include +#endif + #ifdef __BEOS__ /* should not change ID if -1 */ static int be_chown(const char *path, uid_t owner, gid_t group) @@ -2215,7 +2220,6 @@ #endif if (rename(src, dst) < 0) { #if defined __CYGWIN__ - extern unsigned long __attribute__((stdcall)) GetLastError(void); if (errno == 0) { /* This is a bug of old Cygwin */ /* incorrect as cygwin errno, but the last resort */ errno = GetLastError(); @@ -3086,10 +3090,6 @@ # define LOCK_UN 8 # endif -#ifdef __CYGWIN__ -#include -#endif - static VALUE rb_thread_flock(rb_thread_t *th, void *data) { Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 12800) +++ include/ruby/intern.h (working copy) @@ -279,6 +279,7 @@ VALUE rb_thread_local_aset(VALUE, ID, VALUE); void rb_thread_atfork(void); VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE); +VALUE is_ruby_native_thread(void); /* file.c */ VALUE rb_file_s_expand_path(int, VALUE *); VALUE rb_file_expand_path(VALUE, VALUE); Index: missing/strftime.c =================================================================== --- missing/strftime.c (revision 12800) +++ missing/strftime.c (working copy) @@ -445,7 +445,7 @@ } else { tbuf[0] = '+'; } - sprintf(tbuf+1, "%02d%02d", off/60, off%60); + sprintf(tbuf+1, "%02ld%02ld", off/60, off%60); break; #endif /* MAILHEADER_EXT */ -- pegacorn