From 1e6b7332891c7f90a46dfba5be32b95a4730cca7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 4 Sep 2008 13:28:49 +0000 Subject: [PATCH] 2008-09-04 09:43 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * make_vc.mak * contrib/mtpl_vc.mak + -w34701 VC flag added to enabled warning 4701 (uninitialized vars) on -W3 level. % -FD VC flag removed. This is only needed for IDEs. % -Gs VC flag moved to the common section. % VC flags synced in contrib with core. + TOFIX added for WinCE command line. It's full of stuff which is _probably_ not needed. + NOTE added about MSDN page explaining VC switches. ; NOTE: -W4 and -Wp64 are recommended for MSVC. ; TOFIX: There are still a few uninit vars warnings: harboury.c(7226) : warning C4701: potentially uninitialized local variable 'hb_complval' used macroy.c(3095) : warning C4701: potentially uninitialized local variable 'hb_macrolval' used dbffpt1.c(2671) : warning C4701: potentially uninitialized local variable 'ulType' used dbffpt1.c(2614) : warning C4701: potentially uninitialized local variable 'ulSize' used dbffpt1.c(3073) : warning C4701: potentially uninitialized local variable 'ulOldSize' used dbffpt1.c(3083) : warning C4701: potentially uninitialized local variable 'ulBlock' used dbffpt1.c(3652) : warning C4701: potentially uninitialized local variable 'pBlock' used * source/rdd/workarea.c ! Fixed DBI_POSITIONED value returned. * include/hbsetup.h * source/vm/pvalue.c * source/rtl/fserror.c * source/rtl/accept.c * source/rtl/descend.c * source/rtl/inkey.c * source/rtl/dates.c * source/rtl/fkmax.c * source/rtl/natmsg.c * source/rtl/hbinet.c * source/rtl/dates.c ! Fixed some MSVS2008 -W4 warnings (we use -W3 as the default). ; NOTE: There is a lot more of these. * source/rtl/dates.c * Formatting. --- harbour/ChangeLog | 39 ++++++++++++++++++++++ harbour/contrib/mtpl_vc.mak | 7 ++-- harbour/include/hbsetup.h | 2 +- harbour/make_vc.mak | 12 ++++--- harbour/source/rdd/workarea.c | 3 +- harbour/source/rtl/accept.c | 2 +- harbour/source/rtl/dates.c | 61 ++++++++++++++++++----------------- harbour/source/rtl/descend.c | 2 +- harbour/source/rtl/fkmax.c | 2 +- harbour/source/rtl/fserror.c | 7 ++-- harbour/source/rtl/hbinet.c | 12 +++---- harbour/source/rtl/inkey.c | 2 +- harbour/source/rtl/natmsg.c | 6 ++-- harbour/source/vm/pvalue.c | 2 +- 14 files changed, 103 insertions(+), 56 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 807339869c..8fb1a9c162 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,45 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-09-04 09:43 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * make_vc.mak + * contrib/mtpl_vc.mak + + -w34701 VC flag added to enabled warning 4701 (uninitialized vars) on -W3 level. + % -FD VC flag removed. This is only needed for IDEs. + % -Gs VC flag moved to the common section. + % VC flags synced in contrib with core. + + TOFIX added for WinCE command line. It's full of stuff which is _probably_ not needed. + + NOTE added about MSDN page explaining VC switches. + ; NOTE: -W4 and -Wp64 are recommended for MSVC. + ; TOFIX: There are still a few uninit vars warnings: + harboury.c(7226) : warning C4701: potentially uninitialized local variable 'hb_complval' used + macroy.c(3095) : warning C4701: potentially uninitialized local variable 'hb_macrolval' used + dbffpt1.c(2671) : warning C4701: potentially uninitialized local variable 'ulType' used + dbffpt1.c(2614) : warning C4701: potentially uninitialized local variable 'ulSize' used + dbffpt1.c(3073) : warning C4701: potentially uninitialized local variable 'ulOldSize' used + dbffpt1.c(3083) : warning C4701: potentially uninitialized local variable 'ulBlock' used + dbffpt1.c(3652) : warning C4701: potentially uninitialized local variable 'pBlock' used + + * source/rdd/workarea.c + ! Fixed DBI_POSITIONED value returned. + + * include/hbsetup.h + * source/vm/pvalue.c + * source/rtl/fserror.c + * source/rtl/accept.c + * source/rtl/descend.c + * source/rtl/inkey.c + * source/rtl/dates.c + * source/rtl/fkmax.c + * source/rtl/natmsg.c + * source/rtl/hbinet.c + * source/rtl/dates.c + ! Fixed some MSVS2008 -W4 warnings (we use -W3 as the default). + ; NOTE: There is a lot more of these. + + * source/rtl/dates.c + * Formatting. + 2008-09-03 23:06 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/hbziparc/hbziparc.prg ! Fix to one of the rarely used function names. diff --git a/harbour/contrib/mtpl_vc.mak b/harbour/contrib/mtpl_vc.mak index 56ec7f033a..80150dfcf0 100644 --- a/harbour/contrib/mtpl_vc.mak +++ b/harbour/contrib/mtpl_vc.mak @@ -118,13 +118,14 @@ HB_VISUALC_VER = 80 # C Compiler Flags !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Ot2b1 -FD -Gs -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Ot2b1 -EHs-c- -D_CRT_SECURE_NO_DEPRECATE !else -CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX -FD -Gs +CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX !endif #----------- -CFLAGS = -I$(INCLUDE_DIR) $(CFLAGS_VER) -W3 -nologo -T$(HB_BUILD_MODE) $(C_USR) $(CFLAGS) +CFLAGS = -nologo -W3 -w34701 -Gs -I$(INCLUDE_DIR) $(CFLAGS_VER) -T$(HB_BUILD_MODE) \ + $(C_USR) $(CFLAGS) -I$(OBJ_DIR) #----------- !if "$(HB_BUILD_DEBUG)" == "yes" diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index 5e795c23a0..33f9a69ff3 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -302,7 +302,7 @@ /* Sub-option inside HB_OS_WIN_32 */ #ifndef HB_WINCE - #if defined(_WINCE) || defined(__CEGCC__) || defined(__MINGW32CE__) || (__POCC_TARGET__ == 2) + #if defined(_WINCE) || defined(__CEGCC__) || defined(__MINGW32CE__) || (defined(__POCC_TARGET__) && __POCC_TARGET__ == 2) #define HB_WINCE #endif #endif diff --git a/harbour/make_vc.mak b/harbour/make_vc.mak index 30de664102..fe77dec565 100644 --- a/harbour/make_vc.mak +++ b/harbour/make_vc.mak @@ -141,11 +141,13 @@ HB_BUILD_MODE = C !if "$(HB_BUILD_WINCE)" == "yes" !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Od -Os -Gy -GS- -EHsc- -fp:fast -Gm -Zi -GR- -FD -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Od -Os -Gy -GS- -EHsc- -fp:fast -Gm -Zi -GR- -D_CRT_SECURE_NO_DEPRECATE !else CFLAGS_VER = -Oxsb1 -EHsc -YX -GF !endif +# TOFIX: These should be cleaned from everything not absolutely necessary: + CFLAGS = -nologo -W3 -I$(INCLUDE_DIR) -I$(CFLAGS_VER) -T$(HB_BUILD_MODE) \ -D"_WIN32_WCE=0x420" -D"UNDER_CE=0x420" -D"WIN32_PLATFORM_PSPC" \ -D"WINCE" -D"_WINCE" -D"_WINDOWS" -D"ARM" -D"_ARM_" -D"ARMV4" \ @@ -166,13 +168,15 @@ CFLAGS = $(CFLAGS) -D "NDEBUG" !else +# NOTE: See here: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx + !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Ot2b1 -EHs-c- -FD -Gs -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Ot2b1 -EHs-c- -D_CRT_SECURE_NO_DEPRECATE !else -CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX -FD -Gs +CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX !endif -CFLAGS = -nologo -W3 -I$(INCLUDE_DIR) $(CFLAGS_VER) -T$(HB_BUILD_MODE) \ +CFLAGS = -nologo -W3 -w34701 -Gs -I$(INCLUDE_DIR) $(CFLAGS_VER) -T$(HB_BUILD_MODE) \ $(C_USR) $(CFLAGS) -I$(OBJ_DIR) #----------- diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index ef57f8e2dd..4227dc96a1 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -845,7 +845,8 @@ static ERRCODE hb_waInfo( AREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) hb_itemPutL( pItem, TRUE ); else if( SELF_RECCOUNT( pArea, &ulRecCount ) != SUCCESS ) return FAILURE; - hb_itemPutL( pItem, ulRecNo != ulRecCount + 1 ); + else + hb_itemPutL( pItem, ulRecNo != ulRecCount + 1 ); break; } case DBI_RM_SUPPORTED: diff --git a/harbour/source/rtl/accept.c b/harbour/source/rtl/accept.c index bf5bcc7da1..79160f6c15 100644 --- a/harbour/source/rtl/accept.c +++ b/harbour/source/rtl/accept.c @@ -111,7 +111,7 @@ HB_FUNC( __ACCEPT ) default: if( ulLen < ( ACCEPT_BUFFER_LEN - 1 ) && input >= 32 && input <= 255 ) { - szAcceptResult[ ulLen ] = input; /* Accept the input */ + szAcceptResult[ ulLen ] = ( char ) input; /* Accept the input */ hb_conOutAlt( &szAcceptResult[ ulLen ], sizeof( char ) ); /* Then display it */ ulLen++; /* Then adjust the input count */ } diff --git a/harbour/source/rtl/dates.c b/harbour/source/rtl/dates.c index c5dc97e451..8b5fddcdfa 100644 --- a/harbour/source/rtl/dates.c +++ b/harbour/source/rtl/dates.c @@ -50,18 +50,6 @@ * */ -/* - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * Copyright 1999 David G. Holm - * hb_dateFormat() - * hb_dateUnformat() - * - * See doc/license.txt for licensing terms. - * - */ - #include #include "hbapi.h" @@ -82,7 +70,8 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con * Determine the maximum size of the formatted date string */ size = strlen( szDateFormat ); - if( size > 10 ) size = 10; + if( size > 10 ) + size = 10; if( szDate && szFormattedDate && strlen( szDate ) == 8 ) /* A valid date is always 8 characters */ { @@ -102,7 +91,8 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con while( toupper( ( UCHAR ) *szPtr ) == digit && format_count < size ) { szPtr++; - if( format_count + digit_count < size ) digit_count++; + if( format_count + digit_count < size ) + digit_count++; } switch( digit ) { @@ -112,14 +102,14 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con case 4: if( ! used_d && format_count < size ) { -/* szFormattedDate[ format_count++ ] = '0'; */ + /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 6 ]; digit_count--; } case 3: if( ! used_d && format_count < size ) { -/* szFormattedDate[ format_count++ ] = '0'; */ + /* szFormattedDate[ format_count++ ] = '0'; */ szFormattedDate[ format_count++ ] = szDate[ 6 ]; digit_count--; } @@ -135,7 +125,8 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con szFormattedDate[ format_count++ ] = szDate[ 7 ]; digit_count--; } - while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = digit; + while( digit_count-- > 0 && format_count < size ) + szFormattedDate[ format_count++ ] = digit; } used_d = TRUE; break; @@ -169,7 +160,8 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con szFormattedDate[ format_count++ ] = szDate[ 5 ]; digit_count--; } - while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = digit; + while( digit_count-- > 0 && format_count < size ) + szFormattedDate[ format_count++ ] = digit; } used_m = TRUE; break; @@ -204,13 +196,15 @@ HB_EXPORT char * hb_dateFormat( const char * szDate, char * szFormattedDate, con szFormattedDate[ format_count++ ] = szDate[ 3 ]; digit_count--; } - while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = digit; + while( digit_count-- > 0 && format_count < size ) + szFormattedDate[ format_count++ ] = digit; } used_y = TRUE; break; default: - while( digit_count-- > 0 && format_count < size ) szFormattedDate[ format_count++ ] = digit; + while( digit_count-- > 0 && format_count < size ) + szFormattedDate[ format_count++ ] = digit; } } } @@ -261,27 +255,36 @@ HB_EXPORT long hb_dateUnformat( const char * szDate, const char * szDateFormat ) case 'd': if( d_pos == 0 ) { - if( m_pos == 0 && y_pos == 0 ) d_pos = 1; - else if( m_pos == 0 || y_pos == 0 ) d_pos = 2; - else d_pos = 3; + if( m_pos == 0 && y_pos == 0 ) + d_pos = 1; + else if( m_pos == 0 || y_pos == 0 ) + d_pos = 2; + else + d_pos = 3; } break; case 'M': case 'm': if( m_pos == 0 ) { - if( d_pos == 0 && y_pos == 0 ) m_pos = 1; - else if( d_pos == 0 || y_pos == 0 ) m_pos = 2; - else m_pos = 3; + if( d_pos == 0 && y_pos == 0 ) + m_pos = 1; + else if( d_pos == 0 || y_pos == 0 ) + m_pos = 2; + else + m_pos = 3; } break; case 'Y': case 'y': if( y_pos == 0 ) { - if( m_pos == 0 && d_pos == 0 ) y_pos = 1; - else if( m_pos == 0 || d_pos == 0 ) y_pos = 2; - else y_pos = 3; + if( m_pos == 0 && d_pos == 0 ) + y_pos = 1; + else if( m_pos == 0 || d_pos == 0 ) + y_pos = 2; + else + y_pos = 3; } } } diff --git a/harbour/source/rtl/descend.c b/harbour/source/rtl/descend.c index 41c26f4a4a..b420423c8a 100644 --- a/harbour/source/rtl/descend.c +++ b/harbour/source/rtl/descend.c @@ -62,7 +62,7 @@ void hb_strDescend( char * szStringTo, const char * szStringFrom, ULONG ulLen ) else { for(; ulLen--; szStringTo++, szStringFrom++ ) - *szStringTo = 256 - *szStringFrom; + *szStringTo = ( char ) ( 256 - *szStringFrom ); } } diff --git a/harbour/source/rtl/fkmax.c b/harbour/source/rtl/fkmax.c index aff8f0d185..4d1288dea5 100644 --- a/harbour/source/rtl/fkmax.c +++ b/harbour/source/rtl/fkmax.c @@ -68,7 +68,7 @@ HB_FUNC( FKLABEL ) if( pPar1 ) { - USHORT uiFKey = hb_itemGetNI( pPar1 ); + USHORT uiFKey = ( USHORT ) hb_itemGetNI( pPar1 ); if( uiFKey > 0 && uiFKey <= 40 ) { diff --git a/harbour/source/rtl/fserror.c b/harbour/source/rtl/fserror.c index 6d00c0001b..37982f2735 100644 --- a/harbour/source/rtl/fserror.c +++ b/harbour/source/rtl/fserror.c @@ -171,7 +171,7 @@ static int hb_WinToDosError( ULONG ulError ) break; default: - iResult = ( int ) ulError ; + iResult = ( int ) ulError; break; } @@ -223,7 +223,6 @@ HB_EXPORT void hb_fsSetError( USHORT uiError ) /* set error code for last operation */ HB_EXPORT void hb_fsSetIOError( BOOL fResult, USHORT uiOperation ) { - /* TODO: implement it */ HB_SYMBOL_UNUSED( uiOperation ); @@ -234,8 +233,8 @@ HB_EXPORT void hb_fsSetIOError( BOOL fResult, USHORT uiOperation ) else { #if defined(HB_WIN32_IO) || defined(HB_OS_WIN_32) - s_uiOsErrorLast = (USHORT) GetLastError(); - s_uiErrorLast = hb_WinToDosError( s_uiOsErrorLast ); + s_uiOsErrorLast = ( USHORT ) GetLastError(); + s_uiErrorLast = ( USHORT ) hb_WinToDosError( s_uiOsErrorLast ); #elif defined(_MSC_VER) || defined(__DMC__) #ifdef __XCC__ extern unsigned long _doserrno; diff --git a/harbour/source/rtl/hbinet.c b/harbour/source/rtl/hbinet.c index 59c4892f5d..b34a426dcc 100644 --- a/harbour/source/rtl/hbinet.c +++ b/harbour/source/rtl/hbinet.c @@ -994,8 +994,8 @@ static void s_inetRecvPattern( char *szPattern ) PHB_ITEM pMaxSize = hb_param( 3, HB_IT_NUMERIC ); PHB_ITEM pBufferSize = hb_param( 4, HB_IT_NUMERIC ); - char cChar; - char *Buffer; + char cChar = '\0'; + char * Buffer; int iAllocated, iBufferSize, iMax; int iLen = 0, iPatLen; int iPos = 0, iTimeElapsed; @@ -1146,9 +1146,9 @@ HB_FUNC( HB_INETRECVENDBLOCK ) PHB_ITEM pMaxSize = hb_param( 4, HB_IT_NUMERIC ); PHB_ITEM pBufferSize = hb_param( 5, HB_IT_NUMERIC ); - char cChar; - char *Buffer; - char **Proto; + char cChar = '\0'; + char * Buffer; + char ** Proto; int iAllocated, iBufferSize, iMax; int iLen; int iPos = 0; @@ -1256,7 +1256,7 @@ HB_FUNC( HB_INETRECVENDBLOCK ) int protos; bProtoFound = 0; - for( protos=0; protos < iprotos; protos++ ) + for( protos = 0; protos < iprotos; protos++ ) { if( cChar == Proto[protos][iprotosize[protos]-1] && iprotosize[protos] <= iPos ) { diff --git a/harbour/source/rtl/inkey.c b/harbour/source/rtl/inkey.c index 7cfbf14907..50e5ec6952 100644 --- a/harbour/source/rtl/inkey.c +++ b/harbour/source/rtl/inkey.c @@ -81,7 +81,7 @@ static PHB_ITEM s_inkeyBlockAfter = NULL; HB_FUNC( INKEY ) { - USHORT uiPCount = hb_pcount(); + USHORT uiPCount = ( USHORT ) hb_pcount(); PHB_ITEM pKey = NULL; int iKey; diff --git a/harbour/source/rtl/natmsg.c b/harbour/source/rtl/natmsg.c index 82d0500b51..f16e38d2ad 100644 --- a/harbour/source/rtl/natmsg.c +++ b/harbour/source/rtl/natmsg.c @@ -86,11 +86,11 @@ #define _LF_YN 12 /* "Y/N" */ /* NOTE: This must be in uppercase. [vszakats] */ #define _INVALID_EXPR 13 /* "INVALID EXPRESSION" */ -static char * hb_nationGetMsg( USHORT uiMsg ) +static char * hb_nationGetMsg( int iMsg ) { - HB_TRACE(HB_TR_DEBUG, ("hb_nationGetMsg(%hu)", uiMsg)); + HB_TRACE(HB_TR_DEBUG, ("hb_nationGetMsg(%hu)", iMsg)); - return ( uiMsg >= 1 && uiMsg <= 13 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + uiMsg - 1 ) : ( char * ) ""; + return ( iMsg >= 1 && iMsg <= 13 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + iMsg - 1 ) : ( char * ) ""; } HB_FUNC( __NATISAFFIRM ) diff --git a/harbour/source/vm/pvalue.c b/harbour/source/vm/pvalue.c index b98eeb0fa3..29352c42d7 100644 --- a/harbour/source/vm/pvalue.c +++ b/harbour/source/vm/pvalue.c @@ -58,7 +58,7 @@ HB_FUNC( HB_PVALUE ) { LONG lOffset = hb_stackBaseItem()->item.asSymbol.stackstate->lBaseItem; - USHORT uiParam = hb_parni( 1 ); + USHORT uiParam = ( USHORT ) hb_parni( 1 ); if( uiParam && uiParam <= hb_stackItem( lOffset )->item.asSymbol.paramcnt ) {