From cf1dcec33855adf2bef4cf7a6a4b8dd6d89f397a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 13 Jun 2012 22:26:52 +0000 Subject: [PATCH] 2012-06-14 00:24 UTC+0200 Viktor Szakats (harbour syenar.net) * contrib/hbamf/amfdec.c * contrib/hbamf/amfenc.c * contrib/hbamf/amfstdio.c ! fixed about 30 compiler warnings mostly on missing paranthesis causing ambiguous expressions, superfluous variable initializations and one case where probably an 'else' was missing. Please review the patch to see if ambiguous cases were correctly fixed. --- harbour/ChangeLog | 16 +++++++++-- harbour/contrib/hbamf/amfdec.c | 26 ++++++++--------- harbour/contrib/hbamf/amfenc.c | 48 ++++++++++++++++---------------- harbour/contrib/hbamf/amfstdio.c | 4 +-- 4 files changed, 52 insertions(+), 42 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b5ef885dc5..15911beb13 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,16 +16,26 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-14 00:24 UTC+0200 Viktor Szakats (harbour syenar.net) + * contrib/hbamf/amfdec.c + * contrib/hbamf/amfenc.c + * contrib/hbamf/amfstdio.c + ! fixed about 30 compiler warnings mostly on missing + paranthesis causing ambiguous expressions, superfluous + variable initializations and one case where probably + an 'else' was missing. Please review the patch to + see if ambiguous cases were correctly fixed. + 2012-06-13 13:59 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) - contrib/hbqt/qtcore/hbqt_obj.prg - - Deleted: hbQT already has a super class HBQTOBJECTHANDELLER + - Deleted: hbQT already has a super class HBQTOBJECTHANDELLER and concerned protocol is embedded into that. * contrib/hbqt/qtcore/hbqt_hbqevents.cpp * contrib/hbqt/qtcore/hbqt_hbqevents.h ! Changed: constructor without a parent. - In certain situations under current protocol, this had - a overhead where destructor on this object was not being + In certain situations under current protocol, this had + a overhead where destructor on this object was not being called at appropriate time. * contrib/hbqt/qtcore/hbqt_hbqslots.cpp diff --git a/harbour/contrib/hbamf/amfdec.c b/harbour/contrib/hbamf/amfdec.c index 2958519ab4..9eb4c0290a 100644 --- a/harbour/contrib/hbamf/amfdec.c +++ b/harbour/contrib/hbamf/amfdec.c @@ -257,7 +257,7 @@ static HB_BOOL amf3_deserialize_string( amfContext * context, PHB_ITEM pItem ) { int header; int * header_p = &header; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; PHB_ITEM pHash = context->str_ref; if( ! amf3_decode_int( context, header_p ) ) @@ -393,10 +393,10 @@ static HB_BOOL amf3_deserialize_array( amfContext * context, PHB_ITEM pItem, HB_ { int header; int * header_p = &header; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; PHB_ITEM pHash = context->obj_ref; int array_len; - HB_BOOL mixed = HB_FALSE; /* if the result will be a Hash with both numbers and strings as keys */ + HB_BOOL mixed; /* if the result will be a Hash with both numbers and strings as keys */ char * byte_ref; if( ! amf3_decode_int( context, header_p ) ) @@ -506,7 +506,7 @@ static HB_BOOL amf3_deserialize_date( amfContext * context, PHB_ITEM pItem ) { int header; int * header_p = &header; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; PHB_ITEM pHash = context->obj_ref; if( ! amf3_decode_int( context, header_p ) ) @@ -553,7 +553,7 @@ static HB_BOOL amf3_deserialize_byte_array( amfContext * context, PHB_ITEM pItem { int header; int * header_p = &header; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; PHB_ITEM pHash = context->obj_ref; if( ! amf3_decode_int( context, header_p ) ) @@ -657,9 +657,9 @@ static HB_BOOL amf3_decode_class_def( amfContext * context, PHB_ITEM pClass, int { PHB_ITEM pStrAlias = hb_itemNew( NULL ); PHB_ITEM pMappedClassDef = NULL; - PHB_ITEM pKey = NULL; - PHB_ITEM pValue = NULL; - PHB_ITEM pAttrs = NULL; + PHB_ITEM pKey; + PHB_ITEM pValue; + PHB_ITEM pAttrs; int static_attr_len; int i; @@ -788,7 +788,7 @@ static HB_BOOL amf3_decode_class_def( amfContext * context, PHB_ITEM pClass, int static HB_BOOL amf3_deserialize_class_def( amfContext * context, PHB_ITEM pClass, int header ) { PHB_ITEM pHash = context->class_ref; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; /* Check for reference */ pRefItem = amf3_decode_reference( pHash, header ); @@ -941,11 +941,11 @@ static HB_BOOL amf3_deserialize_obj( amfContext * context, PHB_ITEM pItem, HB_BO { int header; int * header_p = &header; - PHB_ITEM pRefItem = NULL; + PHB_ITEM pRefItem; PHB_ITEM pHash = context->obj_ref; - PHB_ITEM pClass = NULL; - PHB_ITEM pMappedClassDef = NULL; - PHB_ITEM pValue = NULL; + PHB_ITEM pClass; + PHB_ITEM pMappedClassDef; + PHB_ITEM pValue; int obj_type; /* 0 = anonymous, 1 == externalizable, 2 == typed */ HB_BOOL result; diff --git a/harbour/contrib/hbamf/amfenc.c b/harbour/contrib/hbamf/amfenc.c index 76bee4b7ac..1920f60bd0 100644 --- a/harbour/contrib/hbamf/amfenc.c +++ b/harbour/contrib/hbamf/amfenc.c @@ -176,22 +176,22 @@ static HB_BOOL amf3_encode_int( amfContext * context, int value ) else if( value < 0x4000 ) { tmp_size = 2; - tmp[ 0 ] = ( char ) ( value >> 7 & 0x7f ) | 0x80; /* Shift bits by 7 to fill 1st byte and set next byte flag */ - tmp[ 1 ] = ( char ) value & 0x7f; /* Shift bits by 7 to fill 2nd byte, leave next byte flag unset */ + tmp[ 0 ] = ( char ) ( ( value >> 7 ) & 0x7f ) | 0x80; /* Shift bits by 7 to fill 1st byte and set next byte flag */ + tmp[ 1 ] = ( char ) value & 0x7f; /* Shift bits by 7 to fill 2nd byte, leave next byte flag unset */ } else if( value < 0x200000 ) { tmp_size = 3; - tmp[ 0 ] = ( char ) ( value >> 14 & 0x7f ) | 0x80; - tmp[ 1 ] = ( char ) ( value >> 7 & 0x7f ) | 0x80; + tmp[ 0 ] = ( char ) ( ( value >> 14 ) & 0x7f ) | 0x80; + tmp[ 1 ] = ( char ) ( ( value >> 7 ) & 0x7f ) | 0x80; tmp[ 2 ] = ( char ) value & 0x7f; } else if( value < 0x40000000 ) { tmp_size = 4; - tmp[ 0 ] = ( char ) ( value >> 22 & 0x7f ) | 0x80; - tmp[ 1 ] = ( char ) ( value >> 15 & 0x7f ) | 0x80; - tmp[ 2 ] = ( char ) ( value >> 8 & 0x7f ) | 0x80; /* Shift bits by 8, since we can use all bits in the 4th byte */ + tmp[ 0 ] = ( char ) ( ( value >> 22 ) & 0x7f ) | 0x80; + tmp[ 1 ] = ( char ) ( ( value >> 15 ) & 0x7f ) | 0x80; + tmp[ 2 ] = ( char ) ( ( value >> 8 ) & 0x7f ) | 0x80; /* Shift bits by 8, since we can use all bits in the 4th byte */ tmp[ 3 ] = ( char ) ( value & 0xff ); } else @@ -261,7 +261,7 @@ static HB_BOOL amf3_encode_string( amfContext * context, PHB_ITEM pItem ) if( context->str_rtrim ) len = hb_strRTrimLen( utf8str, len, HB_FALSE ); - if( ! amf3_encode_int( context, ( ( int ) len ) << 1 | REFERENCE_BIT ) ) + if( ! amf3_encode_int( context, ( ( int ) len << 1 ) | REFERENCE_BIT ) ) return HB_FALSE; result = ( writeBuffer( context, utf8str, len ) != 0 ); @@ -369,7 +369,7 @@ static int amf3_get_index( amfContext * context, PHB_ITEM pHash, PHB_ITEM pItem static int amf3_encode_reference( amfContext * context, PHB_ITEM pHash, PHB_ITEM pItem, int bit ) { - int idx = -1; + int idx; if( pItem == NULL ) return -1; @@ -433,7 +433,7 @@ static HB_BOOL amf3_encode_hash( amfContext * context, PHB_ITEM pItem ) { PHB_ITEM pKey; PHB_ITEM pVal; - int i = 0; + int i; int len = hb_hashLen( pItem ); int nIntKeys = 0; @@ -449,7 +449,7 @@ static HB_BOOL amf3_encode_hash( amfContext * context, PHB_ITEM pItem ) } } - if( ! amf3_encode_int( context, nIntKeys << 1 | REFERENCE_BIT ) ) + if( ! amf3_encode_int( context, ( nIntKeys << 1 ) | REFERENCE_BIT ) ) return HB_FALSE; for( i = 1; i <= len; i++ ) @@ -489,7 +489,7 @@ static HB_BOOL amf3_encode_dynamic_dict( amfContext * context, PHB_ITEM pItem ) { PHB_ITEM pKey; PHB_ITEM pVal; - int i = 0; + int i; int len = hb_hashLen( pItem ); for( i = 1; i <= len; i++ ) @@ -561,7 +561,7 @@ static int amf3_serialize_byte_array( amfContext * context, PHB_ITEM pItem ) if( result > -1 ) return result; - if( ! amf3_encode_int( context, ( ( int ) hb_itemGetCLen( pItem ) ) << 1 | REFERENCE_BIT ) ) + if( ! amf3_encode_int( context, ( ( int ) hb_itemGetCLen( pItem ) << 1 ) | REFERENCE_BIT ) ) return HB_FALSE; return amf3_encode_byte_array( context, pItem ); @@ -596,7 +596,7 @@ static HB_BOOL amf3_encode_array( amfContext * context, PHB_ITEM pItem ) int i; int result; - if( ! amf3_encode_int( context, ( ( int ) item_len ) << 1 | REFERENCE_BIT ) ) + if( ! amf3_encode_int( context, ( ( int ) item_len << 1 ) | REFERENCE_BIT ) ) return HB_FALSE; if( ! writeByte( context, NULL_TYPE ) ) @@ -633,10 +633,10 @@ static int amf3_encode_class_def( amfContext * context, PHB_ITEM pClass ) int result; int static_attr_len; int i; - PHB_ITEM class_alias = NULL; - PHB_ITEM static_attrs = NULL; - /* PHB_ITEM attr_len = NULL; */ - PHB_ITEM attr_name = NULL; + PHB_ITEM class_alias; + PHB_ITEM static_attrs; +/* PHB_ITEM attr_len = NULL; */ + PHB_ITEM attr_name; if( ! pClass ) { @@ -680,7 +680,6 @@ static int amf3_encode_class_def( amfContext * context, PHB_ITEM pClass ) return result; } - static_attrs = hb_hashGetCItemPtr( pClass, "static_attrs" ); if( ! static_attrs ) { @@ -720,7 +719,7 @@ static int amf3_encode_class_def( amfContext * context, PHB_ITEM pClass ) return 0; } - /* not needed hb_itemRelease(static_attrs); */ + /* not needed hb_itemRelease( static_attrs ); */ return 1; } @@ -1039,7 +1038,8 @@ static HB_BOOL amf3_encode( amfContext * context, PHB_ITEM pItem ) { if( ! writeByte( context, DATE_TYPE ) ) result = HB_FALSE; - result = amf3_serialize_date( context, pItem ); + else + result = amf3_serialize_date( context, pItem ); } else if( HB_IS_OBJECT( pItem ) ) { @@ -1253,7 +1253,7 @@ HB_FUNC( AMF3_FROMWA ) /* TODO: should be if( writeByte() ), before we make a variant that operates on streams directly */ writeByte( context, ARRAY_TYPE ); - amf3_encode_int( context, ( ( int ) nCount ) << 1 | REFERENCE_BIT ); + amf3_encode_int( context, ( ( int ) nCount << 1 ) | REFERENCE_BIT ); writeByte( context, NULL_TYPE ); SELF_FIELDCOUNT( pArea, &uiFields ); @@ -1341,7 +1341,7 @@ HB_FUNC( AMF3_FROMWA ) writeByte( context, ARRAY_TYPE ); if( bNoFieldPassed ) { - amf3_encode_int( context, ( ( int ) uiFields ) << 1 | REFERENCE_BIT ); + amf3_encode_int( context, ( ( int ) uiFields << 1 ) | REFERENCE_BIT ); writeByte( context, NULL_TYPE ); for( uiIter = 1; uiIter <= uiFields; uiIter++ ) { @@ -1351,7 +1351,7 @@ HB_FUNC( AMF3_FROMWA ) } else { - amf3_encode_int( context, ( ( int ) uiFieldCopy ) << 1 | REFERENCE_BIT ); + amf3_encode_int( context, ( ( int ) uiFieldCopy << 1 ) | REFERENCE_BIT ); writeByte( context, NULL_TYPE ); for( uiIter = 1; uiIter <= uiFieldCopy; uiIter++ ) { diff --git a/harbour/contrib/hbamf/amfstdio.c b/harbour/contrib/hbamf/amfstdio.c index b8c910f65d..2d89964a2e 100644 --- a/harbour/contrib/hbamf/amfstdio.c +++ b/harbour/contrib/hbamf/amfstdio.c @@ -41,9 +41,9 @@ HB_FUNC( AMFSTDIO_READ ) char * pszLenPrefix = ( char * ) hb_xgrab( 5 ); char * pszBuf; /* = ( char * ) hb_xgrab( SINGLEBUF ); */ char * pszTmp = pszLenPrefix; - HB_USHORT nBytes = 0; + HB_USHORT nBytes; int nTotal = 0; - int nLen = 0; + int nLen; int nToRead; HB_FHANDLE hStdIn = hb_fsGetOsHandle( HB_STDIN_HANDLE );